Download presentation
Presentation is loading. Please wait.
Published bySherman Harris Modified over 6 years ago
1
Chapter 10: Solving Linear Systems of Equations
Introduction Requirements for a solution Gaussian elimination This covers Ch. 8 of the Numerical Methods with MATLAB: Implementation and Application book.
2
Introduction Motivational example: Pump Curve Model
Objective: Find the coefficients of the quadratic equation that approximates the data from a pump. Curve model equation: โ= ๐ 1 ๐ 2 + ๐ 2 ๐+ ๐ 3 How to identify ๐ 1 , ๐ 2 , ๐ 3 ? Three data points: 1ร 10 โ4 ,115 8ร 10 โ4 ,110 (1.4ร 10 โ3 ,92.5) โ: ๐:
3
Introduction Substitute each pair of data points into the model equation: Rewrite in matrix form as:
4
Introduction Using more compact symbolic notation: ๐ด๐ฅ=๐
where ๐ด= 1ร 10 โ8 1ร 10 โ ร 10 โ8 8ร 10 โ ร 10 โ8 14ร 10 โ4 1 , ๐ฅ= ๐ 1 ๐ 2 ๐ 3 , ๐= Our goal: How to numerically solve for the unknown vector ๐ฅ?
5
Introduction Solving systems of equations is one of the most widely automated computing tasks. In this chapter, we will focus on: setting up a system of equations; using the built-in capability of MATLAB to solve the system; developing and understanding the numerical complications that affect the reliability of the computed result.
6
Introduction The generic system of equations is ๐ด๐ฅ=๐:
๐ด is an ๐ร๐ matrix of known real numbers; ๐ฅ is a length-๐ vector of unknowns to be determined; ๐ is a length-๐ vector of known real numbers. Before solving, we always need to go from the physical problem to the general linear-algebra form (๐ด, ๐ฅ, and ๐). Only consider linear equations hereโฆ
7
Introduction How to put system equations into the standard form? Recommended procedure: Write the equations in their natural form. Identify unknowns, and order them. Isolate the unknowns. Write equations in matrix form.
8
Requirements for a Solution
The nature of the solution to ๐ด๐ฅ=๐ depends on the shape of matrix ๐ด: โ โ โ โ โ โ โ โ โ ๐=๐ โ โ โ โ โ โ โ โ โ โ โ โ ๐>๐ โ โ โ โ โ โ โ โ โ โ โ โ ๐<๐ Solving ๐ด๐ฅ=๐ for ๐ unknowns related by ๐ equations. Overdetermined systems (more equations than unknowns) Underdetermined systems (less equations than unknowns).
9
Requirements for a Solution
Consistency: the Elements of the unknown vector ๐ฅ are the coefficients in the linear combination of the columns of ๐ด that yield the vector ๐. ๐ด๐ฅ=๐ โ ๐ฅ 1 ๐ 11 โฎ ๐ ๐1 + ๐ฅ 2 ๐ 12 โฎ ๐ ๐2 +โฆ+ ๐ฅ ๐ ๐ 1๐ โฎ ๐ ๐๐ = ๐ 1 โฎ ๐ ๐ If an exact solution to Ax = b exists, b must lie in the column space of A. If it does, then the system is said to be consistent. Otherwise, the system is said to be inconsistent.
10
Requirements for a Solution
How to check if a system is consistent or not? Can be expressed by forming the augmented matrix ๐ด from the columns of ๐ด and the vector ๐: ๐ด = ๐ด ๐ = ๐ 11 โฎ ๐ ๐1 ๐ 12 โฎ ๐ ๐2 โฆ ๐ 1๐ โฎ ๐ ๐๐ ๐ 1 โฎ ๐ ๐ ๐ด and ๐ are consistent if and only if ๐ด and ๐ด have the same rank, i.e. rank( ๐ด )=rank (๐ด). If rank( ๐ด )>rank (๐ด), the vector ๐ does not lie in the column space of ๐ด. An exact solution is therefore not possible.
11
Requirements for a Solution
Role of ๐๐๐๐(๐ด): If ๐๐๐๐(๐ด) = ๐ and the system is consistent, the solution exists and it is unique. If ๐๐๐๐(๐ด) < ๐ and the system is consistent, an infinite number of solutions exist. If the system is inconsistent, no solution exists. E.g., ๐ฅ 1 ๐ฅ 2 = rank (A)=rank([A b]): the system is consistent, and solution exists. rank(A)=2=# of unknowns: the solution is unique.
12
Requirements for a Solution
Special case, ๐=๐: For ๐ร๐ systems, the rank of ๐ด tells us a lot. If ๐๐๐๐(๐ด)=๐, the columns of ๐ด span the ๐น ๐ space, and hence any length-๐ vector lies in the column space of ๐ด. In other words, ๐๐๐๐([๐ด ๐])=๐ for any vector ๐. For a system of ๐ equations and ๐ unknowns in the form ๐ด๐ฅ=๐, the solution ๐ฅ exists and is unique for any ๐ if and only if ๐๐๐๐(๐ด)=๐.
13
Requirements for a Solution
Again, for ๐ร๐ systems, the unique solution is ๐ฅ= ๐ด โ1 ๐ if and only if ๐ด โ1 exists. Several ways to check if ๐ด โ1 exists or not (equivalent conditions): ๐๐๐๐(๐ด)=๐ (๐ด is a full rank matrix) detโก(๐ด)โ 0 The columns of ๐ด are linearly independent. The rows of ๐ด are linearly independent.
14
Requirements for a Solution
If ๐ด โ1 exists, ๐ด๐ฅ=๐ โ ๐ฅ= ๐ด โ1 ๐ Lots of computer tools allow you to compute ๐ด โ1 directly, so then you can find ๐ฅ . However, there are many reasons you may not want to solve equations this way: more roundoff error, more operations (computations), โฆ We use Gaussian elimination to solve the system. Not only saves computer time, also produces a result with less roundoff error (fewer operations). The matrix inverse ๐ด โ1 is more of a conceptual device than a computational tool here. People donโt normally use it to solve linear systems.
15
Gaussian Elimination To start, let us consider a special case:
Triangular systems: Lower triangular systems: ๐ ๐๐ =0 for all ๐<๐ ๐ด= ๐ ๐ 21 โฎ ๐ ๐ ๐ 22 โฎ ๐ ๐2 โฆ โฎ ๐ ๐๐ Upper triangular systems: ๐ ๐๐ =0 for all ๐>๐ ๐ด= ๐ โฎ ๐ ๐ 22 โฎ 0 โฆ ๐ 1๐ ๐ 2๐ โฎ ๐ ๐๐
16
Gaussian Elimination Solving triangular systems: (upper-triangular)
Equivalent to solve: Solve in backward order (last equation is solved first):
17
Gaussian Elimination Solving for ๐ฅ ๐ , ๐ฅ ๐โ1 ,โฆ, ๐ฅ 1 for an upper triangular system is called backward substitution.
18
Gaussian Elimination Solving triangular systems: (lower-triangular)
๐ด= โ2 0 โ , b= 8 โ1 9 Equivalent to solve: 4 ๐ฅ 1 =8 3 ๐ฅ 1 โ2 ๐ฅ 2 =โ1 โ2 ๐ฅ 1 + ๐ฅ 2 +2 ๐ฅ 3 =9 Solve in forward order (first equation is solved first): ๐ฅ 1 =8/4=2 ๐ฅ 2 =(3 ๐ฅ 1 +1)/2=7/2 ๐ฅ 3 =(9+2 ๐ฅ 1 โ ๐ฅ 2 )/2=19/4
19
Gaussian Elimination Solving for ๐ฅ 1 , ๐ฅ 2 ,โฆ, ๐ฅ ๐ for a lower triangular system is called forward substitution.
20
Gaussian Elimination How to solve a general equation by hand?
Subtract 2 times the first equation from the second equation This equation is now in upper-triangular form, and can be solved by backward substitution. The elimination phase transforms the matrix and right hand side to an equivalent system. The two systems have the same solution.
21
Gaussian Elimination Goal is to transform an arbitrary, square system into the equivalent upper triangular system so that it may be easily solved with backward substitution. We need to perform the Gaussian elimination to [๐ด ๐], the augmented matrix (not just ๐ด)!
22
Gaussian Elimination For example, to solve: Form the augmented system:
Add 2 times row 1 to row 2, and add (1 times) row 1 to row 3: ๐ด (1) Subtract (1 times) row 2 from row 3: ๐ด (2)
23
Gaussian Elimination The transformed system is now in upper triangular form: Solve by back substitution to get:
24
Gaussian Elimination The procedure for Gaussian elimination:
Pivot: ๐ ๐๐ , ratio: ๐ ๐๐ / ๐ ๐๐ ๐ ๐๐ = ๐ ๐๐ โ( ๐ ๐๐ / ๐ ๐๐ )โ ๐ ๐๐ ๐ด = ๐ด ๐ = ๐ 11 ๐ ๐ 13 ๐ 14 ๐ 1 ๐ 21 ๐ ๐ 23 ๐ 24 ๐ ๐ 31 ๐ ๐ 32 ๐ ๐ 33 ๐ 34 ๐ ๐ 43 ๐ 44 ๐ 4 Column ๐=1 Column ๐=2 Column ๐=3 Row ๐=1 Row ๐=2 Row ๐=3 ร( ๐ 41 / ๐ 11 ) ร( ๐ 31 / ๐ 11 ) ร( ๐ 21 / ๐ 11 ) ร( ๐ 43 โฒโฒ / ๐ 33 โฒโฒ ) ร( ๐ 32 โฒ / ๐ 22 โฒ ) ร( ๐ 42 โฒ / ๐ 22 โฒ ) Row ๐=2 Row ๐=3 Row ๐=4
25
Gaussian Elimination Note : This process requires that all the diagonal elements are nonzero! (Otherwise the ratio ๐ ๐๐ / ๐ ๐๐ is undefined since denominator is zero.) The GaussianElimination function uses Gaussian elimination to solve a system of equations. >> GaussianElimination(A,b) ans = 2 -1
26
Gaussian Elimination Unfortunately, the Gaussian elimination algorithm does not work alwaysโฆ One counterexample: matrix ๐ด is full rank, a unique solution exists. Now form the augmented system:
27
Gaussian Elimination Start the elimination for the pivot location ๐ 11 : Subtract 1/2 times the first row from the second row; Add 3/2 times the first row to the third row; Add 1/2 times the first row to the fourth row. The next stage of Gaussian elimination will not work, because there is a zero in the pivot location ๐ 22 .
28
Gaussian Elimination What to do if we run into this situation?
A smart way is to swap the second and fourth rows of the augmented matrix. Why does this work? Because we are just re-ordering the unknowns here, and not changing the system. This row exchanging method to avoid zeros at pivot locations is called Gaussian Elimination with Pivoting.
29
Gaussian Elimination Continue with elimination: subtract (1 times) row 2 from row 3. Another zero has appear in the pivot position. Swap row 3 and row 4. The augmented system is now ready for backward substitution.
30
Gaussian Elimination The GaussianEliminationPivot function uses Gaussian elimination with pivoting to solve a system of equations.
31
Gaussian Elimination Ex: >> GaussianEliminationPivot(A,b)
Swap rows 1 and 3; new pivot = -3 Swap rows 2 and 3; new pivot = 2 ans = 1.0000 2.0000 3.0000 4.0000
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.