4.5.26 · D2Linear Algebra (Full)

Visual walkthrough — LU decomposition — algorithm, applications

1,956 words9 min readBack to topic

Step 0 — What is a matrix and what does "triangular" mean?

Look at the shaded triangles below: the zeros are what make these matrices cheap to solve — a fact we cash in later.

Figure — LU decomposition — algorithm, applications

Our goal, stated visually: take a full square grid and split it into a lower-left triangle times an upper-right triangle .

  • — the original grid we are handed.
  • — the record of our moves (defined below).
  • — the leftover staircase after we clean up (defined below).

Step 1 — One elimination move, drawn as an arrow

WHAT we just did: subtracted a scaled copy of the pivot row from the row below it.

WHY this exact number ? Because we want the entry to become zero. Subtracting from gives . The ratio is designed to cancel. That is the whole reason we divide by the pivot — no other number kills that entry in one clean step.

  • — the troublemaker we want gone (row , column ).
  • — the pivot we are eliminating from.
  • — "how many pivot-rows fit into the troublemaker."

PICTURE: think of each row as a vector. The move slides row along the direction of row until its -th slot hits zero.

Figure — LU decomposition — algorithm, applications

Step 2 — A move is a matrix (the elementary matrix)

The move "" is achieved by multiplying on the left by an elementary matrix : the identity matrix, but with placed in position .

  • The 's down the diagonal mean "keep every row as it is..."
  • ...except the single , which says "...but from row also subtract of row ."

WHY the minus sign? Because we subtract. Remember this sign — it flips in the next step, and that flip is the punchline.

PICTURE: the identity is a "do nothing" stamp; the lone off-diagonal number is the one instruction we injected.

Figure — LU decomposition — algorithm, applications

Step 3 — Stack the moves:

WHAT: we chained the moves. Read right-to-left: acts first, then , and so on.

WHY the order matters: we clear column 1 top-to-bottom first, then column 2, etc. Each later move works on already-cleaned columns, so it never re-dirties an earlier one. This "no interference" is what keeps simple in Step 5.

  • — start.
  • — the moves in the order performed.
  • — the finished upper-triangular staircase; its diagonal entries are the pivots.

PICTURE: watch the lower-left triangle of fill up with zeros, column by column, until only the upper staircase survives.

Figure — LU decomposition — algorithm, applications

Step 4 — Undo the moves to isolate

Solving for :

  • — the move that reverses .
  • The inverses come in reverse order (last move undone first) — same as taking off shoes then socks in reverse.
  • — we name this whole product . That is the definition; we still must check it is nice.

Here is the beautiful fact: the inverse of an elementary matrix is the same matrix with the sign flipped. If had , then has .

WHY does the sign just flip? Because "subtract of row " is undone by "add of row " — the reverse move. No new numbers appear.

Figure — LU decomposition — algorithm, applications

Step 5 — The multipliers drop straight into

WHAT: we multiplied all the inverse moves together and — magically — got a matrix whose off-diagonal entries are literally the multipliers, with signs.

WHY no messy cross-terms? Because of the ordering in Step 3. Each has its single number in a different slot, and (since we go top-down, left-to-right) multiplying them never makes two of these numbers collide. So the product just deposits each in its own home. This is exactly the parent note's "steel-man check."

  • The 's on the diagonal: every reverse-move keeps its own row, so the diagonal stays all ones. This is why is called unit lower triangular.
  • — the multipliers, sitting exactly where we eliminated.

PICTURE: each multiplier we computed during elimination falls, like a coin into a slot, into position of .

Figure — LU decomposition — algorithm, applications
Recall Why exactly are the diagonals of

all ? Because each reverse elimination matrix is the identity plus one off-diagonal number — it never touches the diagonal — so multiplying them keeps every diagonal entry at . The 1's on 's diagonal come from where? ::: The identity part of every inverse elementary matrix (moves never rescale a row).


Step 6 — Watch a full get factored

Take the parent's example .

WHAT/WHY, step by step:

  1. Pivot . To kill the below it: . (We divide by the pivot because that ratio cancels the .)
  2. Apply : . Column 1 below the pivot is now zero.
  3. Read off: The in is exactly the multiplier from step 1.
  • 's diagonal = the two pivots.
  • 's single off-diagonal = the single multiplier.

PICTURE: the entry that was turns to in the grid, and simultaneously a "" is written into 's slot — one leaves the working matrix, its record enters .

Figure — LU decomposition — algorithm, applications

Step 7 — The degenerate case: a zero pivot

Example: has pivot . Plain is impossible as written.

WHY it feels wrong: nothing about is broken — it is a perfectly good invertible matrix. The problem is purely that this order of elimination hit a zero.

THE FIX — permutation. Swap the two rows first. Swapping is itself a matrix, a permutation matrix : which is already upper triangular — now factorable. In general we get

  • — records which rows we swapped (pure bookkeeping, costs no arithmetic).
  • Choosing the swap that brings the largest entry to the pivot is called partial pivoting — it keeps multipliers in size and controls error.

PICTURE: two rows trade places; the that blocked us is escorted out of the pivot seat.

Figure — LU decomposition — algorithm, applications
Recall Why does one row swap flip the sign of the determinant?

Each swap multiplies by . So — see Determinants.


The one-picture summary

Everything above compresses into a single flow: eliminate → zeros go into , multipliers go into , swaps go into .

Figure — LU decomposition — algorithm, applications
Recall Feynman retelling — the whole walkthrough in plain words

You start with a messy grid of numbers. You clean it up one column at a time by subtracting scaled copies of the pivot row from the rows beneath — each "how much did I subtract?" number is a multiplier. As the lower-left of the grid empties out into zeros, an upper staircase is left standing (its diagonal is the pivots). Meanwhile, every multiplier you used gets written down into its matching slot in a second matrix , whose diagonal is all 's because you never rescaled a whole row. Multiply times and you get your original grid back — you've split it into "the record of my moves" times "the tidy leftover." If a pivot ever lands on zero, you can't divide, so you swap that row with a better one and remember the swap in a permutation matrix , giving . That's it: elimination that never forgets its homework.


Connections

  • Gaussian Elimination — this whole page is elimination, slowed to one picture per move.
  • Permutation Matrices — the in (Step 7).
  • Determinants — product of the pivots on 's diagonal.
  • Matrix Inverse — reuse the same against each identity column.
  • Triangular Systems & Substitution — why the and shapes are cheap to solve.
  • Cholesky Decomposition — the symmetric special case .