The process of factorizing a square matrix into 2 triangular matrices: a lower triangular matrix (L) and an upper triangular matrix (U).
Introduced by Alan Turing in 1948.
A=LU
Finding L and U Without Pivoting
Using Gaussian Elimination
Can be used when Gaussian elimination can be performed on Ax=b without row interchanges, A factors as A=LU, where
mji=aii(i)aji(i)
is the multiplier used to eliminate entry (j,i) at step i, U is the row-echelon form produced by elimination, and L collects the multipliers:
L and U are produced together in 1 pass of elimination.
For i=1,…,n−1, use row i as the pivot row.
For each row j>i, compute mji=aji(i)/aii(i).
Eliminate aji with rowj←rowj−mji⋅rowi.
Place mji at position (j,i) of L.
U is the result of elimination. L is the record of multipliers used to produce it.
Direct Computation Method
L and U can also be computed directly by equating entries of A with entries of the product LU.
Entry (i,j) of LU is row i of L multiplied by column j of U.
aij=k=1∑nlikukj
L is lower triangular and U is upper triangular.
lik=0 for k>i.
ukj=0 for k>j.
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).
Setting lii=1 (Doolittle’s method), for i=1,…,n do 2 steps.
Row i of U, for j=i,…,n
uij=aij−k=1∑i−1likukj
Column i of L, for j=i+1,…,n
lji=uii1[aji−k=1∑i−1ljkuki]
Each formula is the entry of A minus the terms that use already known entries of L and U. For i=1 the sums are empty, so row 1 of U is row 1 of A.
Pivoting
LU decomposition can fail when the top-left entry of A is 0 or small compared to other entries.
Pivoting rearranges the rows and/or columns of A to place a larger element in the top-left position, mitigating this. Multiple pivoting algorithms exist.
Applications
Solving Ax=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
Suppose A=LU and Ax=LUx=b must be solved.
Set w=Ux.
Solve Lw=b for w by forward substitution, since L is lower triangular.
Solve Ux=w for x by back substitution, since U is upper triangular. This x solves the original system.
This uses L to perform row operations on U to solve the system.
The factors depend only on A, so they are reused for every new right-hand side. Nodal analysis of a linear circuit gives Yv=i, where Y is the admittance matrix. Changing the sources changes i alone. Y is factored once. Each new i costs only the 2 substitutions.
Factorization costs O(n3), since each of the n−1 elimination steps touches the remaining submatrix. Forward and back substitution are each O(n2). The factorization dominates and is performed once, so solving k systems that share A costs O(n3)+O(kn2) in total. Gaussian elimination on each system separately repeats the O(n3) reduction k times.
Space is O(n2), since L and U together occupy as much storage as A.
Finding the Inverse
Let X be the inverse of A, with columns x1,…,xn. The equation AX=I splits into n systems that share the same A.
Axj=ej,j=1,…,n
Solve each system with the existing factors. The solution xj is column j of X, so the columns collected in order form A−1.
The inverse is the previous case with n right-hand sides, so a single factorization and n pairs of substitutions give A−1 in O(n3) time. Gaussian elimination on each column separately costs O(n4) in total.
Finding the Determinant
For A=LU,
detA=detLdetU
L from Doolittle’s method is unit lower triangular, so detL=1. U is triangular, so detU is the product of its diagonal entries.
detA=i=1∏nuii
A row interchange during pivoting flips the sign of the determinant. With s interchanges,
detA=(−1)si=1∏nuii
The determinant is read off the factorization already computed for solving systems. It adds no cost beyond the factorization itself.
Entries of L and U are filled 1 at a time, row i of U then column i of L. The zeros and the unit diagonal of L are known from the start. ? marks an entry not yet computed.
A
2
1
−1
−3
−1
2
−2
1
2
L
1
0
0
?
1
0
?
?
1
U
2
?
?
0
?
?
0
0
?
a11=u11
u11=a11=2
A
2
1
−1
−3
−1
2
−2
1
2
L
1
0
0
?
1
0
?
?
1
U
2
1
?
0
?
?
0
0
?
a12=u12
u12=a12=1
A
2
1
−1
−3
−1
2
−2
1
2
L
1
0
0
?
1
0
?
?
1
U
2
1
−1
0
?
?
0
0
?
a13=u13
u13=a13=−1
A
2
1
−1
−3
−1
2
−2
1
2
L
1
0
0
−23
1
0
?
?
1
U
2
1
−1
0
?
?
0
0
?
a21=l21u11
l21=u11a21=2−3=−23
A
2
1
−1
−3
−1
2
−2
1
2
L
1
0
0
−23
1
0
−1
?
1
U
2
1
−1
0
?
?
0
0
?
a31=l31u11
l31=u11a31=2−2=−1
A
2
1
−1
−3
−1
2
−2
1
2
L
1
0
0
−23
1
0
−1
?
1
U
2
1
−1
0
21
?
0
0
?
a22=l21u12+u22
u22=a22−l21u12=−1−(−23)1=21
A
2
1
−1
−3
−1
2
−2
1
2
L
1
0
0
−23
1
0
−1
?
1
U
2
1
−1
0
21
21
0
0
?
a23=l21u13+u23
u23=a23−l21u13=2−(−23)(−1)=21
A
2
1
−1
−3
−1
2
−2
1
2
L
1
0
0
−23
1
0
−1
4
1
U
2
1
−1
0
21
21
0
0
?
a32=l31u12+l32u22
l32=u22a32−l31u12=211−(−1)1=4
A
2
1
−1
−3
−1
2
−2
1
2
L
1
0
0
−23
1
0
−1
4
1
U
2
1
−1
0
21
21
0
0
−1
a33=l31u13+l32u23+u33
u33=a33−l31u13−l32u23=2−(−1)(−1)−421=−1
Step-by-step direct computation of L and U, one entry per step
L=1−23−1014001,U=2001210−121−1
Crout's Method
Column 1 of L: l11=2, l21=−3, l31=−2
Row 1 of U: u12=21, u13=−21
Column 2 of L: l22=21, l32=2
Row 2 of U: u23=1
Column 3 of L: l33=−1
1 / 10
A
2
1
−1
−3
−1
2
−2
1
2
L
?
0
0
?
?
0
?
?
?
U
1
?
?
0
1
?
0
0
1
Entries are filled column by column: each iteration computes column i of L then the off-diagonal entries of row i of U. The zeros and the unit diagonal of U are known from the start. ? marks an entry not yet computed.
A
2
1
−1
−3
−1
2
−2
1
2
L
2
0
0
?
?
0
?
?
?
U
1
?
?
0
1
?
0
0
1
a11=l11
l11=a11=2
A
2
1
−1
−3
−1
2
−2
1
2
L
2
0
0
−3
?
0
?
?
?
U
1
?
?
0
1
?
0
0
1
a21=l21
l21=a21=−3
A
2
1
−1
−3
−1
2
−2
1
2
L
2
0
0
−3
?
0
−2
?
?
U
1
?
?
0
1
?
0
0
1
a31=l31
l31=a31=−2
A
2
1
−1
−3
−1
2
−2
1
2
L
2
0
0
−3
?
0
−2
?
?
U
1
21
?
0
1
?
0
0
1
a12=u12l11
u12=l11a12=21=21
A
2
1
−1
−3
−1
2
−2
1
2
L
2
0
0
−3
?
0
−2
?
?
U
1
21
−21
0
1
?
0
0
1
a13=u13l11
u13=l11a13=2−1=−21
A
2
1
−1
−3
−1
2
−2
1
2
L
2
0
0
−3
21
0
−2
?
?
U
1
21
−21
0
1
?
0
0
1
a22=l21u12+l22
l22=a22−l21u12=−1−(−3)21=21
A
2
1
−1
−3
−1
2
−2
1
2
L
2
0
0
−3
21
0
−2
2
?
U
1
21
−21
0
1
?
0
0
1
a32=l31u12+l32
l32=a32−l31u12=1−(−2)21=2
A
2
1
−1
−3
−1
2
−2
1
2
L
2
0
0
−3
21
0
−2
2
?
U
1
21
−21
0
1
1
0
0
1
a23=l21u13+u23l22
u23=l22a23−l21u13=212−(−3)(−21)=1
A
2
1
−1
−3
−1
2
−2
1
2
L
2
0
0
−3
21
0
−2
2
−1
U
1
21
−21
0
1
1
0
0
1
a33=l31u13+l32u23+l33
l33=a33−l31u13−l32u23=2−(−2)(−21)−21=−1
Step-by-step Crout's method: one column of $L$ then row of $U$ per iteration
The determinant is the product of the diagonal entries of U (L has unit diagonal).
detA=1⋅2⋅4=8
Doolittle's Method
Row 1 of U: u11=1, u12=2, u13=1
Column 1 of L: l21=3, l31=2
Row 2 of U: u22=2, u23=2
Column 2 of L: l32=23
Row 3 of U: u33=4
1 / 10
A
1
2
1
3
8
5
2
7
9
L
1
0
0
?
1
0
?
?
1
U
?
?
?
0
?
?
0
0
?
Entries of L and U are filled 1 at a time, row i of U then column i of L. The zeros and the unit diagonal of L are known from the start. ? marks an entry not yet computed.
A
1
2
1
3
8
5
2
7
9
L
1
0
0
?
1
0
?
?
1
U
1
?
?
0
?
?
0
0
?
a11=u11
u11=a11=1
A
1
2
1
3
8
5
2
7
9
L
1
0
0
?
1
0
?
?
1
U
1
2
?
0
?
?
0
0
?
a12=u12
u12=a12=2
A
1
2
1
3
8
5
2
7
9
L
1
0
0
?
1
0
?
?
1
U
1
2
1
0
?
?
0
0
?
a13=u13
u13=a13=1
A
1
2
1
3
8
5
2
7
9
L
1
0
0
3
1
0
?
?
1
U
1
2
1
0
?
?
0
0
?
a21=l21u11
l21=u11a21=13=3
A
1
2
1
3
8
5
2
7
9
L
1
0
0
3
1
0
2
?
1
U
1
2
1
0
?
?
0
0
?
a31=l31u11
l31=u11a31=12=2
A
1
2
1
3
8
5
2
7
9
L
1
0
0
3
1
0
2
?
1
U
1
2
1
0
2
?
0
0
?
a22=l21u12+u22
u22=a22−l21u12=8−32=2
A
1
2
1
3
8
5
2
7
9
L
1
0
0
3
1
0
2
?
1
U
1
2
1
0
2
2
0
0
?
a23=l21u13+u23
u23=a23−l21u13=5−31=2
A
1
2
1
3
8
5
2
7
9
L
1
0
0
3
1
0
2
23
1
U
1
2
1
0
2
2
0
0
?
a32=l31u12+l32u22
l32=u22a32−l31u12=27−22=23
A
1
2
1
3
8
5
2
7
9
L
1
0
0
3
1
0
2
23
1
U
1
2
1
0
2
2
0
0
4
a33=l31u13+l32u23+u33
u33=a33−l31u13−l32u23=9−21−232=4
Step-by-step direct computation of L and U, one entry per step
L=1320123001,U=100220124detA=1⋅2⋅4=8
Crout's Method
Column 1 of L: l11=1, l21=3, l31=2
Row 1 of U: u12=2, u13=1
Column 2 of L: l22=2, l32=3
Row 2 of U: u23=1
Column 3 of L: l33=4
1 / 10
A
1
2
1
3
8
5
2
7
9
L
?
0
0
?
?
0
?
?
?
U
1
?
?
0
1
?
0
0
1
Entries are filled column by column: each iteration computes column i of L then the off-diagonal entries of row i of U. The zeros and the unit diagonal of U are known from the start. ? marks an entry not yet computed.
A
1
2
1
3
8
5
2
7
9
L
1
0
0
?
?
0
?
?
?
U
1
?
?
0
1
?
0
0
1
a11=l11
l11=a11=1
A
1
2
1
3
8
5
2
7
9
L
1
0
0
3
?
0
?
?
?
U
1
?
?
0
1
?
0
0
1
a21=l21
l21=a21=3
A
1
2
1
3
8
5
2
7
9
L
1
0
0
3
?
0
2
?
?
U
1
?
?
0
1
?
0
0
1
a31=l31
l31=a31=2
A
1
2
1
3
8
5
2
7
9
L
1
0
0
3
?
0
2
?
?
U
1
2
?
0
1
?
0
0
1
a12=u12l11
u12=l11a12=12=2
A
1
2
1
3
8
5
2
7
9
L
1
0
0
3
?
0
2
?
?
U
1
2
1
0
1
?
0
0
1
a13=u13l11
u13=l11a13=11=1
A
1
2
1
3
8
5
2
7
9
L
1
0
0
3
2
0
2
?
?
U
1
2
1
0
1
?
0
0
1
a22=l21u12+l22
l22=a22−l21u12=8−32=2
A
1
2
1
3
8
5
2
7
9
L
1
0
0
3
2
0
2
3
?
U
1
2
1
0
1
?
0
0
1
a32=l31u12+l32
l32=a32−l31u12=7−22=3
A
1
2
1
3
8
5
2
7
9
L
1
0
0
3
2
0
2
3
?
U
1
2
1
0
1
1
0
0
1
a23=l21u13+u23l22
u23=l22a23−l21u13=25−31=1
A
1
2
1
3
8
5
2
7
9
L
1
0
0
3
2
0
2
3
4
U
1
2
1
0
1
1
0
0
1
a33=l31u13+l32u23+l33
l33=a33−l31u13−l32u23=9−21−31=4
Step-by-step Crout's method: one column of $L$ then row of $U$ per iteration
L=132023004,U=100210111
The determinant is the product of the diagonal entries of L (U has unit diagonal).
detA=1⋅2⋅4=8
Example 4
Using the L and U from Example 1, find the inverse of
A=2−3−21−11−122
Solution RevealHide
Each column xj of A−1 solves LUxj=ej. From Example 1,
L=1−23−1014001,U=2001210−121−1
For each j, solve Lwj=ej, then solve Uxj=wj.
1 /
For e1=100, solve Lw1=e1 by forward substitution.