Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

Recipe

Factor a matrix into L and U

Use when: you have a square matrix A and need L (lower triangular, 1s on the diagonal) and U (upper triangular) with A=LU

Goal: a complete L and U that multiply back out to A exactly, with every multiplier ordinary elimination used recorded in L

Taught in LU factorization · a later section extends this recipe with more cases

  1. 1

    Run through the pivot columns of A in your head and check that each one already has a nonzero entry sitting in the pivot row once earlier columns are cleared — no swap required to keep going.

    Why: the plain factorization A=LU (no permutation) only exists when ordinary elimination never has to swap rows; running the rest of this recipe on a matrix that does need one produces an L and U that don't multiply back to A.

  2. 2

    Start with U=A and L=I_n. For the pivot in column k, and each row i below it, compute m_{ik}=U_{ik}/U_{kk}, apply R_i\to R_i-m_{ik}R_k to U, and write m_{ik} into row i, column k of L — every other entry of L stays at its starting value (1 on the diagonal, 0 elsewhere) until its own turn comes.

    Example

    Start with U=N and L=I_3 for N=\begin{bmatrix}4&3&2\\8&9&7\\4&3&5\end{bmatrix}. Clear column 1 below the pivot U_{11}=4: m_{21}=\frac{8}{4}=2,\ R_2\to R_2-2R_1 \qquad m_{31}=\frac{4}{4}=1,\ R_3\to R_3-1R_1 U=\begin{bmatrix}4&3&2\\0&3&3\\0&0&3\end{bmatrix},\qquad L=\begin{bmatrix}1&0&0\\2&1&0\\1&0&1\end{bmatrix}

    Why: this is exactly the multiplier ordinary elimination already uses to zero out U_{ik} — recording it instead of throwing it away is the only new bookkeeping LU factorization adds to elimination you'd be doing anyway.

  3. 3

    Move to the next pivot column and repeat. If the entry below a pivot is already 0, its multiplier is 0 and L's entry there stays 0 — that's a completed part of the process, not a step you skip.

    Example

    Continuing with the U and L above, column 2's pivot is U_{22}=3, and the entry below it, U_{32}, is already 0: m_{32}=\frac{0}{3}=0,\qquad R_3\to R_3-0R_2\ \text{(no change)} U was already upper triangular after column 1, so elimination is finished — L's (3,2) entry stays the 0 it started at: U=\begin{bmatrix}4&3&2\\0&3&3\\0&0&3\end{bmatrix},\qquad L=\begin{bmatrix}1&0&0\\2&1&0\\1&0&1\end{bmatrix}

    Why: elimination isn't finished — and neither is L — until every column left of the diagonal has had its multipliers computed, even when some of them turn out to be zero.

  4. 4

    Compute LU entry by entry and confirm it reproduces A exactly.

    Example

    LU=\begin{bmatrix}1&0&0\\2&1&0\\1&0&1\end{bmatrix}\begin{bmatrix}4&3&2\\0&3&3\\0&0&3\end{bmatrix}=\begin{bmatrix}4&3&2\\8&9&7\\4&3&5\end{bmatrix}=N

    Why: this is the direct check that L and U actually multiply back to the original matrix, catching an arithmetic slip in any multiplier before it propagates into a later solve.

Common mistakes

  • Recording a multiplier with the wrong sign — L stores m_{ik} itself, the number you multiplied row k by before subtracting, not its negative.
  • Skipping a multiplier that happens to be 0, leaving L incomplete even though no visible elimination step occurred there.
  • Writing a multiplier into the wrong slot of L — m_{ik} (row i used pivot row k) belongs at row i, column k, never the transposed position.
  • Forcing plain LU on a matrix that actually needs a row swap partway through elimination, instead of recognizing it needs PA=LU.