Skip to content

LU Decomposition

LU decomposition is a reformulation of Gaussian elimination that makes the factorization reusable. Instead of discarding the row operations after solving one system, we encode them into two triangular matrices LL (lower) and UU (upper) such that A=LUA = LU. Solving Ax=bAx = b then splits into two triangular systems — Ly=bLy = b (forward substitution) followed by Ux=yUx = y (back substitution) — each of which costs only n2n^2 operations.


Frobenius Matrices

Each round of Gaussian elimination can be represented as multiplication by a Frobenius matrix (also called an elementary lower triangular matrix). A Frobenius matrix is a unit lower triangular matrix that differs from the identity only in one column below the diagonal.

For the kk-th elimination step, the Frobenius matrix F(k)F^{(k)} places the negated multipliers −mik-m_{ik} (for i>ki > k) in column kk:

F(k)=[1⋱1−mk+1,k1⋮⋱−mn,k1]F^{(k)} = \begin{bmatrix}1&&&&&\\&\ddots&&&&\\&&1&&&\\&&-m_{k+1,k}&1&&\\&&\vdots&&\ddots&\\&&-m_{n,k}&&&1\end{bmatrix}

Proof: Ak+1=F(k)AkA_{k+1} = F^{(k)} A_k

Let AkA_k be the matrix at the start of step kk, with entries aij(k)a^{(k)}_{ij} and rows R1,…,RnR_1, \dots, R_n, and let mik=aik(k)/akk(k)m_{ik} = a^{(k)}_{ik} / a^{(k)}_{kk}. We show that left-multiplying by F(k)F^{(k)} performs exactly the row operations Ri←Ri−mikRkR_i \leftarrow R_i - m_{ik} R_k for every i>ki > k.

The ii-th row of a product FAFA is the ii-th row of FF times AA, which is a combination of the rows of AA weighted by the entries of that row of FF:

rowi(FA)=fi,1R1+fi,2R2+⋯+fi,nRn\text{row}_i(FA) = f_{i,1}R_1 + f_{i,2}R_2 + \cdots + f_{i,n}R_n

Now read the rows of F(k)F^{(k)}:

  • For i≤ki \le k, row ii of F(k)F^{(k)} is just row ii of the identity, so row ii of F(k)AkF^{(k)}A_k is RiR_i. The first kk rows are unchanged.
  • For i>ki > k, row ii of F(k)F^{(k)} has −mik-m_{ik} in column kk and 11 in column ii, so row ii of F(k)AkF^{(k)}A_k is Ri−mikRkR_i - m_{ik}R_k.

This is the kk-th round of Gaussian elimination. The column-kk entry of each row i>ki > k becomes

aik(k)−mik akk(k)=aik(k)−aik(k)akk(k) akk(k)=0a^{(k)}_{ik} - m_{ik}\,a^{(k)}_{kk} = a^{(k)}_{ik} - \frac{a^{(k)}_{ik}}{a^{(k)}_{kk}}\,a^{(k)}_{kk} = 0

and the zeros already in columns 1,…,k−11, \dots, k-1 stay zero, because RkR_k is also zero in those columns. So F(k)Ak=Ak+1F^{(k)}A_k = A_{k+1}. ■\blacksquare

Example: A2=F(1)A1A_2 = F^{(1)}A_1 for a 3×33 \times 3 matrix. With pivot a11a_{11}, the multipliers are m21=a21/a11m_{21} = a_{21}/a_{11} and m31=a31/a11m_{31} = a_{31}/a_{11}:

F(1)A1=[100−m2110−m3101][a11a12a13a21a22a23a31a32a33]F^{(1)}A_1 = \begin{bmatrix}1&0&0\\-m_{21}&1&0\\-m_{31}&0&1\end{bmatrix}\begin{bmatrix}a_{11}&a_{12}&a_{13}\\a_{21}&a_{22}&a_{23}\\a_{31}&a_{32}&a_{33}\end{bmatrix}

Taking one row of F(1)F^{(1)} at a time:

[100]A1=R1[−m2110]A1=R2−m21R1[−m3101]A1=R3−m31R1\begin{bmatrix}1&0&0\end{bmatrix}A_1 = R_1 \qquad \begin{bmatrix}-m_{21}&1&0\end{bmatrix}A_1 = R_2 - m_{21}R_1 \qquad \begin{bmatrix}-m_{31}&0&1\end{bmatrix}A_1 = R_3 - m_{31}R_1

Written out entry by entry:

F(1)A1=[a11a12a13a21−m21a11a22−m21a12a23−m21a13a31−m31a11a32−m31a12a33−m31a13]F^{(1)}A_1 = \begin{bmatrix}a_{11}&a_{12}&a_{13}\\a_{21}-m_{21}a_{11}&a_{22}-m_{21}a_{12}&a_{23}-m_{21}a_{13}\\a_{31}-m_{31}a_{11}&a_{32}-m_{31}a_{12}&a_{33}-m_{31}a_{13}\end{bmatrix}

The multipliers were chosen so that the first-column entries below the diagonal cancel:

a21−m21a11=a21−a21a11 a11=0a31−m31a11=a31−a31a11 a11=0a_{21}-m_{21}a_{11} = a_{21}-\frac{a_{21}}{a_{11}}\,a_{11} = 0 \qquad a_{31}-m_{31}a_{11} = a_{31}-\frac{a_{31}}{a_{11}}\,a_{11} = 0

A2=F(1)A1=[a11a12a130a22(2)a23(2)0a32(2)a33(2)],aij(2)=aij−mi1 a1jA_2 = F^{(1)}A_1 = \begin{bmatrix}a_{11}&a_{12}&a_{13}\\0&a^{(2)}_{22}&a^{(2)}_{23}\\0&a^{(2)}_{32}&a^{(2)}_{33}\end{bmatrix}, \qquad a^{(2)}_{ij} = a_{ij} - m_{i1}\,a_{1j}

Step 2 of the worked example below is this same computation with numbers.

From AA to UU

Applying all n−1n-1 Frobenius matrices in turn (A1=A→A2→⋯→An=UA_1 = A \to A_2 \to \cdots \to A_n = U) transforms AA into UU:

F(n−1)⋯F(2)F(1)A=UF^{(n-1)}\cdots F^{(2)}F^{(1)}A = U

The lower triangular factor LL is then recovered by inverting the Frobenius matrices in order:

L=(F(1))−1(F(2))−1⋯(F(n−1))−1L = \left(F^{(1)}\right)^{-1}\left(F^{(2)}\right)^{-1}\cdots\left(F^{(n-1)}\right)^{-1}


Worked Example

Problem: Decompose the matrix AA below into LL and UU, then use LU decomposition to solve Ax=bAx = b.

A=[1211−22212−2],b=[044]A=\begin{bmatrix}1&2&1\\1&-2&2\\2&12&-2\end{bmatrix},\quad b=\begin{bmatrix}0\\4\\4\end{bmatrix}

Step 1 — First Frobenius matrix F(1)F^{(1)}

Label the original matrix A1=AA_1 = A. Compute the multipliers for the first elimination column using the pivot a11=1a_{11} = 1:

m21=a21a11=11=1m31=a31a11=21=2m_{21} = \frac{a_{21}}{a_{11}} = \frac{1}{1} = 1 \qquad m_{31} = \frac{a_{31}}{a_{11}} = \frac{2}{1} = 2

Build F(1)F^{(1)} by placing −m21-m_{21} and −m31-m_{31} in column 1 below the diagonal:

F(1)=[100−110−201]F^{(1)}=\begin{bmatrix}1&0&0\\-1&1&0\\-2&0&1\end{bmatrix}

Step 2 — Compute A2=F(1)A1A_2 = F^{(1)} A_1

A2=F(1)A1=[100−110−201][1211−22212−2]=[1210−4108−4]A_{2}=F^{(1)}A_{1}=\begin{bmatrix}1&0&0\\-1&1&0\\-2&0&1\end{bmatrix}\begin{bmatrix}1&2&1\\1&-2&2\\2&12&-2\end{bmatrix}=\begin{bmatrix}1&2&1\\0&-4&1\\0&8&-4\end{bmatrix}

The first column below the diagonal is now zero, exactly as in the Gaussian elimination step.

Step 3 — Second Frobenius matrix F(2)F^{(2)}

Use A2A_2 to compute the multiplier for the second elimination column. The new pivot is a22=−4a_{22} = -4:

m32=a32a22=8−4=−2m_{32} = \frac{a_{32}}{a_{22}} = \frac{8}{-4} = -2

Build F(2)F^{(2)} by placing −m32=2-m_{32} = 2 in position (3,2)(3,2):

F(2)=[100010021]F^{(2)}=\begin{bmatrix}1&0&0\\0&1&0\\0&2&1\end{bmatrix}

Step 4 — Compute U=F(2)A2U = F^{(2)} A_2

U=F(2)A2=[100010021][1210−4108−4]=[1210−4100−2]U=F^{(2)}A_{2}=\begin{bmatrix}1&0&0\\0&1&0\\0&2&1\end{bmatrix}\begin{bmatrix}1&2&1\\0&-4&1\\0&8&-4\end{bmatrix}=\begin{bmatrix}1&2&1\\0&-4&1\\0&0&-2\end{bmatrix}

This is the upper triangular factor UU.

Step 5 — Assemble LL

Rather than explicitly inverting the Frobenius matrices, we reuse the multipliers from each step and place them directly at their natural positions:

L=[100m2110m31m321]=[1001102−21]L=\begin{bmatrix}1&0&0\\m_{21}&1&0\\m_{31}&m_{32}&1\end{bmatrix}=\begin{bmatrix}1&0&0\\1&1&0\\2&-2&1\end{bmatrix}

Verification: L⋅UL \cdot U should equal AA:

[1001102−21][1210−4100−2]=[1211−22212−2]=A✓\begin{bmatrix}1&0&0\\1&1&0\\2&-2&1\end{bmatrix}\begin{bmatrix}1&2&1\\0&-4&1\\0&0&-2\end{bmatrix}=\begin{bmatrix}1&2&1\\1&-2&2\\2&12&-2\end{bmatrix} = A \checkmark


Solving Ax=bAx = b via LULU

With the factorization A=LUA = LU, the system Ax=bAx = b becomes LUx=bLUx = b. Define y=Uxy = Ux, so that Ly=bLy = b and then Ux=yUx = y.

Step 6 — Forward substitution: solve Ly=bLy = b

[1001102−21][y1y2y3]=[044]\begin{bmatrix}1&0&0\\1&1&0\\2&-2&1\end{bmatrix}\begin{bmatrix}y_{1}\\y_{2}\\y_{3}\end{bmatrix}=\begin{bmatrix}0\\4\\4\end{bmatrix}

Row 1: y1=0y_1 = 0

Row 2: y1+y2=4  ⟹  0+y2=4  ⟹  y2=4y_1 + y_2 = 4 \implies 0 + y_2 = 4 \implies y_2 = 4

Row 3: 2y1−2y2+y3=4  ⟹  0−8+y3=4  ⟹  y3=122y_1 - 2y_2 + y_3 = 4 \implies 0 - 8 + y_3 = 4 \implies y_3 = 12

y=[0412]y = \begin{bmatrix}0\\4\\12\end{bmatrix}

Step 7 — Back substitution: solve Ux=yUx = y

[1210−4100−2][x1x2x3]=[0412]\begin{bmatrix}1&2&1\\0&-4&1\\0&0&-2\end{bmatrix}\begin{bmatrix}x_{1}\\x_{2}\\x_{3}\end{bmatrix}=\begin{bmatrix}0\\4\\12\end{bmatrix}

Row 3: −2x3=12  ⟹  x3=−6-2x_3 = 12 \implies x_3 = -6

Row 2: −4x2+x3=4  ⟹  −4x2+(−6)=4  ⟹  −4x2=10  ⟹  x2=−2.5-4x_2 + x_3 = 4 \implies -4x_2 + (-6) = 4 \implies -4x_2 = 10 \implies x_2 = -2.5

Row 1: x1+2x2+x3=0  ⟹  x1+2(−2.5)+(−6)=0  ⟹  x1=11x_1 + 2x_2 + x_3 = 0 \implies x_1 + 2(-2.5) + (-6) = 0 \implies x_1 = 11

Step 8 — Solution

x1=11,x2=−2.5,x3=−6\boxed{x_1 = 11,\quad x_2 = -2.5,\quad x_3 = -6}