Download presentation

Presentation is loading. Please wait.

Published byLora Ford Modified over 4 years ago

1
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 ~ Linear Algebraic Equations ~ Gauss Elimination Chapter 9 Credit: Prof. Lale Yurttas, Chemical Eng., Texas A&M University

2
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2 Solving Systems of Equations A linear equation in n variables: a 1 x 1 + a 2 x 2 + … + a n x n = b For small (n ≤ 3), linear algebra provides several tools to solve such systems of linear equations: –Graphical method –Cramer’s rule –Method of elimination Nowadays, easy access to computers makes the solution of very large sets of linear algebraic equations possible

3
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 3 Determinants and Cramer’s Rule [A] : coefficient matrix D : Determinant of A matrix

4
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 Computing the Determinant

5
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 5 Gauss Elimination Solve Ax = b Consists of two phases: –Forward elimination –Back substitution Forward Elimination reduces Ax = b to an upper triangular system Tx = b’ Back substitution can then solve Tx = b’ for x Forward Elimination Back Substitution

6
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 6 Gaussian Elimination Forward Elimination x 1 - x 2 + x 3 = 6 3x 1 + 4x 2 + 2x 3 = 9 2x 1 + x 2 + x 3 = 7 x 1 - x 2 + x 3 = 6 0 +7x 2 - x 3 = -9 0 + 3x 2 - x 3 = -5 x 1 - x 2 + x 3 = 6 0 7x 2 - x 3 = -9 0 0 -(4/7)x 3 =-(8/7) -(3/1) Solve using BACK SUBSTITUTION: x 3 = 2 x 2 =-1 x 1 =3 -(2/1) -(3/7) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

7
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 7 Back Substitution 1x01x0 +1x 1 –1x2–1x2 +4x 3 8= – 2x 1 –3x2–3x2 +1x 3 5= 2x22x2 – 3x 3 0= 2x32x3 4= x 3 = 2

8
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 8 1x01x0 +1x 1 –1x2–1x2 0= – 2x 1 –3x2–3x2 3= 2x22x2 6= Back Substitution x 2 = 3

9
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 9 1x01x0 +1x 1 3= – 2x 1 12= Back Substitution x 1 = –6

10
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1x01x0 9= Back Substitution x 0 = 9

11
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 11 for i n down to 1 do /* calculate x i */ x [ i ] b [ i ] / a [ i, i ] /* substitute in the equations above */ for j 1 to i-1 do b [ j ] b [ j ] x [ i ] × a [ j, i ] endfor Back Substitution (* Pseudocode *) Time Complexity? O(n 2 )

12
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 12 Gaussian Elimination Forward Elimination

13
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 13 Forward Elimination 4x04x0 +6x 1 +2x 2 – 2x 3 =8 2x02x0 +5x 2 – 2x 3 =4 –4x0–4x0 – 3x 1 – 5x 2 +4x 3 =1 8x08x0 +18x 1 – 2x 2 +3x 3 =40 -(2/4) MULTIPLIERSMULTIPLIERS -(-4/4) -(8/4)

14
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 14 4x04x0 +6x 1 +2x 2 – 2x 3 =8 +4x 2 – 1x 3 =0 +3x 1 – 3x 2 +2x 3 =9 +6x 1 – 6x 2 +7x 3 =24 – 3x 1 -(3/-3) MULTIPLIERSMULTIPLIERS Forward Elimination -(6/-3)

15
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 15 4x04x0 +6x 1 +2x 2 – 2x 3 =8 +4x 2 – 1x 3 =0 1x21x2 +1x 3 =9 2x22x2 +5x 3 =24 – 3x 1 ?? MULTIPLIERMULTIPLIER Forward Elimination

16
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 16 4x04x0 +6x 1 +2x 2 – 2x 3 =8 +4x 2 – 1x 3 =0 1x21x2 +1x 3 =9 3x33x3 =6 – 3x 1 Forward Elimination

17
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 17 Gaussian Elimination Operation count in Forward Elimination 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2n TOTAL 1 st column: 2n(n-1) 2n 2 2(n-1) 2 2(n-2) 2 ……. b 11 b 22 b 33 b 44 b 55 b 66 b 77 b 66

18
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 18 Pitfalls of Elimination Methods Division by zero It is possible that during both elimination and back-substitution phases a division by zero can occur. For example: 2x 2 + 3x 3 = 8023 4x 1 + 6x 2 + 7x 3 = -3 A =467 2x 1 + x 2 + 6x 3 = 5216 Solution: pivoting (to be discussed later)

19
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 19 Pitfalls (cont.) Round-off errors Because computers carry only a limited number of significant figures, round-off errors will occur and they will propagate from one iteration to the next. This problem is especially important when large numbers of equations (100 or more) are to be solved. Always use double-precision numbers/arithmetic. It is slow but needed for correctness! It is also a good idea to substitute your results back into the original equations and check whether a substantial error has occurred.

20
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. ill-conditioned systems - small changes in coefficients result in large changes in the solution. Alternatively, a wide range of answers can approximately satisfy the equations. (Well-conditioned systems – small changes in coefficients result in small changes in the solution) Problem: Since round off errors can induce small changes in the coefficients, these changes can lead to large solution errors in ill-conditioned systems. Example: x 1 + 2x 2 = 10 1.1x 1 + 2x 2 = 10.4 x 1 + 2x 2 = 10 1.05x 1 + 2x 2 = 10.4 Pitfalls (cont.)

21
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Surprisingly, substitution of the erroneous values, x 1 =8 and x 2 =1, into the original equation will not reveal their incorrect nature clearly: x 1 + 2x 2 = 108+2(1) = 10 (the same!) 1.1x 1 + 2x 2 = 10.4 1.1(8)+2(1)=10.8 (close!) IMPORTANT OBSERVATION: An ill-conditioned system is one with a determinant close to zero If determinant D=0 then there are infinitely many solutions singular system Scaling (multiplying the coefficients with the same value) does not change the equations but changes the value of the determinant in a significant way. However, it does not change the ill-conditioned state of the equations! DANGER! It may hide the fact that the system is ill-conditioned!! How can we find out whether a system is ill-conditioned or not? Not easy! Luckily, most engineering systems yield well-conditioned results! One way to find out: change the coefficients slightly and recompute & compare ill-conditioned systems (cont.) –

22
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 22 COMPUTING THE DETERMINANT OF A MATRIX USING GAUSSIAN ELIMINATION The determinant of a matrix can be found using Gaussian elimination. Here are the rules that apply: Interchanging two rows changes the sign of the determinant. Multiplying a row by a scalar multiplies the determinant by that scalar. Replacing any row by the sum of that row and the multiple of any other row does NOT change the determinant. The determinant of a triangular matrix (upper or lower triangular) is the product of the diagonal elements. i.e. D=t 11 t 22 t 33

23
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Techniques for Improving Solutions

24
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 24 Gauss-Jordan Elimination 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a 11 x 22 0 x 33 0 0 x 44 0 0 0 x 55 0 0 0 0 x 66 x 77 x 88 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b 11 b 22 b 33 b 44 b 55 b 66 b 77 b 88 b 99 000 x 99

25
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 25 Gauss-Jordan Elimination: Example R2 R2 - (-1)R1 R3 R3 - ( 3)R1 Scaling R2: R2 R2/(-1) R1 R1 - (1)R2 R3 R3-(4)R2 Scaling R3: R3 R3/(18) R1 R1 - (7)R3 R2 R2-(-5)R3 RESULT: x 1 =8.45, x 2 =-2.89, x 3 =1.23 Time Complexity? O(n 3 )

26
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 26 Systems of Nonlinear Equations Locate the roots of a set of simultaneous nonlinear equations: Systems of Nonlinear Equations

27
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. First-order Taylor series expansion of a function with more than one variable: The root of the equation occurs at the value of x 1 and x 2 where f 1(i+1) =0 and f 2(i+1) =0 Rearrange to solve for x 1(i+1) and x 2(i+1) Since x 1(i), x 2(i), f 1(i), and f 2(i) are all known at the i th iteration, this represents a set of two linear equations with two unknowns, x 1(i+1) and x 2(i+1) You may use several techniques to solve these equations

28
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 28 General Representation for the solution of Nonlinear Systems of Equations Solve this set of linear equations at each iteration: Jacobian Matrix

29
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 29 Solution of Nonlinear Systems of Equations Solve this set of linear equations at each iteration: Rearrange:

30
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. n non-linear equations n unknowns to be solved: Jacobian Matrix: Need to solve this set of Linear Equations in each and every iterative solution of the original Non-Linear system of equations. For n unknowns, the size of the Jacobian matrix is n 2 and the time it takes to solve the linear system of equations (one iteration of the non-linear system) is proportional to O(n 3 ) There is no guarantee for the convergence of the non-linear system. There may also be slow convergence. In summary, finding the solution set for the Non-Linear system of equations is an extremely compute-intensive task. 30 Notes on the solution of Nonlinear Systems of Equations

Similar presentations

© 2019 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google