Introduction

Gaussian elimination does two jobs at once: it transforms the matrix and it transforms the right-hand side. LU decomposition separates them. It records elimination once as A=LUA = LU, a lower triangular matrix times an upper triangular one, and then solves Ax=bAx = b for any number of right-hand sides with two cheap triangular solves. The tasks are to find the factors of a small matrix, a particular entry of LL or UU, the conditions under which the factorisation exists, or the cost of solving.

Prerequisites

Core concepts

The factorisation

For a square matrix AA, an LU decomposition is A=LUA = LU with LL lower triangular and UU upper triangular. Since n2n^2 entries of AA cannot fix the n2+nn^2 + n entries of LL and UU, a normalisation is chosen:

NameNormalisationNotes
DoolittleLL has 1s on the diagonalUU is upper triangular (also row-echelon in nonsingular no-swap elimination); LL stores the multipliers
CroutUU has 1s on the diagonalLL carries the pivots
LDUboth LL and UU unit triangular, DD diagonalDD holds the pivots
CholeskyA=LLTA = LL^T, LL with positive diagonalonly for symmetric positive definite AA

Factorisation convention. "LU" means Doolittle unless a question says otherwise.

Where LL and UU come from

Run elimination without row swaps. To clear entry (i,j)(i, j) below the pivot ujju_{jj}, subtract ℓij=aij(j)/ujj\ell_{ij} = a^{(j)}_{ij}/u_{jj} times row jj from row ii (with a(j)a^{(j)} the current entries). Then

  • UU = the final upper triangular matrix;
  • LL = unit lower triangular, with ℓij\ell_{ij} placed at position (i,j)(i, j).

The multipliers go into LL with the same sign as they were used for subtraction. Equivalently, the Doolittle formulas compute row kk of UU and column kk of LL in turn:

ukj=akj−∑s<kℓksusj (j≥k),ℓik=1ukk(aik−∑s<kℓisusk) (i>k).u_{kj} = a_{kj} - \sum_{s < k} \ell_{ks} u_{sj} \ (j \ge k), \qquad \ell_{ik} = \frac{1}{u_{kk}}\Big(a_{ik} - \sum_{s < k} \ell_{is} u_{sk}\Big) \ (i > k).

Solving Ax=bAx = b

With A=LUA = LU, write Ux=yUx = y. Then:

  1. Forward substitution: solve Ly=bLy = b from the top row down.
  2. Back substitution: solve Ux=yUx = y from the bottom row up.
Forward then backward substitution
Figure 1. Solving Ax=bAx = b through A=LUA = LU: forward substitution in Ly=bLy = b runs top to bottom, then back substitution in Ux=yUx = y runs bottom to top. Values are those of Example 1.

Cost. Factorising an n×nn \times n matrix takes about n3/3n^3/3 multiplications (and as many additions), that is O(n3)O(n^3). Each triangular solve takes about n2/2n^2/2 multiplications, so each additional right-hand side costs only O(n2)O(n^2). This is why LU is preferred over computing A−1A^{-1} when the same AA appears with many bb.

Determinant for free. det⁡A=det⁡L⋅det⁡U=∏iuii\det A = \det L \cdot \det U = \prod_i u_{ii} for Doolittle (and with row swaps, multiply by (−1)number of swaps(-1)^{\text{number of swaps}}).

Existence and pivoting

  • Sufficient: if every leading principal minor det⁡Ak\det A_k (top-left k×kk \times k block), k=1,…,n−1k = 1, \ldots, n - 1, is non-zero, then AA has an LU decomposition with unit LL; if additionally AA is invertible, the Doolittle factorisation is unique. The pivots are ukk=det⁡Ak/det⁡Ak−1u_{kk} = \det A_k / \det A_{k-1} (with det⁡A0=1\det A_0 = 1).
  • Necessary for invertible AA: if an invertible AA has A=LUA = LU, then all leading principal minors are non-zero. So for invertible matrices the condition is necessary and sufficient.
  • For an invertible matrix at an active elimination pivot, a zero pivot requires a row exchange. A singular matrix may instead have a zero column to skip or reveal singularity; a useful exchange need not exist. With a permutation matrix PP, every invertible AA satisfies PA=LUPA=LU. Partial pivoting chooses the largest available pivot in absolute value for numerical stability.
  • Classes that never need pivoting: symmetric positive definite matrices (and they admit Cholesky), and strictly diagonally dominant matrices.

Cholesky

If AA is symmetric positive definite (xTAx>0x^TAx > 0 for all x≠0x \ne 0; equivalently all eigenvalues positive; equivalently all leading principal minors positive), then A=LLTA = LL^T with a unique lower triangular LL having positive diagonal. It needs about half the work of LU.

Worked examples

Example 1: Doolittle factorisation and solve

A=(211433879)A = \begin{pmatrix} 2 & 1 & 1 \\ 4 & 3 & 3 \\ 8 & 7 & 9 \end{pmatrix}, b=(4,10,24)Tb = (4, 10, 24)^T.

Column 1: multipliers ℓ21=4/2=2\ell_{21} = 4/2 = 2, ℓ31=8/2=4\ell_{31} = 8/2 = 4; rows become (0,1,1)(0, 1, 1) and (0,3,5)(0, 3, 5). Column 2: ℓ32=3/1=3\ell_{32} = 3/1 = 3; row 3 becomes (0,0,2)(0, 0, 2). So

L=(100210431),U=(211011002),det⁡A=2⋅1⋅2=4.L = \begin{pmatrix} 1 & 0 & 0 \\ 2 & 1 & 0 \\ 4 & 3 & 1 \end{pmatrix}, \qquad U = \begin{pmatrix} 2 & 1 & 1 \\ 0 & 1 & 1 \\ 0 & 0 & 2 \end{pmatrix}, \qquad \det A = 2 \cdot 1 \cdot 2 = 4 .

Forward: y1=4y_1 = 4, y2=10−2⋅4=2y_2 = 10 - 2 \cdot 4 = 2, y3=24−4⋅4−3⋅2=2y_3 = 24 - 4 \cdot 4 - 3 \cdot 2 = 2. Back: x3=2/2=1x_3 = 2/2 = 1, x2=2−1=1x_2 = 2 - 1 = 1, x1=(4−1−1)/2=1x_1 = (4 - 1 - 1)/2 = 1. So x=(1,1,1)x = (1, 1, 1).

Example 2: Doolittle versus Crout

A=(4363)A = \begin{pmatrix} 4 & 3 \\ 6 & 3 \end{pmatrix}. Doolittle: L=(101.51)L = \begin{pmatrix} 1 & 0 \\ 1.5 & 1 \end{pmatrix}, U=(430−1.5)U = \begin{pmatrix} 4 & 3 \\ 0 & -1.5 \end{pmatrix}. Crout: L=(406−1.5)L = \begin{pmatrix} 4 & 0 \\ 6 & -1.5 \end{pmatrix}, U=(10.7501)U = \begin{pmatrix} 1 & 0.75 \\ 0 & 1 \end{pmatrix}. Both multiply back to AA; both give det⁡A=−6\det A = -6.

Example 3: pivoting needed

A=(0111)A = \begin{pmatrix} 0 & 1 \\ 1 & 1 \end{pmatrix} is invertible, but its first leading minor is 0, so it has no LU decomposition: ℓ11u11=0\ell_{11}u_{11} = 0 would force LL or UU to be singular. Swapping the rows gives PA=(1101)=I⋅PAPA = \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix} = I \cdot PA, already upper triangular.

Example 4: a parameter

A=(246k)A = \begin{pmatrix} 2 & 4 \\ 6 & k \end{pmatrix}: ℓ21=3\ell_{21} = 3, u22=k−12u_{22} = k - 12. The factorisation exists for every kk (the first pivot is 2); AA is singular exactly when k=12k = 12.

Example 5: Cholesky

A=(4225)A = \begin{pmatrix} 4 & 2 \\ 2 & 5 \end{pmatrix} (leading minors 4 and 16, positive). ℓ11=2\ell_{11} = 2, ℓ21=2/2=1\ell_{21} = 2/2 = 1, ℓ22=5−1=2\ell_{22} = \sqrt{5 - 1} = 2: L=(2012)L = \begin{pmatrix} 2 & 0 \\ 1 & 2 \end{pmatrix} and LLT=ALL^T = A.

Example 6: pivots from leading minors

For the matrix of Example 1, the leading principal minors are det⁡A1=2\det A_1 = 2, det⁡A2=2⋅3−1⋅4=2\det A_2 = 2 \cdot 3 - 1 \cdot 4 = 2 and det⁡A3=4\det A_3 = 4. The pivots are therefore 2/1=22/1 = 2, 2/2=12/2 = 1 and 4/2=24/2 = 2, matching the diagonal of UU without doing any elimination.

Example 7: why factor once

For n=1000n = 1000 and 100 right-hand sides, repeating elimination costs about 100×n3/3≈3.3×1010100 \times n^3/3 \approx 3.3 \times 10^{10} multiplications. Factoring once and doing two triangular solves per right-hand side costs about n3/3+100×n2≈3.3×108+108≈4.3×108n^3/3 + 100 \times n^2 \approx 3.3 \times 10^8 + 10^8 \approx 4.3 \times 10^8, roughly 77 times fewer multiplications.

Example 8: a tridiagonal matrix

T=(2−10−12−10−12)T = \begin{pmatrix} 2 & -1 & 0 \\ -1 & 2 & -1 \\ 0 & -1 & 2 \end{pmatrix}. Elimination gives ℓ21=−1/2\ell_{21} = -1/2, u22=3/2u_{22} = 3/2, ℓ32=−2/3\ell_{32} = -2/3, u33=4/3u_{33} = 4/3:

L=(100−1/2100−2/31),U=(2−1003/2−1004/3).L = \begin{pmatrix} 1 & 0 & 0 \\ -1/2 & 1 & 0 \\ 0 & -2/3 & 1 \end{pmatrix}, \qquad U = \begin{pmatrix} 2 & -1 & 0 \\ 0 & 3/2 & -1 \\ 0 & 0 & 4/3 \end{pmatrix} .

The pivots 2,3/2,4/32, 3/2, 4/3 are the ratios 2/1,3/2,4/32/1, 3/2, 4/3 of consecutive leading minors, and det⁡T=2⋅32⋅43=4\det T = 2 \cdot \frac32 \cdot \frac43 = 4. Here all required pivots are nonzero. Under that condition both factors are bidiagonal, so for an n×nn \times n tridiagonal matrix factorisation and each solve take O(n)O(n) operations instead of O(n3)O(n^3) and O(n2)O(n^2) (the Thomas algorithm). If a required pivot vanishes, use an appropriate pivoted banded solver rather than dividing by zero.

Example 9: a singular matrix with many factorisations

A=(0001)A = \begin{pmatrix} 0 & 0 \\ 0 & 1 \end{pmatrix} has a zero first leading minor, yet for every number ℓ\ell, L=(10ℓ1)L = \begin{pmatrix} 1 & 0 \\ \ell & 1 \end{pmatrix} and U=(0001)U = \begin{pmatrix} 0 & 0 \\ 0 & 1 \end{pmatrix} give LU=ALU = A. So for singular matrices a zero leading minor does not rule out an LU factorisation, and the factorisation need not be unique; the clean "exists uniquely if and only if the leading minors are non-zero" statement is for invertible matrices.

Important properties and observations

  • The inverse of a unit lower triangular matrix is unit lower triangular; products of lower triangular matrices are lower triangular. This is why the elimination steps combine into one LL.
  • UU from Doolittle is upper triangular; in nonsingular elimination without swaps it is also row-echelon. Singular upper triangular factors need not be row-echelon.
  • In elimination without row swaps, pivots are ratios of consecutive leading principal minors when the denominator minor (the product of prior pivots) is nonzero.
  • LU does not change the O(n3)O(n^3) cost of one solve; it makes repeated solves O(n2)O(n^2).

GATE examination perspective

  • Compute LL or UU (or one entry) for a 2×22 \times 2 or 3×33 \times 3 matrix, in the Doolittle convention used here.
  • Forward and back substitution to finish a solve.
  • Existence: leading principal minors, need for pivoting.
  • Cost: O(n3)O(n^3) factorisation, O(n2)O(n^2) per right-hand side.
  • Trap: sign errors when copying multipliers into LL.
  • Trap: mixing Doolittle and Crout normalisations.
  • Banded matrices. If all required elimination pivots are nonzero, tridiagonal AA gives bidiagonal L,UL,U with O(n)O(n) work (Example 8); otherwise use an appropriate pivoted banded solver.
  • Trap: applying the leading-minor test to a singular matrix as if it were invertible (Example 9).

Summary

Sources

  1. G. Strang, Introduction to Linear Algebra, 5th ed., Wellesley-Cambridge Press, 2016: Sections 2.6 (Elimination = Factorization: A = LU) and 2.7 (Transposes and Permutations).
  2. E. Kreyszig, Advanced Engineering Mathematics, 10th ed., Wiley, 2011: Chapter 20 (Numeric Linear Algebra).

Next steps