230 likes | 395 Views
Algorithm for Gauss elimination 1) first eliminate for each eq. j, j=1 to n-1 for all eq.s k greater than j a) multiply eq. j by a kj /a jj b) subtract the result from eq. K This leads to upper triangular. 2) now backsubstitute a) determine x n from b) put x n into n-1 eq.
E N D
Algorithm for Gauss elimination • 1) first eliminate • for each eq. j, j=1 to n-1 • for all eq.s k greater than j • a) multiply eq. j by akj/ajj • b) subtract the result from eq. K • This leads to upper triangular
2) now backsubstitute • a) determine xn from • b) put xn into n-1 eq. • c) solve for xn-1 • d) repeat from b), moving back to n-2, n-3, etc. until all equations are solved
Operation counting • Important as matrix gets large • For Gauss elimination • elimination routine uses on the order of • operations • backsubstitution uses
Problems with Gauss elimination (as done last time) 1) division by zero 2) round off errors 3) ill conditioned systems
Division by zero Using first eq. to eliminate x1 in second eq. means dividing by 0
Pivoting developed to avoid this find row with largest absolute value under pivot element switch rows More later
Round off errors With more than n3/3 operations, get a lot of chopping. More important - error is propagted More than 100 equations - round can be very important - system dependent
Ill conditioned systems - small changes in coefficients lead to large changes in solution Round-off errors especially important in ill-conditioned systems
Can write as Since slopes are almost equal
Determinant close to zero indicates ill-conditioned set of equations. How close? No clear answer Problem of scale
However, graphically No change
Scaling Make maximum element in any row =1
Another problem - singular systems Two equations in the set are the same Determinant is 0.
How to avoid pitfalls • higher precision • pivoting • scaling
Partial Pivoting Determine the largest coefficient in the column below pivot element Then switch rows (Compete pivot switches columns also, but is rarely used.)
Example: Exchange rows 2 and 3 And now eliminate
Algorithm for Gauss elimination using improvements • 1) first eliminate • for each eq. j, j=1 to n-1 • first scale each equation k greater than j • then pivot • now • a) multiply eq. j by akj/ajj • b) subtract the result from eq. k
The Gauss Jordan method Major difference - eliminate unknowns from all rows, not just subsequent ones Normalize matrix so all entries are 1 Leads to identity matrix instead of upper triangular Backsubstitution is easy