Elimination throws its multipliers away. Keep them, and the matrix splits into two triangles. Watch each one drop into place.
Elimination, written down
Each multiplier of elimination drops into its cell of L.
A, and an empty L with ones on its diagonal, ready to keep the multipliers.
Describe this picture
Two grids of cells side by side: the matrix , and a lower triangle labelled with ones on its diagonal, zeros above it and empty places below. As elimination clears each entry below a pivot, the row changes, and its multiplier appears as a highlighted cell beside the row, then slides into the matching place of : 3 into row 2, column 1; 0 into row 3, column 1; 2 into row 3, column 2. When the first grid has become upper triangular it is relabelled . A third grid then fills cell by cell, row by row, with the product , and when it is full its label reads : the same numbers as the matrix at the start. The picture has no control.
Keep the multipliers
On the page Elimination we turned
with the multipliers , and . Now put those multipliers in a lower triangle, below a diagonal of ones:
Then . This is the LU factorisation: is lower triangular, is upper triangular, and their product is .
Why does it work? Elimination made each row of by taking multiples of earlier rows away from a row of . Run that backwards, and each row of is its row of plus those same multiples put back. Row 2 of is 3 times row 1 of plus row 2 of :
Row 3 of is 0 times row 1 plus 2 times row 2 plus row 3 of : . Each row of lists how much of each row of to add, and that is what the product does.
So LU is not a new method. It is elimination, written down.
Watch the signs. On the elimination page, the step matrix held , because the step takes 3 of row 1 away. In the 3 appears with a plus sign, because rebuilding puts it back. In matrices, undoes the steps in reverse order, as the page The inverse matrix said an undo must:
Solving with two triangles
Now solve , which is . Give the inside a name, , and split the job in two:
Both are triangles, so both are quick. Take , the right-hand side from the elimination page. is solved from the top down, a forward substitution:
These are the right-hand sides that elimination produced, 2, 6 and . Then is solved from the bottom up, by back substitution: gives ; gives , so ; and gives , so .
Many right-hand sides
The work is in the factoring. Once and are known, a new needs only the two sweeps.
One factoring, many solves
Lc = b from the top, then Ux = c from the bottom.
The factors L and U, kept from one elimination.
Describe this picture
Two lines of cells, one above the other. The top reads , then a column , an equals sign and a column ; the bottom reads , a column , an equals sign and a copy of . The factors stay on screen while two right-hand sides pass through them one after the other. Each first fills from the top, the row of in use lit up, then is copied down and fills from the bottom, row by row of . The first, , gives and ; the second, , gives and . The picture has no control.
Try the second one yourself before the picture finishes: . Forward: , , . Back: , so ; , so ; , so . Check: .
How much cheaper is it? Factoring an matrix takes about multiply-and-subtract steps, as the elimination page counted. Each sweep through a triangle takes about , so a solve takes about . For , the factoring takes about steps and each later solve about : about 330 times less.
Row exchanges
Elimination sometimes needs a row exchange, when a pivot is 0. Take
The first pivot is 0. Swap the rows first, with the permutation matrix , which is the identity with its rows swapped. Then is already upper triangular, so and . In general, with the exchanges done first,
Library programs exchange rows more often than this page does. They move the largest available number into each pivot place, because that keeps rounding errors small. SciPy, for example, makes two exchanges on the matrix above, even though none of its pivots is 0. Its and then differ from ours, but they solve the same system.
Worked example
- Read from the multipliers. Multipliers , , give , , in , below a diagonal of ones.
- Rebuild . Row 2: . Row 3: .
- First solve. gives and .
- Second solve. gives and , with no new elimination.
- Signs. In the entry in row 2, column 1 is ; in it is .
- A zero pivot. needs ; then and .
Where you’ll meet this
A circuit simulator stepping through time often solves with the same matrix at every step, with a new right-hand side each time. It factors once and then only sweeps. Programs that compute how a structure bends under many different loads do the same: one factoring, one quick solve per load. In SciPy, a free Python library, the pair of functions lu_factor and lu_solve splits the work exactly this way.
In signal processing · sparse matrix factorisation
The FFT is a factorisation too. The page The FFT writes the full matrix of the discrete Fourier transform as a product of a few matrices that are mostly zeros, after a reordering of the samples. Like and , the factors are much quicker to apply than the matrix they replace.
Reference card
| Quantity | Formula | Notes |
|---|---|---|
| Factorisation | elimination, written down | |
| multipliers below a diagonal of ones | with a plus sign | |
| the result of elimination | pivots on its diagonal | |
| Steps | undo in reverse order | |
| Solve | , then | forward, then back substitution |
| Row exchanges | reorders the rows | |
| Cost | factor , each solve | factor once, solve many times |