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
Example First pivot
Normalize pivot row
Multiply 1st row by 3 and subtract from 2nd row
Do the other two rows Now pivot again
Normalize
Multiply 2nd row by 0.75 and subtract from first row
For first row and after all eliminated
No need to pivot, so normalize Work on rows 1,2 and 4 with row 3
No rows below row 4 to pivot with, so normalize and eliminate column 4
We now have our answer, since backsubstitution is trivial
LU decomposition - another method for solving matrix equations Idea behind LU decomposition - start with or
We know (because we did it in G.E.) we can write i.e or
Assume there exists [L] such that
means that
LU method 1) factor (decompose) A into L and U 2) given b, determine d from Ld=b 3) using Ux=d and backsubstitution, solve for x Advantage: Once you have L and U, can use many different b’s
How do you get L and U? Gauss elimination gives you U. It also gives you L. The factors are the entries in L
Changes in algorithm for Gauss elimination for LU decomposition loop over all the rows except the last one loop over all the rows below the current one get fik = aik/akk multiply row k by f and subtract from row i put fik in L at row i, column k end loop A is now upper triangular U make all Lkk=1
A fancier way of storing L and U Good if n is large More overhead to sort out
Pivoting in LU decomposition Still need it Messes up order of L What to do? Need to pivot also both L and a permutation matrix P
Initialize P as identity matrix and pivot when A is pivoted Initialize P as identity matrix and pivot when A is pivoted. Also pivot L
Example Starting out
No pivot
Now exchange rows 2 and 4
The pivot factors are
No pivot again, factor
Now make the diagonal elements of L=1
Recall
LU method 1) factor (decompose) A into L and U 2) given b, determine d 3) using Ux=d and backsubstitution, solve for x Advantage: Once you have L and U, can use many different b’s
Example (no pivoting):
Get d
Use Ux=d and backsubstitute
Now change b We don’t have to do elimination again Use the same L and U
Get d
Use Ux=d and backsubstitute