**Unformatted text preview:**

Lecture 8 Gaussian Elimination AMath 352 Wed Apr 14 1 13 1 2 3 1 4 5 6 0 7 8 0 2 1 2 3 1 0 3 6 4 0 6 21 5 that is if then L1 1 0 0 4 1 0 7 0 1 L1A 1 0 0 4 1 0 7 0 1 1 2 3 4 5 6 7 8 0 1 2 3 0 3 6 0 6 21 Gaussian Elimination as LU Factorization Solve A cid 126 x cid 126 b A is n by n nonsingular Example 1 2 3 4 5 6 7 8 0 1 0 2 x1 x2 x3 2 13 Gaussian Elimination as LU Factorization Solve A cid 126 x cid 126 b A is n by n nonsingular Example 1 2 3 4 5 6 7 8 0 1 0 2 x1 x2 x3 1 2 3 1 4 5 6 0 7 8 0 2 2 3 1 1 0 3 6 4 0 6 21 5 that is if then L1 1 0 0 4 1 0 7 0 1 L1A 1 0 0 4 1 0 7 0 1 1 2 3 4 5 6 7 8 0 1 3 2 0 3 6 0 6 21 2 13 1 2 3 0 3 6 4 0 6 21 5 1 2 3 0 3 6 4 0 9 1 3 1 0 1 0 L2 0 0 1 0 0 2 1 1 0 0 0 1 0 0 2 1 1 2 3 2 3 0 3 6 0 6 21 0 3 6 0 9 1 0 that is if then L2L1A Gaussian Elimination as LU Factorization Cont L1 1 0 0 4 1 0 7 0 1 L1A 1 3 2 0 3 6 0 6 21 3 13 Gaussian Elimination as LU Factorization Cont L1 1 0 0 4 1 0 7 0 1 L1A 1 3 2 0 3 6 0 6 21 2 3 1 1 0 3 6 4 0 6 21 5 2 3 1 1 0 3 6 4 3 0 9 0 L2 0 0 1 0 1 0 0 2 1 that is if then L2L1A 0 0 1 0 1 0 0 2 1 1 3 2 0 3 6 0 6 21 1 3 2 0 3 6 0 9 0 3 13 To get L 1 and L 1 o diagonal entries 1 from L1 and L2 just change the signs of the 2 L1 L2 1 4 7 1 0 0 1 0 0 1 0 2 0 0 1 0 0 1 L 1 1 L 1 2 1 4 7 1 0 0 0 1 0 0 1 2 0 0 1 0 0 1 To compute the product L 1 1 L 1 2 just put 1 s on the diagonal and take the o diagonal entries of both L 1 and L 1 2 1 L L 1 1 L 1 2 1 4 7 0 1 2 0 0 1 Gaussian Elimination as LU Factorization Cont L2L1A U L1A L 1 2 U A L 1 Claim We have factored A in the form LU where L is lower triangular with 1 s on its diagonal and U is upper triangular 1 L 1 2 U 4 13 Gaussian Elimination as LU Factorization Cont 1 L 1 L2L1A U L1A L 1 2 U A L 1 Claim We have factored A in the form LU where L is lower triangular with 1 s on its diagonal and U is upper triangular To get L 1 and L 1 1 2 o diagonal entries from L1 and L2 just change the signs of the 2 U L1 1 4 7 0 0 1 0 0 1 L 1 1 L2 1 0 0 2 0 0 1 0 1 To compute the product L 1 1 L 1 take the o diagonal entries of both L 1 L 1 2 1 4 7 0 0 1 0 0 1 1 0 0 0 1 0 0 2 1 2 just put 1 s on the diagonal and and L 1 2 1 L L 1 1 L 1 2 1 4 7 0 0 1 0 2 1 4 13 Use the LU factors to solve linear systems with di erent right hand sides L cid 126 y cid 126 b U cid 126 x cid 126 y L U cid 126 x LU cid 126 x A cid 126 x L cid 126 y cid 126 b Gaussian Elimination as LU Factorization Cont Check LU 1 0 0 4 1 0 7 2 1 1 3 2 0 3 6 0 9 0 1 2 3 4 5 6 7 8 0 5 13 Gaussian Elimination as LU Factorization Cont Check LU 1 0 0 4 1 0 7 2 1 1 3 2 0 3 6 0 9 0 1 2 3 4 5 6 7 8 0 Use the LU factors to solve linear systems with di erent right hand sides L cid 126 y cid 126 b U cid 126 x cid 126 y L U cid 126 x LU cid 126 x A cid 126 x L cid 126 y cid 126 b 5 13 First step of Gaussian Elimination L eye n Initialize L to the identity for i 2 n mult A i 1 A 1 1 L i 1 mult A i A i mult A 1 b i b i mult b 1 end Generalize to n by n Matrices a12 a11 a22 a21 an1 an2 a1n a2n ann b1 b2 bn a11 0 0 a12 a22 an2 a1n a2n ann b1 b2 bn 6 13 Generalize to n by n Matrices a12 a11 a22 a21 an1 an2 a1n a2n ann b1 b2 bn a11 0 0 a12 a22 an2 a1n a2n ann b1 b2 bn First step of Gaussian Elimination L eye n Initialize L to the identity for i 2 n mult A i 1 A 1 1 L i 1 mult A i A i mult A 1 b i b i mult b 1 end 6 13 Gaussian elimination without pivoting for j 1 n 1 Loop over columns for i j 1 n Loop over rows below row j mult A i j A j j L i j mult A i A i mult A j b i b i mult b j end end Gaussian Elimination Without Pivoting a11 0 0 a12 a22 an2 a1n a2n ann b1 b2 bn a11 a12 0 a22 0 0 a1n a2n ann b1 b2 bn 7 13 Gaussian Elimination Without Pivoting a11 0 0 a12 a22 an2 a1n a2n ann b1 b2 bn a11 a12 0 a22 0 0 a1n a2n ann b1 b2 bn Gaussian elimination without pivoting for j 1 n 1 Loop over columns for i j 1 n Loop over rows below row j mult A i j A j j L i j mult A i A i mult A j b i …

View Full Document