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 L L L (lower) and U U U (upper) such that A = L U A = LU A = LU . Solving A x = b Ax = b A x = b then splits into two triangular systems — L y = b Ly = b L y = b (forward substitution) followed by U x = y Ux = y U x = y (back substitution) — each of which costs only n 2 n^2 n 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 k k k -th elimination step, the Frobenius matrix F ( k ) F^{(k)} F ( k ) places the negated multipliers − m i k -m_{ik} − m ik (for i > k i > k i > k ) in column k k k :
F ( k ) = [ 1 ⋱ 1 − m k + 1 , k 1 ⋮ ⋱ − m n , k 1 ] F^{(k)} = \begin{bmatrix}1&&&&&\\&\ddots&&&&\\&&1&&&\\&&-m_{k+1,k}&1&&\\&&\vdots&&\ddots&\\&&-m_{n,k}&&&1\end{bmatrix} F ( k ) = 1 ⋱ 1 − m k + 1 , k ⋮ − m n , k 1 ⋱ 1
Proof: A k + 1 = F ( k ) A k A_{k+1} = F^{(k)} A_k A k + 1 = F ( k ) A k
Let A k A_k A k be the matrix at the start of step k k k , with entries a i j ( k ) a^{(k)}_{ij} a ij ( k ) and rows R 1 , … , R n R_1, \dots, R_n R 1 , … , R n , and let m i k = a i k ( k ) / a k k ( k ) m_{ik} = a^{(k)}_{ik} / a^{(k)}_{kk} m ik = a ik ( k ) / a k k ( k ) . We show that left-multiplying by F ( k ) F^{(k)} F ( k ) performs exactly the row operations R i ← R i − m i k R k R_i \leftarrow R_i - m_{ik} R_k R i ← R i − m ik R k for every i > k i > k i > k .
The i i i -th row of a product F A FA F A is the i i i -th row of F F F times A A A , which is a combination of the rows of A A A weighted by the entries of that row of F F F :
row i ( F A ) = f i , 1 R 1 + f i , 2 R 2 + ⋯ + f i , n R n \text{row}_i(FA) = f_{i,1}R_1 + f_{i,2}R_2 + \cdots + f_{i,n}R_n row i ( F A ) = f i , 1 R 1 + f i , 2 R 2 + ⋯ + f i , n R n
Now read the rows of F ( k ) F^{(k)} F ( k ) :
For i ≤ k i \le k i ≤ k , row i i i of F ( k ) F^{(k)} F ( k ) is just row i i i of the identity, so row i i i of F ( k ) A k F^{(k)}A_k F ( k ) A k is R i R_i R i . The first k k k rows are unchanged.
For i > k i > k i > k , row i i i of F ( k ) F^{(k)} F ( k ) has − m i k -m_{ik} − m ik in column k k k and 1 1 1 in column i i i , so row i i i of F ( k ) A k F^{(k)}A_k F ( k ) A k is R i − m i k R k R_i - m_{ik}R_k R i − m ik R k .
This is the k k k -th round of Gaussian elimination. The column-k k k entry of each row i > k i > k i > k becomes
a i k ( k ) − m i k a k k ( k ) = a i k ( k ) − a i k ( k ) a k k ( k ) a k k ( k ) = 0 a^{(k)}_{ik} - m_{ik}\,a^{(k)}_{kk} = a^{(k)}_{ik} - \frac{a^{(k)}_{ik}}{a^{(k)}_{kk}}\,a^{(k)}_{kk} = 0 a ik ( k ) − m ik a k k ( k ) = a ik ( k ) − a k k ( k ) a ik ( k ) a k k ( k ) = 0
and the zeros already in columns 1 , … , k − 1 1, \dots, k-1 1 , … , k − 1 stay zero, because R k R_k R k is also zero in those columns. So F ( k ) A k = A k + 1 F^{(k)}A_k = A_{k+1} F ( k ) A k = A k + 1 . ■ \blacksquare ■
Example: A 2 = F ( 1 ) A 1 A_2 = F^{(1)}A_1 A 2 = F ( 1 ) A 1 for a 3 × 3 3 \times 3 3 × 3 matrix. With pivot a 11 a_{11} a 11 , the multipliers are m 21 = a 21 / a 11 m_{21} = a_{21}/a_{11} m 21 = a 21 / a 11 and m 31 = a 31 / a 11 m_{31} = a_{31}/a_{11} m 31 = a 31 / a 11 :
F ( 1 ) A 1 = [ 1 0 0 − m 21 1 0 − m 31 0 1 ] [ a 11 a 12 a 13 a 21 a 22 a 23 a 31 a 32 a 33 ] 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} F ( 1 ) A 1 = 1 − m 21 − m 31 0 1 0 0 0 1 a 11 a 21 a 31 a 12 a 22 a 32 a 13 a 23 a 33
Taking one row of F ( 1 ) F^{(1)} F ( 1 ) at a time:
[ 1 0 0 ] A 1 = R 1 [ − m 21 1 0 ] A 1 = R 2 − m 21 R 1 [ − m 31 0 1 ] A 1 = R 3 − m 31 R 1 \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 [ 1 0 0 ] A 1 = R 1 [ − m 21 1 0 ] A 1 = R 2 − m 21 R 1 [ − m 31 0 1 ] A 1 = R 3 − m 31 R 1
Written out entry by entry:
F ( 1 ) A 1 = [ 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 ] 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} F ( 1 ) A 1 = a 11 a 21 − m 21 a 11 a 31 − m 31 a 11 a 12 a 22 − m 21 a 12 a 32 − m 31 a 12 a 13 a 23 − m 21 a 13 a 33 − m 31 a 13
The multipliers were chosen so that the first-column entries below the diagonal cancel:
a 21 − m 21 a 11 = a 21 − a 21 a 11 a 11 = 0 a 31 − m 31 a 11 = a 31 − a 31 a 11 a 11 = 0 a_{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 a 21 − m 21 a 11 = a 21 − a 11 a 21 a 11 = 0 a 31 − m 31 a 11 = a 31 − a 11 a 31 a 11 = 0
A 2 = F ( 1 ) A 1 = [ a 11 a 12 a 13 0 a 22 ( 2 ) a 23 ( 2 ) 0 a 32 ( 2 ) a 33 ( 2 ) ] , a i j ( 2 ) = a i j − m i 1 a 1 j A_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} A 2 = F ( 1 ) A 1 = a 11 0 0 a 12 a 22 ( 2 ) a 32 ( 2 ) a 13 a 23 ( 2 ) a 33 ( 2 ) , a ij ( 2 ) = a ij − m i 1 a 1 j
Step 2 of the worked example below is this same computation with numbers.
From A A A to U U U
Applying all n − 1 n-1 n − 1 Frobenius matrices in turn (A 1 = A → A 2 → ⋯ → A n = U A_1 = A \to A_2 \to \cdots \to A_n = U A 1 = A → A 2 → ⋯ → A n = U ) transforms A A A into U U U :
F ( n − 1 ) ⋯ F ( 2 ) F ( 1 ) A = U F^{(n-1)}\cdots F^{(2)}F^{(1)}A = U F ( n − 1 ) ⋯ F ( 2 ) F ( 1 ) A = U
The lower triangular factor L L L is then recovered by inverting the Frobenius matrices in order:
L = ( F ( 1 ) ) − 1 ( F ( 2 ) ) − 1 ⋯ ( F ( n − 1 ) ) − 1 L = \left(F^{(1)}\right)^{-1}\left(F^{(2)}\right)^{-1}\cdots\left(F^{(n-1)}\right)^{-1} L = ( F ( 1 ) ) − 1 ( F ( 2 ) ) − 1 ⋯ ( F ( n − 1 ) ) − 1
Note
The inverse of a Frobenius matrix is obtained simply by flipping the signs of its off-diagonal entries. For F ( k ) F^{(k)} F ( k ) with entries − m i k -m_{ik} − m ik below the diagonal, ( F ( k ) ) − 1 \left(F^{(k)}\right)^{-1} ( F ( k ) ) − 1 has entries + m i k +m_{ik} + m ik in exactly the same positions. This makes assembling L L L trivial: just collect all multipliers m i k m_{ik} m ik at their natural positions.
Worked Example
Problem: Decompose the matrix A A A below into L L L and U U U , then use LU decomposition to solve A x = b Ax = b A x = b .
A = [ 1 2 1 1 − 2 2 2 12 − 2 ] , b = [ 0 4 4 ] A=\begin{bmatrix}1&2&1\\1&-2&2\\2&12&-2\end{bmatrix},\quad b=\begin{bmatrix}0\\4\\4\end{bmatrix} A = 1 1 2 2 − 2 12 1 2 − 2 , b = 0 4 4
Step 1 — First Frobenius matrix F ( 1 ) F^{(1)} F ( 1 )
Label the original matrix A 1 = A A_1 = A A 1 = A . Compute the multipliers for the first elimination column using the pivot a 11 = 1 a_{11} = 1 a 11 = 1 :
m 21 = a 21 a 11 = 1 1 = 1 m 31 = a 31 a 11 = 2 1 = 2 m_{21} = \frac{a_{21}}{a_{11}} = \frac{1}{1} = 1 \qquad m_{31} = \frac{a_{31}}{a_{11}} = \frac{2}{1} = 2 m 21 = a 11 a 21 = 1 1 = 1 m 31 = a 11 a 31 = 1 2 = 2
Build F ( 1 ) F^{(1)} F ( 1 ) by placing − m 21 -m_{21} − m 21 and − m 31 -m_{31} − m 31 in column 1 below the diagonal:
F ( 1 ) = [ 1 0 0 − 1 1 0 − 2 0 1 ] F^{(1)}=\begin{bmatrix}1&0&0\\-1&1&0\\-2&0&1\end{bmatrix} F ( 1 ) = 1 − 1 − 2 0 1 0 0 0 1
Step 2 — Compute A 2 = F ( 1 ) A 1 A_2 = F^{(1)} A_1 A 2 = F ( 1 ) A 1
A 2 = F ( 1 ) A 1 = [ 1 0 0 − 1 1 0 − 2 0 1 ] [ 1 2 1 1 − 2 2 2 12 − 2 ] = [ 1 2 1 0 − 4 1 0 8 − 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} A 2 = F ( 1 ) A 1 = 1 − 1 − 2 0 1 0 0 0 1 1 1 2 2 − 2 12 1 2 − 2 = 1 0 0 2 − 4 8 1 1 − 4
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)} F ( 2 )
Use A 2 A_2 A 2 to compute the multiplier for the second elimination column. The new pivot is a 22 = − 4 a_{22} = -4 a 22 = − 4 :
m 32 = a 32 a 22 = 8 − 4 = − 2 m_{32} = \frac{a_{32}}{a_{22}} = \frac{8}{-4} = -2 m 32 = a 22 a 32 = − 4 8 = − 2
Build F ( 2 ) F^{(2)} F ( 2 ) by placing − m 32 = 2 -m_{32} = 2 − m 32 = 2 in position ( 3 , 2 ) (3,2) ( 3 , 2 ) :
F ( 2 ) = [ 1 0 0 0 1 0 0 2 1 ] F^{(2)}=\begin{bmatrix}1&0&0\\0&1&0\\0&2&1\end{bmatrix} F ( 2 ) = 1 0 0 0 1 2 0 0 1
Step 4 — Compute U = F ( 2 ) A 2 U = F^{(2)} A_2 U = F ( 2 ) A 2
U = F ( 2 ) A 2 = [ 1 0 0 0 1 0 0 2 1 ] [ 1 2 1 0 − 4 1 0 8 − 4 ] = [ 1 2 1 0 − 4 1 0 0 − 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} U = F ( 2 ) A 2 = 1 0 0 0 1 2 0 0 1 1 0 0 2 − 4 8 1 1 − 4 = 1 0 0 2 − 4 0 1 1 − 2
This is the upper triangular factor U U U .
Step 5 — Assemble L L L
Rather than explicitly inverting the Frobenius matrices, we reuse the multipliers from each step and place them directly at their natural positions:
L = [ 1 0 0 m 21 1 0 m 31 m 32 1 ] = [ 1 0 0 1 1 0 2 − 2 1 ] 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} L = 1 m 21 m 31 0 1 m 32 0 0 1 = 1 1 2 0 1 − 2 0 0 1
Verification: L ⋅ U L \cdot U L ⋅ U should equal A A A :
[ 1 0 0 1 1 0 2 − 2 1 ] [ 1 2 1 0 − 4 1 0 0 − 2 ] = [ 1 2 1 1 − 2 2 2 12 − 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 1 1 2 0 1 − 2 0 0 1 1 0 0 2 − 4 0 1 1 − 2 = 1 1 2 2 − 2 12 1 2 − 2 = A ✓
Solving A x = b Ax = b A x = b via L U LU LU
With the factorization A = L U A = LU A = LU , the system A x = b Ax = b A x = b becomes L U x = b LUx = b LU x = b . Define y = U x y = Ux y = U x , so that L y = b Ly = b L y = b and then U x = y Ux = y U x = y .
Step 6 — Forward substitution: solve L y = b Ly = b L y = b
[ 1 0 0 1 1 0 2 − 2 1 ] [ y 1 y 2 y 3 ] = [ 0 4 4 ] \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} 1 1 2 0 1 − 2 0 0 1 y 1 y 2 y 3 = 0 4 4
Row 1: y 1 = 0 y_1 = 0 y 1 = 0
Row 2: y 1 + y 2 = 4 ⟹ 0 + y 2 = 4 ⟹ y 2 = 4 y_1 + y_2 = 4 \implies 0 + y_2 = 4 \implies y_2 = 4 y 1 + y 2 = 4 ⟹ 0 + y 2 = 4 ⟹ y 2 = 4
Row 3: 2 y 1 − 2 y 2 + y 3 = 4 ⟹ 0 − 8 + y 3 = 4 ⟹ y 3 = 12 2y_1 - 2y_2 + y_3 = 4 \implies 0 - 8 + y_3 = 4 \implies y_3 = 12 2 y 1 − 2 y 2 + y 3 = 4 ⟹ 0 − 8 + y 3 = 4 ⟹ y 3 = 12
y = [ 0 4 12 ] y = \begin{bmatrix}0\\4\\12\end{bmatrix} y = 0 4 12
Step 7 — Back substitution: solve U x = y Ux = y U x = y
[ 1 2 1 0 − 4 1 0 0 − 2 ] [ x 1 x 2 x 3 ] = [ 0 4 12 ] \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} 1 0 0 2 − 4 0 1 1 − 2 x 1 x 2 x 3 = 0 4 12
Row 3: − 2 x 3 = 12 ⟹ x 3 = − 6 -2x_3 = 12 \implies x_3 = -6 − 2 x 3 = 12 ⟹ x 3 = − 6
Row 2: − 4 x 2 + x 3 = 4 ⟹ − 4 x 2 + ( − 6 ) = 4 ⟹ − 4 x 2 = 10 ⟹ x 2 = − 2.5 -4x_2 + x_3 = 4 \implies -4x_2 + (-6) = 4 \implies -4x_2 = 10 \implies x_2 = -2.5 − 4 x 2 + x 3 = 4 ⟹ − 4 x 2 + ( − 6 ) = 4 ⟹ − 4 x 2 = 10 ⟹ x 2 = − 2.5
Row 1: x 1 + 2 x 2 + x 3 = 0 ⟹ x 1 + 2 ( − 2.5 ) + ( − 6 ) = 0 ⟹ x 1 = 11 x_1 + 2x_2 + x_3 = 0 \implies x_1 + 2(-2.5) + (-6) = 0 \implies x_1 = 11 x 1 + 2 x 2 + x 3 = 0 ⟹ x 1 + 2 ( − 2.5 ) + ( − 6 ) = 0 ⟹ x 1 = 11
Step 8 — Solution
x 1 = 11 , x 2 = − 2.5 , x 3 = − 6 \boxed{x_1 = 11,\quad x_2 = -2.5,\quad x_3 = -6} x 1 = 11 , x 2 = − 2.5 , x 3 = − 6
Note
The power of LU decomposition is that L L L and U U U only need to be computed once. If we need to solve A x = b Ax = b A x = b for many different right-hand side vectors b b b (with the same A A A ), we simply repeat Steps 6 and 7 with the new b b b each time. This is far cheaper than re-running Gaussian elimination from scratch for every new b b b .