LU Decomposition

lean4-prooflinear-algebravisualization
A=LU,L unit lower triangular,  U upper triangularA = LU,\quad L \text{ unit lower triangular},\; U \text{ upper triangular}

Statement

Let AA be an n×nn \times n invertible matrix over a field FF. Then there exist matrices LL and UU such that

A=LU,A = LU,

where LL is unit lower-triangular (ones on the diagonal, zeros above) and UU is upper-triangular (zeros below the diagonal). The factorization is unique when it exists without pivoting.

When row swaps are required, the decomposition takes the form PA=LUPA = LU for a permutation matrix PP.

Visualization

Factor A=(4363)A = \begin{pmatrix} 4 & 3 \\ 6 & 3 \end{pmatrix}:

Step 1 — eliminate below a11=4a_{11} = 4:

Multiplier m21=6/4=3/2m_{21} = 6/4 = 3/2. Subtract 3/23/2 times row 1 from row 2:

(4363243323)=(43032)=U.\begin{pmatrix} 4 & 3 \\ 6 - \tfrac{3}{2}\cdot4 & 3 - \tfrac{3}{2}\cdot3 \end{pmatrix} = \begin{pmatrix} 4 & 3 \\ 0 & -\tfrac{3}{2} \end{pmatrix} = U.

Result:

L=(103/21),U=(4303/2).L = \begin{pmatrix} 1 & 0 \\ 3/2 & 1 \end{pmatrix}, \quad U = \begin{pmatrix} 4 & 3 \\ 0 & -3/2 \end{pmatrix}.

Verification:

LU=(14+013+0324+10323+1(32))=(4363)=A.LU = \begin{pmatrix} 1\cdot4+0 & 1\cdot3+0 \\ \tfrac{3}{2}\cdot4+1\cdot0 & \tfrac{3}{2}\cdot3+1\cdot(-\tfrac{3}{2}) \end{pmatrix} = \begin{pmatrix} 4 & 3 \\ 6 & 3 \end{pmatrix} = A. \checkmark

Also: detA=detLdetU=1(4(32))=6\det A = \det L \cdot \det U = 1 \cdot (4 \cdot (-\tfrac{3}{2})) = -6.

Proof Sketch

  1. Gaussian elimination. Apply row operations to reduce AA to upper-triangular form. At step kk, subtract multiples of row kk from all rows below it. This works without swaps when all pivot entries akk(k)a_{kk}^{(k)} are nonzero.
  2. Encoding the multipliers. Each row operation "subtract mikm_{ik} times row kk from row ii" corresponds to multiplying on the left by a unit lower-triangular matrix EikE_{ik}. The product L=kEik1L = \prod_k E_{ik}^{-1} is again unit lower-triangular.
  3. Determinant. Since detL=1\det L = 1 (product of ones on diagonal), detA=detU=iuii\det A = \det U = \prod_i u_{ii}. This follows from det(upper-triangular)=idiagonal entries\det(\text{upper-triangular}) = \prod_i \text{diagonal entries}.
  4. Uniqueness (no pivoting case). If A=LU=LUA = LU = L'U' with L,LL, L' unit lower and U,UU, U' upper triangular, then L1L=UU1L^{-1}L' = UU'^{-1} is both lower and upper triangular with ones on the diagonal, so it equals II.

Connections

LU decomposition depends on Determinant MultiplicativityDeterminant Multiplicativitydet(AB)=det(A)det(B)\det(AB) = \det(A)\,\det(B)The determinant of a product equals the product of determinantsRead more → (det(LU)=detLdetU\det(LU) = \det L \cdot \det U) and is a concrete construction underlying the Rank–Nullity TheoremRank–Nullity Theoremrank(f)+nullity(f)=dimV\operatorname{rank}(f) + \operatorname{nullity}(f) = \dim VThe dimensions of image and kernel of a linear map sum to the domain dimensionRead more → (Gaussian elimination reveals the rank). It generalizes Cramer's RuleCramer's Rulexi=det(Ai)det(A)x_i = \frac{\det(A_i)}{\det(A)}Explicit determinant formula for the solution of a linear systemRead more → as a more efficient solver.

Lean4 Proof

-- We prove the triangular determinant product rule, which is the key algebraic
-- fact behind LU: det of upper-triangular = product of diagonal entries.
-- Mathlib: Matrix.det_of_upperTriangular in LinearAlgebra.Matrix.Block
-- For a concrete 2x2 LU verification we use decide on rational matrices.
open Matrix in
theorem det_upper_triangular_is_diag_prod
    {n : Type*} [LinearOrder n] [Fintype n] (M : Matrix n n )
    (h : M.BlockTriangular id) : M.det = ∏ i : n, M i i :=
  det_of_upperTriangular h

-- Concrete LU check for the 2x2 example: A = L * U
theorem lu_example_2x2 :
    let A : Matrix (Fin 2) (Fin 2)  := !![4, 3; 6, 3]
    let L : Matrix (Fin 2) (Fin 2)  := !![1, 0; 3/2, 1]
    let U : Matrix (Fin 2) (Fin 2)  := !![4, 3; 0, -3/2]
    A = L * U := by decide