Linear AlgebraMatrix FactorisationNumerical MethodsMonte Carlo

LU and Cholesky Factorisation

Module 2 of 522 min readLevel: Medium

Setup

The central operation: solving Ax=bAx = b

Almost every numerical routine in quantitative finance reduces to solving a linear system. Yield curve bootstrapping solves Ax=bAx = b for discount factors. Greeks computed by bump-and-reval solve for a perturbed price. Calibration via Gauss-Newton solves the normal equations JJδ=JrJ^\top J \delta = -J^\top r. Even generating correlated random variables for Monte Carlo requires factorising a covariance matrix.

The naïve approach — computing A1A^{-1} explicitly and then forming A1bA^{-1}b — is both slower and less numerically stable than direct factorisation. The standard alternatives are:

  • LU factorisation with partial pivoting: general square AA, O(n3/3)O(n^3/3) flops.
  • Cholesky factorisation: symmetric positive definite AA, O(n3/6)O(n^3/6) flops — twice as fast as LU, always stable without pivoting.
INSIGHT

Why this matters on a derivatives desk. Cholesky factorisation of the covariance matrix Σ=LL\Sigma = LL^\top is the backbone of correlated Monte Carlo simulation. If you call np.linalg.cholesky or LAPACK dpotrf in a pricing library, you are using Cholesky. If it throws an error ("matrix is not positive definite"), you have a broken covariance matrix — and you need to know why to fix it.

Assumptions

  • ARn×nA \in \mathbb{R}^{n \times n} is square. For LU: assume AA is non-singular (otherwise partial pivoting detects the singularity). For Cholesky: assume AA is symmetric positive definite (SPD).
  • All arithmetic is in exact real arithmetic unless otherwise stated; floating-point effects are discussed in Limitations.
  • Conventions: LU factorisation produces PA=LUPA = LU where PP is a permutation matrix, LL is unit lower triangular (diagonal entries all 1), and UU is upper triangular. Cholesky produces A=LLA = LL^\top where LL is lower triangular with positive diagonal.

Theory

1. LU Factorisation

The idea is systematic Gaussian elimination: reduce AA to upper triangular form UU by applying elementary row operations, then record those operations as a lower triangular matrix LL.

DEFINITION

Definition 1.1 (LU factorisation). An LU factorisation of ARn×nA \in \mathbb{R}^{n \times n} is a decomposition A=LUA = LU where LL is unit lower triangular (lower triangular with 1s on the diagonal) and UU is upper triangular.

With partial pivoting: PA=LUPA = LU, where PP is a permutation matrix that reorders the rows of AA to place the largest element in each column on the diagonal before eliminating — improving numerical stability.

Algorithm (Gaussian elimination with partial pivoting):

At step kk (for k=1,,n1k = 1, \ldots, n-1):

  1. Find the row pkp \geq k with the largest absolute value in column kk: p=argmaxjkAjkp = \arg\max_{j \geq k} |A_{jk}| (partial pivot).
  2. Swap rows kk and pp in AA.
  3. For each row i>ki > k: compute the multiplier ik=Aik/Akk\ell_{ik} = A_{ik} / A_{kk} and subtract ik\ell_{ik} times row kk from row ii.
  4. Store ik\ell_{ik} in the lower triangular part of LL.

After n1n-1 steps, AA has been transformed to UU and the multipliers fill LL.

THEOREM

Theorem 1.2 (Existence of LU with partial pivoting). For any non-singular ARn×nA \in \mathbb{R}^{n \times n}, there exists a permutation matrix PP such that PA=LUPA = LU with LL unit lower triangular, UU upper triangular, and Ukk0U_{kk} \neq 0 for all kk. The factorisation is unique given PP.

Solving Ax=bAx = b using LU:

Given PA=LUPA = LU, the system Ax=bAx = b becomes LUx=PbLUx = Pb. Solve in two triangular passes:

  1. Forward substitution: solve Ly=PbLy = Pb for yyO(n2)O(n^2) operations.
  2. Backward substitution: solve Ux=yUx = y for xxO(n2)O(n^2) operations.

Total cost: O(n3/3)O(n^3/3) for the factorisation (done once), then O(n2)O(n^2) per right-hand side. For bootstrapping with multiple right-hand sides (e.g., different rate scenarios), reusing the factorisation is a significant efficiency gain.

EXAMPLE

Example 1.3 (2×2 LU by hand). Let A=(2143)A = \begin{pmatrix} 2 & 1 \\ 4 & 3 \end{pmatrix}.

Step 1: pivot is row 2 (|4| > |2|), so swap: A(4321)A \to \begin{pmatrix} 4 & 3 \\ 2 & 1 \end{pmatrix}.

Step 2: multiplier 21=2/4=1/2\ell_{21} = 2/4 = 1/2. Subtract 12×\frac{1}{2} \times row 1 from row 2: (2,1)12(4,3)=(0,1/2)(2, 1) - \frac{1}{2}(4, 3) = (0, -1/2).

Result: U=(4301/2)U = \begin{pmatrix} 4 & 3 \\ 0 & -1/2 \end{pmatrix}, L=(101/21)L = \begin{pmatrix} 1 & 0 \\ 1/2 & 1 \end{pmatrix}, P=(0110)P = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}.

Verify: LU=(4323/2+(1/2))LU = \begin{pmatrix} 4 & 3 \\ 2 & 3/2 + (-1/2) \cdot \ldots \end{pmatrix}... or more directly: PA=(4321)=LUPA = \begin{pmatrix} 4 & 3 \\ 2 & 1 \end{pmatrix} = LU. ✓

2. Cholesky Factorisation

When AA is symmetric and positive definite, a more efficient and always-stable factorisation exists.

DEFINITION

Definition 2.1 (Cholesky factorisation). The Cholesky factorisation of a symmetric positive definite matrix ARn×nA \in \mathbb{R}^{n \times n} is A=LLA = LL^\top where LL is lower triangular with strictly positive diagonal entries Lii>0L_{ii} > 0.

The factorisation is unique (given the positivity convention for the diagonal).

The full lesson requires Premium

The complete derivation, the C++ / Python implementation, the validation tables, the quiz, and the interview-angle notes are part of Premium. Start a Premium plan to unlock every module in this track.