Cholesky Decomposition

March 23, 2026 · View on GitHub

Overview & Motivation

The Cholesky decomposition factors a symmetric positive-definite matrix AA into the product A=LLTA = LL^T, where LL is a lower triangular matrix with positive diagonal entries. This is the matrix equivalent of taking a "square root."

It is approximately twice as fast as LU decomposition for symmetric positive-definite systems and is numerically stable without pivoting. In this library, it is used primarily by the Unscented Kalman Filter to generate sigma points from the state covariance matrix.

Mathematical Theory

Given ARn×nA \in \mathbb{R}^{n \times n} symmetric positive-definite, compute LL such that A=LLTA = LL^T:

Ljj=Ajjk=0j1Ljk2L_{jj} = \sqrt{A_{jj} - \sum_{k=0}^{j-1} L_{jk}^2}

Lij=1Ljj(Aijk=0j1LikLjk),i>jL_{ij} = \frac{1}{L_{jj}} \left( A_{ij} - \sum_{k=0}^{j-1} L_{ik} L_{jk} \right), \quad i > j

Complexity Analysis

OperationTimeSpaceNotes
DecompositionO(n3/6)O(n^3/6)O(n2)O(n^2)Half the cost of general LU decomposition

Step-by-Step Walkthrough

Input: A=[4225]A = \begin{bmatrix} 4 & 2 \\ 2 & 5 \end{bmatrix} (symmetric positive-definite).

Compute LL column by column:

StepFormulaValue
L00L_{00}A00=4\sqrt{A_{00}} = \sqrt{4}$2$
L10L_{10}A10/L00=2/2A_{10} / L_{00} = 2 / 2$1$
L11L_{11}A11L102=51\sqrt{A_{11} - L_{10}^2} = \sqrt{5 - 1}$2$

Result:

L=[2012]L = \begin{bmatrix} 2 & 0 \\ 1 & 2 \end{bmatrix}

Verify: LLT=[2012][2102]=[4225]=ALL^T = \begin{bmatrix} 2 & 0 \\ 1 & 2 \end{bmatrix} \begin{bmatrix} 2 & 1 \\ 0 & 2 \end{bmatrix} = \begin{bmatrix} 4 & 2 \\ 2 & 5 \end{bmatrix} = A

Pitfalls & Edge Cases

  • Non-positive-definite input. If AA is not positive-definite, a diagonal element under the square root will be negative, producing NaN. Always verify the input or add a small regularization A+ϵIA + \epsilon I.
  • Numerical precision. In fixed-point arithmetic, the intermediate sums and square root can lose precision. Use float for the decomposition and convert back if needed.
  • Zero diagonal. A zero or near-zero diagonal in LL indicates a singular or nearly singular matrix.

Variants & Generalizations

  • LDLTLDL^T Decomposition. Avoids the square root by factoring A=LDLTA = LDL^T where DD is diagonal. Preferred in fixed-point arithmetic where sqrt is expensive or imprecise.
  • Cholesky–Banachiewicz vs Cholesky–Crout. Two orderings of the same algorithm: row-oriented (Banachiewicz, used in this implementation) vs column-oriented (Crout). Performance differs by cache access pattern.
  • Incomplete Cholesky. Drops small entries during factorization to produce a sparse approximate factor. Used as a preconditioner for iterative solvers (e.g., conjugate gradient).
  • Rank-1 Update/Downdate. Given the existing factor LL of AA, efficiently compute the factor of A+vvTA + vv^T (or AvvTA - vv^T) in O(n2)O(n^2) without recomputing from scratch. Central to the square-root UKF.
  • Block Cholesky. Exploits block structure in large matrices for better cache utilization and parallelism.

Applications

  • Sigma point generation — The Unscented Kalman Filter uses Cholesky decomposition of the covariance matrix P=LLTP = LL^T to spread sigma points along the principal uncertainty directions.
  • Solving symmetric positive-definite systems — Given Ax=bAx = b, compute LL, then solve Ly=bLy = b (forward substitution) and LTx=yL^Tx = y (back substitution). Twice as fast as general LU.
  • Multivariate normal sampling — To generate xN(μ,Σ)x \sim \mathcal{N}(\mu, \Sigma), compute LL from Σ\Sigma and set x=μ+Lzx = \mu + Lz where zN(0,I)z \sim \mathcal{N}(0, I).
  • Least squares — The normal equations ATAx=ATbA^TAx = A^Tb produce a symmetric positive-definite system solvable via Cholesky.
  • Optimization — Newton-type methods with positive-definite Hessians use Cholesky to compute search directions.

Connections to Other Algorithms

AlgorithmRelationship
Unscented Kalman FilterUses Cholesky to generate sigma points from the covariance matrix
Gaussian EliminationGeneral-purpose alternative; does not exploit symmetry

References & Further Reading

  • Golub, G.H. and Van Loan, C.F., Matrix Computations, 4th ed., Johns Hopkins University Press, 2013.
  • Press, W.H. et al., Numerical Recipes, 3rd ed., Cambridge University Press, 2007 — Section 2.9.