Skip to content

LU decomposition, explained

5 min read

Short answer

LU decomposition writes A=LUA=LU with LL lower triangular (ones on the diagonal) and UU upper triangular, recording the steps of Gaussian elimination. To solve Ax=bA\mathbf x=\mathbf b: solve Ly=bL\mathbf y=\mathbf b (forward substitution), then Ux=yU\mathbf x=\mathbf y (back substitution).

Steps1Eliminate below the pivots to reachU; store the multipliers in L2Solve L y = b by forward substitution3Solve U x = y by back substitution4Reuse L and U for every new right-hand side bFactoring costs about n³/3 operations; each solve only n².
The expensive step is done once; extra right-hand sides are cheap.

What L and U are

Gaussian elimination turns AA into the upper triangular UU. The multiplier used to clear each entry, ℓij\ell_{ij}, goes below the diagonal of LL. Together A=LUA=LU holds exactly.

Pivoting

If a pivot is zero or tiny, swap rows first. This gives PA=LUPA=LU with a permutation matrix PP, the form used by practical solvers.

Worked example

Factor A=(2145)A=\begin{pmatrix}2&1\\4&5\end{pmatrix} and solve Ax=(39)A\mathbf x=\begin{pmatrix}3\\9\end{pmatrix}.

Multiplier 4/2=24/2=2: L=(1021)L=\begin{pmatrix}1&0\\2&1\end{pmatrix}, U=(2103)U=\begin{pmatrix}2&1\\0&3\end{pmatrix}. Forward: y1=3y_1=3, y2=9−6=3y_2=9-6=3. Back: x2=3/3=1x_2=3/3=1, x1=(3−1)/2=1x_1=(3-1)/2=1. Check: 2+1=32+1=3, 4+5=94+5=9. ✓

Try it yourself

How many operations does each extra right-hand side cost, compared with the factorization?

Show the answer

About n2n^2 for the two triangular solves, versus about n33\tfrac{n^3}{3} for the factorization, so many right-hand sides are cheap after one LU.

Keep going with practice

Vidi's linear algebra lessons teach the elimination that LU records.