4.8.19 · D2Numerical Methods

Visual walkthrough — LU decomposition (numerical)

1,910 words9 min readBack to topic

Before we start, three words we will use constantly, defined in plain language and anchored to the pictures:

The diagonal itself is the set of positions — where row number equals column number.


Step 1 — What "solving by elimination" actually does to a grid

WHAT. We start with a system. Elimination means: use the top-left number to wipe out the numbers directly below it, turning the left column into .

WHY. A grid whose bottom-left is all zeros (upper triangular) can be solved by back substitution — read the bottom equation, which has only one unknown, then climb up. So the entire goal of elimination is to manufacture that zero-filled corner.

PICTURE. Look at the grid below. The amber cell is the pivot — the number we divide by. The two cyan cells beneath it, and , are the ones we want to turn into .

Figure — LU decomposition (numerical)

To kill we subtract a copy of row 1 from row 2. How many copies? Exactly enough so the slot lands on zero. That number of copies is:

is called a multiplier: the amount of row 1 we mixed into row 2.


Step 2 — The multiplier is worth keeping

WHAT. In ordinary elimination we compute , do the subtraction, and then throw away. LU decomposition's one insight: don't throw it away — write it into the empty slot it just cleared.

WHY. The slot is now and will stay — it is spare storage. If we park there, the grid remembers how it was eliminated. Later that memory reconstructs the original .

PICTURE. The amber arrow shows flowing from the "work we did" into the freshly-zeroed cell. That zeroed cell (now holding ) becomes an entry of ; the surviving top part becomes an entry of .

Figure — LU decomposition (numerical)

Every symbol here is doing a job: says how much, row says of what, the minus sign says remove it.


Step 3 — One elimination step = multiply by an elementary matrix

WHAT. The single operation "row rowrow" is itself a matrix. Call it . It looks like the identity with tucked into position .

WHY. If a step is a matrix, then a whole elimination is a product of such matrices. Products are easy to invert and re-order — that is what lets us collect all the multipliers into one clean .

PICTURE. The identity matrix (a "do nothing" grid, 1's on the diagonal) with one amber intruder is the machine that performs Step 2.

Figure — LU decomposition (numerical)

Term-by-term: the 's copy every other row unchanged; the in row 2 injects " row 1" into row 2 — precisely Step 2.


Step 4 — Stack all steps:

WHAT. Do every elimination in order — clear column 1, then column 2. Each is an elementary matrix. Multiply them all onto from the left. The result is upper triangular; call it .

WHY. Once the grid is upper triangular, elimination is done. We have factored out all the "downward mixing" into the product of 's sitting on the left of .

PICTURE. Read left to right: enters, each shaves off one more sub-diagonal cell, and (clean upper-triangular staircase) emerges. See Gaussian Elimination for the same story without the matrix bookkeeping.

Figure — LU decomposition (numerical)

The order matters: acts first (it is closest to ), then , then — right-to-left, like functions.


Step 5 — Undo the steps to reveal

WHAT. Move all the 's to the other side. The inverse of the whole product is :

WHY. Inverting each just flips its one off-diagonal sign (), and — here is the small miracle — multiplying the inverses together simply drops each into its own slot with no cross-contamination. So is literally the table of multipliers, with 's on the diagonal.

PICTURE. The amber entries flip to and assemble into the lower-triangular . No arithmetic between them — each multiplier lands untouched.

Figure — LU decomposition (numerical)

Reading it: diagonal 's mean "each row keeps itself in full"; below records how much of row 1 went into row 2; how much of (cleaned) row 2 went into row 3. This is exactly the Doolittle form. (Swap the 1's onto instead and you get Crout Decomposition.)


Step 6 — The degenerate case: a zero pivot

WHAT. Suppose the amber pivot . Then — undefined. Elimination stalls even when is perfectly invertible.

WHY. Dividing by the pivot is baked into every multiplier. A zero pivot is a divide-by-zero, and a tiny pivot is nearly as bad — it magnifies rounding error (this is the link to Condition Number and Numerical Stability).

PICTURE. The left grid shows the stall: a red in the pivot seat. The right grid shows the cure — swap two rows so a big number sits on the pivot. That swap is a permutation matrix , giving . This is Partial Pivoting.

Figure — LU decomposition (numerical)

Term-by-term: reorders the rows of (and the same reorder must hit ); after the swap the pivot is nonzero and Steps 1–5 run normally.


Step 7 — Two triangular solves finish the job

WHAT. With in hand, becomes . Name the middle vector . Solve downward, then upward.

WHY. A triangular system has a "one new unknown per line" structure: the first row of involves only , the second only , and so on — no algebra, just substitution. See Forward and Back Substitution.

PICTURE. Green flows down the staircase of (forward), then flows up the staircase of (back). The two directions are the two triangles' shapes made physical.

Figure — LU decomposition (numerical)

And the free bonus (from Step 5's diagonal): since , the determinant is — just multiply the diagonal of .


The one-picture summary

Figure — LU decomposition (numerical)

The whole journey in one frame: enters on the left; elimination (the 's) shaves it into upper-triangular while quietly filing every multiplier into lower-triangular ; the reunion reproduces exactly; and any right-hand side then rides two cheap staircases (down, then up) to the answer .

Recall Feynman retelling — say it to a friend

You want to un-mix a system of equations. So you clean it up column by column: for each number under a pivot, figure out how many copies of the pivot's row you must subtract to zero it out, and subtract them. That "how many copies" number is a multiplier. Normally you'd forget it — but the cell you just zeroed is now empty, so you store the multiplier there instead. When you're done, the top-right of your grid is the cleaned-up upper matrix , and the bottom-left holds all your stored multipliers, which (with 1's down the diagonal) form . Multiply by and, magically, you get your original back — because literally remembers every move you made. If a pivot ever turns out to be zero, you can't divide by it, so you just swap that row with a lower one that has a big number there, remember the swap in , and continue. After all this, solving for any new right-hand side is trivial: slide down (forward substitution), then climb up (back substitution). Factor once, solve forever.


Connections