When we have to solve Ax=b for many different right-hand sides b using the same matrix A, running Gaussian elimination on A from scratch every time repeats the exact same work, so we want to save our elimination steps inside a matrix of their own.
by reducing A to an upper triangular matrix U and saving the multipliers we subtracted in a lower triangular matrix L.
The row operation that subtracts m times row j from row i can be written as an elimination matrix Eij by placing −m into the (i,j) spot of the identity matrix, and its inverse Eij−1 simply flips −m to +m because adding m times row j back undoes the subtraction:
undo stepsubtract 2R1 from R2E21=1−20010001add 2R1 back to R2E21−1=120010001
Saving Elimination Steps in L and U
Text solution
Clear below the first pivotUse the 1 in the (1,1) spot to eliminate the 2 and 3 below it by subtracting 2 times Row 1 from Row 2 and 3 times Row 1 from Row 3.
Move the elimination matrices onto U to form LSolving E32E31E21A=U for A reverses the order into E21−1E31−1E32−1U, which puts the multipliers 2,3, and 4 directly into the spots they zeroed out.
So A=LU saves the finished upper triangular matrix in U and the exact multipliers 2,3, and 4 subtracted during elimination in L. On a test, you don't need to write out the E matrices: just start L with 1s on the diagonal and 0s above it, and put each multiplier straight into the spot it zeros out.
On the A side: E32E31E21A=U
Row 1
Row 2
Row 3
−2R1
−4R2
−3R1
(−4)(−2R1)−3+8=+8R1=5, the (3,1) entry of E
On the U side: A=LU
U
121
013
002
3
4
1
31017
row 3 of A
L=123014001
On the A side of the equation, later elimination matrices act on rows that earlier steps already changed, which mixes the multipliers so the (3,1) entry of the product E32E31E21 becomes −3+8=5. Across the equals sign on the U side, their inverses act in reverse order on the finished rows of U, so the multipliers 2,3, and 4 go untouched into L.
On the A side, later elimination steps act on earlier ones and mix the multipliers, while moving the matrices to the U side reverses their order so every multiplier goes straight into L unchanged.
2
Solving Ax=b with Forward and Back Substitution
Now that A is factored into LU, we want to solve our original system
Ax=bforb=61740
without doing row operations on A again. Replacing A with LU lets us name the unknown vector Ux as y and split the problem into two triangular systems:
So x=121 solves Ax=b, and the intermediate vector y=652 is the exact right-hand side we would have gotten by applying the row operations on A to b.
Whenever the right-hand side b changes, A,L, and U stay completely fixed while Ly=b runs the saved elimination steps on b from top to bottom and Ux=y solves for the new x from bottom to top.
Once the matrix is factored, you can solve for any new load in two quick passes without redoing elimination.
3
Negative and Fractional Multipliers
In the first example, both pivots we eliminated with were 1 and every step subtracted a positive whole number. Now let's factor
A=2−414−65227
into A=LU, where the pivots are not 1 and elimination requires adding a row or subtracting fractions.
Negative and Fractional Multipliers
2
4
2
−4
−6
2
1
5
7
=
1
0
0
1
0
1
?
A
L
U
Text solution
Clear below the first pivot 2Add 2 times Row 1 to Row 2 (which is subtracting −2 times Row 1, so L21=−2) and subtract 21 times Row 1 from Row 3 (so L31=21).
So A=LU works the same way with negative and fractional multipliers, and multiplying the first column of L by the first pivot 2 in U immediately rebuilds the first column 2−41 of A.
To get the sign and fraction right every time, divide the entry you are eliminating by the pivot you are using:
Lij=pivot being used in row jentry being eliminated in row i
4
Row Swaps and PA=LU
Dividing by the pivot works whenever the pivot is nonzero, but elimination can put a 0 into a pivot position. We want to factor A and solve
A123247156x1x2x3=b51622
where clearing the first column leaves a 0 in the (2,2) pivot spot.
To move a nonzero number into a pivot spot, we swap rows using a permutation matrix P, which is the identity matrix with the exact same rows swapped:
swap Row 2 and Row 3I=100010001permutation matrixP=100001010
Row Swaps and PA = LU
0
0
0
2
3
1
2
1
0
0
3
0
1
3
R2↔R3
3
2
1
2
1
0
1
3
0
0
3
L
L
U
Text solution
Clear below the first pivotSubtract 2 times Row 1 from Row 2 (multiplier 2) and 3 times Row 1 from Row 3 (multiplier 3), which leaves a 0 in the (2,2) pivot spot.
Swap Row 2 and Row 3 to form P,L, and USwapping Row 2 and Row 3 puts 1 into the (2,2) pivot spot to finish U, swaps the already-recorded multipliers 2 and 3 in the first column of L, and leaves L32=0 since the (3,2) entry is already 0.
So x=112 solves Ax=b, with P applying the same row swap to A and b before we use L and U to solve the two triangular systems.
When two rows swap to replace a zero pivot, the matching rows of the identity matrix swap to form P, the entries of b swap into Pb, and the multipliers already recorded in L swap along with the rows they came from so that PA=LU.
Swapping two rows to fix a zero pivot moves their multipliers, their permutation rows, and their right-hand side numbers right along with them.
Key concepts
If you only ever need to solve Ax=b for a single vector b, ordinary elimination on A and b together does the same arithmetic without building L. We factor A into L and U when A stays fixed across many different right-hand sides b, or when we want a matrix record of the elimination steps.
Without row swaps, Gaussian elimination factors A=LU. As you reduce A to the upper triangular matrix U, start the lower triangular matrix L with 1s on the diagonal and put each multiplier
Lij=pivotentry being eliminated
straight into the (i,j) spot it zeros out. Because L=E21−1E31−1E32−1 rebuilds A from the finished rows of U, the multipliers never mix the way they do in the forward product E32E31E21. Watch the sign whenever you add a row: eliminating −4 with the pivot 2 via R2←R2+2R1 means you subtracted −2R1, so L21=2−4=−2.
If a 0 appears in a pivot spot (such as the (2,2) entry in 100201133), swap that row with a row below it that has a nonzero entry in that column. Record the same swap on the identity matrix to get P, and swap the multipliers already recorded in earlier columns of L (so L21=2 and L31=3 trade places to become L21=3 and L31=2), giving PA=LU. If the swap already leaves a 0 below the new pivot, no elimination step is needed there and L32=0.
Once A is factored, solve for any b in two triangular steps without doing row operations on A again: swap b into Pb if rows were swapped, solve Ly=b (or Ly=Pb) from top to bottom for y, and solve Ux=y from bottom to top for x.
5
Practice
1
Given the factorization A=LU with
LU=12−1013001and=100310−124,
solve Ax=b for b=41113 by first solving Ly=b and then solving Ux=y.
Start at the top row of Ly=b where y1 is the only unknown, then use your finished vector y as the right-hand side of Ux=y starting from the bottom row.
Because we added 3R1 and 2R2 during elimination, the multipliers subtracted are −3 and −2; writing +3 and +2 in L is the most common mistake and gives the wrong matrix 1321012001.
Divide each entry being eliminated by the pivot you are using, and pay close attention to the sign when you add a multiple of a pivot row to clear a negative entry.
Clear below the first pivot 2 using L21=2−6=−3 and L31=21:
Clear below the second pivot 3 using L32=3−6=−2:
R3←R3−(−2)R2200−23−6413200−230415
(Because we added 3R1 and 2R2 during elimination, the multipliers subtracted are −3 and −2; writing +3 and +2 in L is the most common mistake and gives the wrong matrix 1321012001.)
L=1−32101−2001,U=200−230415
3
Suppose three elimination steps reduce A to U via E32E31E21A=U, where
Find the single combined forward matrix E=E32E31E21 and the lower triangular matrix L in A=LU, and explain why the (3,1) entry of E is not simply −L31.
Multiply E31E21 first and then multiply on the left by E32; to find L, invert each elimination matrix and multiply them in the reverse order E21−1E31−1E32−1.
Multiply the forward elimination matrices in order from right to left:
(Don't just copy −3,−1, and −2 into E to get 1−3−101−2001: the bottom row of E32 multiplies the first column of E31E21 to give (0)(1)+(−2)(−3)+(1)(−1)=5.)
Now invert each elimination matrix and multiply in reverse order to get L:
(Be sure to reverse the order to E21−1E31−1E32−1; multiplying the inverses in the forward order E32−1E31−1E21−1 mixes the multipliers so the (3,1) entry becomes 1+(2)(3)=7.)
In E, subtracting 2 times the updated Row 2 from Row 3 also subtracts 2 times (−3 of Row 1), which adds 6 of Row 1 to the −1 of Row 1 from E31 to produce 5; in L=E21−1E31−1E32−1, the inverse order rebuilds A directly from the finished rows of U so the multipliers 3,1, and 2 do not mix:
E=1−3501−2001,L=131012001
4
Factor A=12−136−1272 into PA=LU, and use the factorization to solve Ax=b for b=7231.
Don't leave the first-column multipliers unswapped as L21=2 and L31=−1, which would lead to y=7−1330 and x=2133−25310.Remember to swap b into Pb first; solving Ly=b with the unswapped b=7231 gives y=730−13 and x=−3166371−313.
After clearing the first column, look at the (2,2) pivot spot. When you swap rows, remember what must happen to the multipliers already recorded in the first column of L and to the entries of b.
Clear below the first pivot 1 using multipliers 2 in Row 2 and −1 in Row 3:
Since a 0 is in the (2,2) pivot spot, swap Row 2 and Row 3 to get U, swap Row 2 and Row 3 of I to get P, and swap the saved multipliers 2 and −1 in the first column of L:
Elimination with no row swaps reduces a 3×3 matrix A to
U=200130−124.
If the bottom row of A is [6159], find the bottom row [L31L321] of L without knowing the first two rows of A.
Use A=LU: how does the bottom row of L combine the three rows of U to rebuild the bottom row of A?
In A=LU, the bottom row [L31L321] of L rebuilds the bottom row of A as a combination of the rows of U:
L31[21−1]+L32[032]+1[004]=[6159]
Match the first entries to find L31, then match the second entries to find L32:
2L31L31+3L32=6⟹L31=3=15⟹3+3L32=15⟹L32=4
(Don't divide the original entry 15 directly by the second pivot 3 to get L32=315=5 and [351]: subtracting 3 times Row 1 of U first changes the (3,2) entry from 15 to 15−3(1)=12 before you divide by the second pivot 3.)