LU Decomposition

The process of factorizing a square matrix into 2 triangular matrices: a lower triangular matrix (LL) and an upper triangular matrix (UU). Introduced by Alan Turing in 1948.

A=LUA = LU

Finding LL and UU Without Pivoting

Using Gaussian Elimination

Can be used when Gaussian elimination can be performed on Ax⃗=b⃗A\vec{x} = \vec{b} without row interchanges, AA factors as A=LUA = LU, where

mji=aji(i)aii(i)m_{ji} = \frac{a_{ji}^{(i)}}{a_{ii}^{(i)}}

is the multiplier used to eliminate entry (j,i)(j, i) at step ii, UU is the row-echelon form produced by elimination, and LL collects the multipliers:

U=(a11(1)a12(1)⋯a1n(1)0a22(2)⋯a2n(2)⋮⋮⋱⋮0⋯⋯ann(n))  and  L=(10⋯0m211⋯⋮⋮⋮⋱0mn1⋯mn,n−11)U = \begin{pmatrix} a_{11}^{(1)} & a_{12}^{(1)} & \cdots & a_{1n}^{(1)} \\ 0 & a_{22}^{(2)} & \cdots & a_{2n}^{(2)} \\ \vdots & \vdots & \ddots & \vdots \\ 0 & \cdots & \cdots & a_{nn}^{(n)} \end{pmatrix} \; \text{and} \; L = \begin{pmatrix} 1 & 0 & \cdots & 0 \\ m_{21} & 1 & \cdots & \vdots \\ \vdots & \vdots & \ddots & 0 \\ m_{n1} & \cdots & m_{n,n-1} & 1 \end{pmatrix}

LL and UU are produced together in 1 pass of elimination.

  • For i=1,…,n−1i = 1, \ldots, n-1, use row ii as the pivot row.
  • For each row j>ij > i, compute mji=aji(i)/aii(i)m_{ji} = a_{ji}^{(i)} / a_{ii}^{(i)}.
  • Eliminate ajia_{ji} with rowj←rowj−mji⋅rowi\text{row}_j \leftarrow \text{row}_j - m_{ji} \cdot \text{row}_i.
  • Place mjim_{ji} at position (j,i)(j, i) of LL.

UU is the result of elimination. LL is the record of multipliers used to produce it.

Direct Computation Method

LL and UU can also be computed directly by equating entries of AA with entries of the product LULU.

Entry (i,j)(i, j) of LULU is row ii of LL multiplied by column jj of UU.

aij=∑k=1nlikukja_{ij} = \sum_{k=1}^{n} l_{ik} u_{kj}

LL is lower triangular and UU is upper triangular.

  • lik=0l_{ik} = 0 for k>ik > i.
  • ukj=0u_{kj} = 0 for k>jk > j.
Zero patterns of L and U, entries with k greater than i in L and k greater than j in U are 0 1 0 0 0 l 2 1 1 l 3 1 l 3 2 1 0 l 4 1 l 4 2 l 4 3 1 0 0 i k > i L u 1 1 u 1 2 u 1 3 u 1 4 0 u 2 2 u 2 3 u 2 4 0 u 3 3 u 3 4 0 0 u 4 4 0 0 j k > j U
Matrices L and U with row i = 2 of L and column j = 2 of U highlighted. Every entry l_ik with k > i lies above the diagonal of L and is 0. Every entry u_kj with k > j lies below the diagonal of U and is 0.

So the sum stops at k=min⁡(i,j)k = \min(i, j).

Setting lii=1l_{ii} = 1 (Doolittle’s method), for i=1,…,ni = 1, \ldots, n do 2 steps.

  • Row ii of UU, for j=i,…,nj = i, \ldots, n
uij=aij−∑k=1i−1likukju_{ij} = a_{ij} - \sum_{k=1}^{i-1} l_{ik} u_{kj}
  • Column ii of LL, for j=i+1,…,nj = i+1, \ldots, n
lji=1uii[aji−∑k=1i−1ljkuki]l_{ji} = \frac{1}{u_{ii}} \left[ a_{ji} - \sum_{k=1}^{i-1} l_{jk} u_{ki} \right]

Each formula is the entry of AA minus the terms that use already known entries of LL and UU. For i=1i = 1 the sums are empty, so row 1 of UU is row 1 of AA.

Pivoting

LU decomposition can fail when the top-left entry of AA is 00 or small compared to other entries.

Pivoting rearranges the rows and/or columns of AA to place a larger element in the top-left position, mitigating this. Multiple pivoting algorithms exist.

Applications

  • Solving Ax⃗=b⃗A\vec{x} = \vec{b}, used for finding current in a circuit and solving discrete dynamical systems.
  • Finding the inverse of a matrix.
  • Finding the determinant of a matrix.

Applicable whenever a problem can be modeled in matrix form, since triangular matrices are easy to compute with.

Solving Ax⃗=b⃗A\vec{x} = \vec{b}

Suppose A=LUA = LU and Ax⃗=LUx⃗=b⃗A\vec{x} = LU\vec{x} = \vec{b} must be solved.

  • Set w⃗=Ux⃗\vec{w} = U\vec{x}.
  • Solve Lw⃗=b⃗L\vec{w} = \vec{b} for w⃗\vec{w} by forward substitution, since LL is lower triangular.
  • Solve Ux⃗=w⃗U\vec{x} = \vec{w} for x⃗\vec{x} by back substitution, since UU is upper triangular. This x⃗\vec{x} solves the original system.

This uses LL to perform row operations on UU to solve the system.

The factors depend only on AA, so they are reused for every new right-hand side. Nodal analysis of a linear circuit gives Yv⃗=i⃗Y\vec{v} = \vec{i}, where YY is the admittance matrix. Changing the sources changes i⃗\vec{i} alone. YY is factored once. Each new i⃗\vec{i} costs only the 2 substitutions.

Factorization costs O(n3)O(n^3), since each of the n−1n-1 elimination steps touches the remaining submatrix. Forward and back substitution are each O(n2)O(n^2). The factorization dominates and is performed once, so solving kk systems that share AA costs O(n3)+O(kn2)O(n^3) + O(k n^2) in total. Gaussian elimination on each system separately repeats the O(n3)O(n^3) reduction kk times.

Space is O(n2)O(n^2), since LL and UU together occupy as much storage as AA.

Finding the Inverse

Let XX be the inverse of AA, with columns x⃗1,…,x⃗n\vec{x}_1, \ldots, \vec{x}_n. The equation AX=IAX = I splits into nn systems that share the same AA.

Ax⃗j=e⃗j,j=1,…,nA\vec{x}_j = \vec{e}_j, \quad j = 1, \ldots, n

Solve each system with the existing factors. The solution x⃗j\vec{x}_j is column jj of XX, so the columns collected in order form A−1A^{-1}.

The inverse is the previous case with nn right-hand sides, so a single factorization and nn pairs of substitutions give A−1A^{-1} in O(n3)O(n^3) time. Gaussian elimination on each column separately costs O(n4)O(n^4) in total.

Finding the Determinant

For A=LUA = LU,

det⁡A=det⁡Ldet⁡U\det A = \det L \det U

LL from Doolittle’s method is unit lower triangular, so det⁡L=1\det L = 1. UU is triangular, so det⁡U\det U is the product of its diagonal entries.

det⁡A=∏i=1nuii\det A = \prod_{i=1}^{n} u_{ii}

A row interchange during pivoting flips the sign of the determinant. With ss interchanges,

det⁡A=(−1)s∏i=1nuii\det A = (-1)^{s} \prod_{i=1}^{n} u_{ii}

The determinant is read off the factorization already computed for solving systems. It adds no cost beyond the factorization itself.

Worked Examples

Example 1

For

A=(21−1−3−12−212)A = \begin{pmatrix} 2 & 1 & -1 \\ -3 & -1 & 2 \\ -2 & 1 & 2 \end{pmatrix}

find LL and UU.

Solution Reveal Hide

Gaussian Elimination

m21=−32=−32,m31=−22=−1m_{21} = \frac{-3}{2} = -\frac{3}{2}, \quad m_{31} = \frac{-2}{2} = -1→R3+R1R2+32R1(21−101212021)\xrightarrow[R_3 + R_1]{R_2 + \frac{3}{2}R_1} \begin{pmatrix} 2 & 1 & -1 \\ 0 & \frac{1}{2} & \frac{1}{2} \\ 0 & 2 & 1 \end{pmatrix}m32=212=4m_{32} = \frac{2}{\frac{1}{2}} = 4→R3−4R2(21−10121200−1)\xrightarrow{R_3 - 4R_2} \begin{pmatrix} 2 & 1 & -1 \\ 0 & \frac{1}{2} & \frac{1}{2} \\ 0 & 0 & -1 \end{pmatrix}

Collecting the multipliers

L=(100−3210−141),U=(21−10121200−1)L = \begin{pmatrix} 1 & 0 & 0 \\ -\frac{3}{2} & 1 & 0 \\ -1 & 4 & 1 \end{pmatrix}, \quad U = \begin{pmatrix} 2 & 1 & -1 \\ 0 & \frac{1}{2} & \frac{1}{2} \\ 0 & 0 & -1 \end{pmatrix}

Doolittle's Method

Row 1 of UU: u11=2u_{11} = 2, u12=1u_{12} = 1, u13=−1u_{13} = -1

Column 1 of LL: l21=−32l_{21} = -\frac{3}{2}, l31=−1l_{31} = -1

Row 2 of UU: u22=12u_{22} = \frac{1}{2}, u23=12u_{23} = \frac{1}{2}

Column 2 of LL: l32=4l_{32} = 4

Row 3 of UU: u33=−1u_{33} = -1

1 / 10
AA
LL
UU

Entries of LL and UU are filled 1 at a time, row ii of UU then column ii of LL. The zeros and the unit diagonal of LL are known from the start. ?? marks an entry not yet computed.

AA
LL
UU

a11=u11a_{11} = u_{11}

u11=a11=2u_{11} = a_{11} = 2

AA
LL
UU

a12=u12a_{12} = u_{12}

u12=a12=1u_{12} = a_{12} = 1

AA
LL
UU

a13=u13a_{13} = u_{13}

u13=a13=−1u_{13} = a_{13} = -1

AA
LL
UU

a21=l21u11a_{21} = l_{21} u_{11}

l21=a21u11=−32=−32l_{21} = \dfrac{a_{21}}{u_{11}} = \dfrac{-3}{2} = -\tfrac{3}{2}

AA
LL
UU

a31=l31u11a_{31} = l_{31} u_{11}

l31=a31u11=−22=−1l_{31} = \dfrac{a_{31}}{u_{11}} = \dfrac{-2}{2} = -1

AA
LL
UU

a22=l21u12+u22a_{22} = l_{21} u_{12} + u_{22}

u22=a22−l21u12=−1−(−32)1=12u_{22} = a_{22} - l_{21} u_{12} = -1 - (-\tfrac{3}{2})1 = \tfrac{1}{2}

AA
LL
UU

a23=l21u13+u23a_{23} = l_{21} u_{13} + u_{23}

u23=a23−l21u13=2−(−32)(−1)=12u_{23} = a_{23} - l_{21} u_{13} = 2 - (-\tfrac{3}{2})(-1) = \tfrac{1}{2}

AA
LL
UU

a32=l31u12+l32u22a_{32} = l_{31} u_{12} + l_{32} u_{22}

l32=a32−l31u12u22=1−(−1)112=4l_{32} = \dfrac{a_{32} - l_{31} u_{12}}{u_{22}} = \dfrac{1 - (-1)1}{\tfrac{1}{2}} = 4

AA
LL
UU

a33=l31u13+l32u23+u33a_{33} = l_{31} u_{13} + l_{32} u_{23} + u_{33}

u33=a33−l31u13−l32u23=2−(−1)(−1)−412=−1u_{33} = a_{33} - l_{31} u_{13} - l_{32} u_{23} = 2 - (-1)(-1) - 4\tfrac{1}{2} = -1

L=(100−3210−141),U=(21−10121200−1)L = \begin{pmatrix} 1 & 0 & 0 \\ -\frac{3}{2} & 1 & 0 \\ -1 & 4 & 1 \end{pmatrix}, \quad U = \begin{pmatrix} 2 & 1 & -1 \\ 0 & \frac{1}{2} & \frac{1}{2} \\ 0 & 0 & -1 \end{pmatrix}

Crout's Method

Column 1 of LL: l11=2l_{11} = 2, l21=−3l_{21} = -3, l31=−2l_{31} = -2

Row 1 of UU: u12=12u_{12} = \frac{1}{2}, u13=−12u_{13} = -\frac{1}{2}

Column 2 of LL: l22=12l_{22} = \frac{1}{2}, l32=2l_{32} = 2

Row 2 of UU: u23=1u_{23} = 1

Column 3 of LL: l33=−1l_{33} = -1

1 / 10
AA
LL
UU

Entries are filled column by column: each iteration computes column ii of LL then the off-diagonal entries of row ii of UU. The zeros and the unit diagonal of UU are known from the start. ?? marks an entry not yet computed.

AA
LL
UU

a11=l11a_{11} = l_{11}

l11=a11=2l_{11} = a_{11} = 2

AA
LL
UU

a21=l21a_{21} = l_{21}

l21=a21=−3l_{21} = a_{21} = -3

AA
LL
UU

a31=l31a_{31} = l_{31}

l31=a31=−2l_{31} = a_{31} = -2

AA
LL
UU

a12=u12l11a_{12} = u_{12} l_{11}

u12=a12l11=12=12u_{12} = \dfrac{a_{12}}{l_{11}} = \dfrac{1}{2} = \tfrac{1}{2}

AA
LL
UU

a13=u13l11a_{13} = u_{13} l_{11}

u13=a13l11=−12=−12u_{13} = \dfrac{a_{13}}{l_{11}} = \dfrac{-1}{2} = -\tfrac{1}{2}

AA
LL
UU

a22=l21u12+l22a_{22} = l_{21} u_{12} + l_{22}

l22=a22−l21u12=−1−(−3)12=12l_{22} = a_{22} - l_{21} u_{12} = -1 - (-3)\tfrac{1}{2} = \tfrac{1}{2}

AA
LL
UU

a32=l31u12+l32a_{32} = l_{31} u_{12} + l_{32}

l32=a32−l31u12=1−(−2)12=2l_{32} = a_{32} - l_{31} u_{12} = 1 - (-2)\tfrac{1}{2} = 2

AA
LL
UU

a23=l21u13+u23l22a_{23} = l_{21} u_{13} + u_{23} l_{22}

u23=a23−l21u13l22=2−(−3)(−12)12=1u_{23} = \dfrac{a_{23} - l_{21} u_{13}}{l_{22}} = \dfrac{2 - (-3)(-\tfrac{1}{2})}{\tfrac{1}{2}} = 1

AA
LL
UU

a33=l31u13+l32u23+l33a_{33} = l_{31} u_{13} + l_{32} u_{23} + l_{33}

l33=a33−l31u13−l32u23=2−(−2)(−12)−21=−1l_{33} = a_{33} - l_{31} u_{13} - l_{32} u_{23} = 2 - (-2)(-\tfrac{1}{2}) - 21 = -1

L=(200−3120−22−1),U=(112−12011001)L = \begin{pmatrix} 2 & 0 & 0 \\ -3 & \frac{1}{2} & 0 \\ -2 & 2 & -1 \end{pmatrix}, \quad U = \begin{pmatrix} 1 & \frac{1}{2} & -\frac{1}{2} \\ 0 & 1 & 1 \\ 0 & 0 & 1 \end{pmatrix}

Example 2

Using the LL and UU from Example 1, solve Ax⃗=b⃗A\vec{x} = \vec{b} for

b⃗=(101)\vec{b} = \begin{pmatrix} 1 \\ 0 \\ 1 \end{pmatrix}
Solution Reveal Hide

From Example 1,

L=(100−3210−141),U=(21−10121200−1)L = \begin{pmatrix} 1 & 0 & 0 \\ -\frac{3}{2} & 1 & 0 \\ -1 & 4 & 1 \end{pmatrix}, \quad U = \begin{pmatrix} 2 & 1 & -1 \\ 0 & \frac{1}{2} & \frac{1}{2} \\ 0 & 0 & -1 \end{pmatrix}

Solve Lw⃗=b⃗L\vec{w} = \vec{b} by forward substitution.

w1=1w_1 = 1−32w1+w2=0  ⟹  w2=32-\frac{3}{2} w_1 + w_2 = 0 \implies w_2 = \frac{3}{2}−w1+4w2+w3=1  ⟹  w3=−4-w_1 + 4w_2 + w_3 = 1 \implies w_3 = -4w⃗=(132−4)\vec{w} = \begin{pmatrix} 1 \\ \frac{3}{2} \\ -4 \end{pmatrix}

Solve Ux⃗=w⃗U\vec{x} = \vec{w} by back substitution.

−x3=−4  ⟹  x3=4-x_3 = -4 \implies x_3 = 412x2+12(4)=32  ⟹  x2=−1\frac{1}{2} x_2 + \frac{1}{2}(4) = \frac{3}{2} \implies x_2 = -12x1+x2−x3=1  ⟹  x1=32x_1 + x_2 - x_3 = 1 \implies x_1 = 3x⃗=(3−14)\vec{x} = \begin{pmatrix} 3 \\ -1 \\ 4 \end{pmatrix}

Example 3

Find the determinant of

A=(121385279)A = \begin{pmatrix} 1 & 2 & 1 \\ 3 & 8 & 5 \\ 2 & 7 & 9 \end{pmatrix}

using LU decomposition.

Solution Reveal Hide

Gaussian Elimination

Elimination on AA

m21=3,m31=2m_{21} = 3, \quad m_{31} = 2→R3−2R1R2−3R1(121022037)\xrightarrow[R_3 - 2R_1]{R_2 - 3R_1} \begin{pmatrix} 1 & 2 & 1 \\ 0 & 2 & 2 \\ 0 & 3 & 7 \end{pmatrix}m32=32m_{32} = \frac{3}{2}→R3−32R2(121022004)\xrightarrow{R_3 - \frac{3}{2}R_2} \begin{pmatrix} 1 & 2 & 1 \\ 0 & 2 & 2 \\ 0 & 0 & 4 \end{pmatrix}L=(1003102321),U=(121022004)L = \begin{pmatrix} 1 & 0 & 0 \\ 3 & 1 & 0 \\ 2 & \frac{3}{2} & 1 \end{pmatrix}, \quad U = \begin{pmatrix} 1 & 2 & 1 \\ 0 & 2 & 2 \\ 0 & 0 & 4 \end{pmatrix}

The determinant is the product of the diagonal entries of UU (LL has unit diagonal).

det⁡A=1⋅2⋅4=8\det A = 1 \cdot 2 \cdot 4 = 8

Doolittle's Method

Row 1 of UU: u11=1u_{11} = 1, u12=2u_{12} = 2, u13=1u_{13} = 1

Column 1 of LL: l21=3l_{21} = 3, l31=2l_{31} = 2

Row 2 of UU: u22=2u_{22} = 2, u23=2u_{23} = 2

Column 2 of LL: l32=32l_{32} = \frac{3}{2}

Row 3 of UU: u33=4u_{33} = 4

1 / 10
AA
LL
UU

Entries of LL and UU are filled 1 at a time, row ii of UU then column ii of LL. The zeros and the unit diagonal of LL are known from the start. ?? marks an entry not yet computed.

AA
LL
UU

a11=u11a_{11} = u_{11}

u11=a11=1u_{11} = a_{11} = 1

AA
LL
UU

a12=u12a_{12} = u_{12}

u12=a12=2u_{12} = a_{12} = 2

AA
LL
UU

a13=u13a_{13} = u_{13}

u13=a13=1u_{13} = a_{13} = 1

AA
LL
UU

a21=l21u11a_{21} = l_{21} u_{11}

l21=a21u11=31=3l_{21} = \dfrac{a_{21}}{u_{11}} = \dfrac{3}{1} = 3

AA
LL
UU

a31=l31u11a_{31} = l_{31} u_{11}

l31=a31u11=21=2l_{31} = \dfrac{a_{31}}{u_{11}} = \dfrac{2}{1} = 2

AA
LL
UU

a22=l21u12+u22a_{22} = l_{21} u_{12} + u_{22}

u22=a22−l21u12=8−32=2u_{22} = a_{22} - l_{21} u_{12} = 8 - 32 = 2

AA
LL
UU

a23=l21u13+u23a_{23} = l_{21} u_{13} + u_{23}

u23=a23−l21u13=5−31=2u_{23} = a_{23} - l_{21} u_{13} = 5 - 31 = 2

AA
LL
UU

a32=l31u12+l32u22a_{32} = l_{31} u_{12} + l_{32} u_{22}

l32=a32−l31u12u22=7−222=32l_{32} = \dfrac{a_{32} - l_{31} u_{12}}{u_{22}} = \dfrac{7 - 22}{2} = \tfrac{3}{2}

AA
LL
UU

a33=l31u13+l32u23+u33a_{33} = l_{31} u_{13} + l_{32} u_{23} + u_{33}

u33=a33−l31u13−l32u23=9−21−322=4u_{33} = a_{33} - l_{31} u_{13} - l_{32} u_{23} = 9 - 21 - \tfrac{3}{2}2 = 4

L=(1003102321),U=(121022004)L = \begin{pmatrix} 1 & 0 & 0 \\ 3 & 1 & 0 \\ 2 & \frac{3}{2} & 1 \end{pmatrix}, \quad U = \begin{pmatrix} 1 & 2 & 1 \\ 0 & 2 & 2 \\ 0 & 0 & 4 \end{pmatrix}det⁡A=1⋅2⋅4=8\det A = 1 \cdot 2 \cdot 4 = 8

Crout's Method

Column 1 of LL: l11=1l_{11} = 1, l21=3l_{21} = 3, l31=2l_{31} = 2

Row 1 of UU: u12=2u_{12} = 2, u13=1u_{13} = 1

Column 2 of LL: l22=2l_{22} = 2, l32=3l_{32} = 3

Row 2 of UU: u23=1u_{23} = 1

Column 3 of LL: l33=4l_{33} = 4

1 / 10
AA
LL
UU

Entries are filled column by column: each iteration computes column ii of LL then the off-diagonal entries of row ii of UU. The zeros and the unit diagonal of UU are known from the start. ?? marks an entry not yet computed.

AA
LL
UU

a11=l11a_{11} = l_{11}

l11=a11=1l_{11} = a_{11} = 1

AA
LL
UU

a21=l21a_{21} = l_{21}

l21=a21=3l_{21} = a_{21} = 3

AA
LL
UU

a31=l31a_{31} = l_{31}

l31=a31=2l_{31} = a_{31} = 2

AA
LL
UU

a12=u12l11a_{12} = u_{12} l_{11}

u12=a12l11=21=2u_{12} = \dfrac{a_{12}}{l_{11}} = \dfrac{2}{1} = 2

AA
LL
UU

a13=u13l11a_{13} = u_{13} l_{11}

u13=a13l11=11=1u_{13} = \dfrac{a_{13}}{l_{11}} = \dfrac{1}{1} = 1

AA
LL
UU

a22=l21u12+l22a_{22} = l_{21} u_{12} + l_{22}

l22=a22−l21u12=8−32=2l_{22} = a_{22} - l_{21} u_{12} = 8 - 32 = 2

AA
LL
UU

a32=l31u12+l32a_{32} = l_{31} u_{12} + l_{32}

l32=a32−l31u12=7−22=3l_{32} = a_{32} - l_{31} u_{12} = 7 - 22 = 3

AA
LL
UU

a23=l21u13+u23l22a_{23} = l_{21} u_{13} + u_{23} l_{22}

u23=a23−l21u13l22=5−312=1u_{23} = \dfrac{a_{23} - l_{21} u_{13}}{l_{22}} = \dfrac{5 - 31}{2} = 1

AA
LL
UU

a33=l31u13+l32u23+l33a_{33} = l_{31} u_{13} + l_{32} u_{23} + l_{33}

l33=a33−l31u13−l32u23=9−21−31=4l_{33} = a_{33} - l_{31} u_{13} - l_{32} u_{23} = 9 - 21 - 31 = 4

L=(100320234),U=(121011001)L = \begin{pmatrix} 1 & 0 & 0 \\ 3 & 2 & 0 \\ 2 & 3 & 4 \end{pmatrix}, \quad U = \begin{pmatrix} 1 & 2 & 1 \\ 0 & 1 & 1 \\ 0 & 0 & 1 \end{pmatrix}

The determinant is the product of the diagonal entries of LL (UU has unit diagonal).

det⁡A=1⋅2⋅4=8\det A = 1 \cdot 2 \cdot 4 = 8

Example 4

Using the LL and UU from Example 1, find the inverse of

A=(21−1−3−12−212)A = \begin{pmatrix} 2 & 1 & -1 \\ -3 & -1 & 2 \\ -2 & 1 & 2 \end{pmatrix}
Solution Reveal Hide

Each column x⃗j\vec{x}_j of A−1A^{-1} solves LUx⃗j=e⃗jLU\vec{x}_j = \vec{e}_j. From Example 1,

L=(100−3210−141),U=(21−10121200−1)L = \begin{pmatrix} 1 & 0 & 0 \\ -\frac{3}{2} & 1 & 0 \\ -1 & 4 & 1 \end{pmatrix}, \quad U = \begin{pmatrix} 2 & 1 & -1 \\ 0 & \frac{1}{2} & \frac{1}{2} \\ 0 & 0 & -1 \end{pmatrix}

For each jj, solve Lw⃗j=e⃗jL\vec{w}_j = \vec{e}_j, then solve Ux⃗j=w⃗jU\vec{x}_j = \vec{w}_j.

1 /

For e⃗1=(100)\vec{e}_1 = \begin{pmatrix} 1 \\ 0 \\ 0 \end{pmatrix}, solve Lw⃗1=e⃗1L\vec{w}_1 = \vec{e}_1 by forward substitution.

w1=1,−32w1+w2=0  ⟹  w2=32w_1 = 1, \quad -\frac{3}{2}w_1 + w_2 = 0 \implies w_2 = \frac{3}{2}−w1+4w2+w3=0  ⟹  w3=−5,w⃗1=(132−5)-w_1 + 4w_2 + w_3 = 0 \implies w_3 = -5, \quad \vec{w}_1 = \begin{pmatrix} 1 \\ \frac{3}{2} \\ -5 \end{pmatrix}

Solve Ux⃗1=w⃗1U\vec{x}_1 = \vec{w}_1 by back substitution.

−x3=−5  ⟹  x3=5-x_3 = -5 \implies x_3 = 512x2+12(5)=32  ⟹  x2=−2,2x1+x2−x3=1  ⟹  x1=4\frac{1}{2}x_2 + \frac{1}{2}(5) = \frac{3}{2} \implies x_2 = -2, \quad 2x_1 + x_2 - x_3 = 1 \implies x_1 = 4x⃗1=(4−25)\vec{x}_1 = \begin{pmatrix} 4 \\ -2 \\ 5 \end{pmatrix}

For e⃗2=(010)\vec{e}_2 = \begin{pmatrix} 0 \\ 1 \\ 0 \end{pmatrix}, solve Lw⃗2=e⃗2L\vec{w}_2 = \vec{e}_2.

w1=0,−32w1+w2=1  ⟹  w2=1w_1 = 0, \quad -\frac{3}{2}w_1 + w_2 = 1 \implies w_2 = 1−w1+4w2+w3=0  ⟹  w3=−4,w⃗2=(01−4)-w_1 + 4w_2 + w_3 = 0 \implies w_3 = -4, \quad \vec{w}_2 = \begin{pmatrix} 0 \\ 1 \\ -4 \end{pmatrix}

Solve Ux⃗2=w⃗2U\vec{x}_2 = \vec{w}_2.

−x3=−4  ⟹  x3=4-x_3 = -4 \implies x_3 = 412x2+12(4)=1  ⟹  x2=−2,2x1+x2−x3=0  ⟹  x1=3\frac{1}{2}x_2 + \frac{1}{2}(4) = 1 \implies x_2 = -2, \quad 2x_1 + x_2 - x_3 = 0 \implies x_1 = 3x⃗2=(3−24)\vec{x}_2 = \begin{pmatrix} 3 \\ -2 \\ 4 \end{pmatrix}

For e⃗3=(001)\vec{e}_3 = \begin{pmatrix} 0 \\ 0 \\ 1 \end{pmatrix}, solve Lw⃗3=e⃗3L\vec{w}_3 = \vec{e}_3.

w1=0,−32w1+w2=0  ⟹  w2=0w_1 = 0, \quad -\frac{3}{2}w_1 + w_2 = 0 \implies w_2 = 0−w1+4w2+w3=1  ⟹  w3=1,w⃗3=(001)-w_1 + 4w_2 + w_3 = 1 \implies w_3 = 1, \quad \vec{w}_3 = \begin{pmatrix} 0 \\ 0 \\ 1 \end{pmatrix}

Solve Ux⃗3=w⃗3U\vec{x}_3 = \vec{w}_3.

−x3=1  ⟹  x3=−1-x_3 = 1 \implies x_3 = -112x2+12(−1)=0  ⟹  x2=1,2x1+x2−x3=0  ⟹  x1=−1\frac{1}{2}x_2 + \frac{1}{2}(-1) = 0 \implies x_2 = 1, \quad 2x_1 + x_2 - x_3 = 0 \implies x_1 = -1x⃗3=(−11−1)\vec{x}_3 = \begin{pmatrix} -1 \\ 1 \\ -1 \end{pmatrix}

The columns are x⃗1\vec{x}_1, x⃗2\vec{x}_2, and x⃗3\vec{x}_3 in order.

A−1=(43−1−2−2154−1)A^{-1} = \begin{pmatrix} 4 & 3 & -1 \\ -2 & -2 & 1 \\ 5 & 4 & -1 \end{pmatrix}

Wolfram Mathematica notebooks

A companion notebook for this note. Open it in Mathematica and evaluate the cells to reproduce the worked example.

The summary notebook defines every function used in this module, with documentation and no examples, as a starting point for your own problems.

Written by November 5, 2026 5 min read
Was this helpful?