Understanding the Cholesky decomposition calculator — concept and principle
This calculator factors a symmetric positive-definite matrix A as A = L·Lᵀ, with L lower triangular and a positive diagonal. It shows L, its transpose, the diagonal, the determinant and whether the matrix is positive definite. Use it for linear algebra homework, solving least-squares problems or simulating correlated random variables.
How it is calculated
Column by column, for j = 1 … n:
l_jj = √(a_jj − Σ_(k<j) l_jk²)
l_ij = (a_ij − Σ_(k<j) l_ik l_jk) ÷ l_jj, for rows i below j
det(A) = (l₁₁ × l₂₂ × … × l_nn)²
- If a number under a square root is zero or negative, A is not positive definite and the page says so.
The principle
A symmetric matrix is positive definite when xᵀAx > 0 for every non-zero vector x; covariance matrices and the normal equations of least squares are typical examples. Such a matrix behaves like a positive number, and just as a positive number has a square root, A has a "square root" L with A = L·Lᵀ. The factorization is unique when the diagonal of L is positive. Because it uses the symmetry, Cholesky takes about half the work of an LU factorization, and failure of a square root is itself a test for positive definiteness.
Worked example
Default input: A = [4 12 −16; 12 37 −43; −16 −43 98].
- l₁₁ = √4 = 2; l₂₁ = 12 ÷ 2 = 6; l₃₁ = −16 ÷ 2 = −8.
- l₂₂ = √(37 − 6²) = √1 = 1; l₃₂ = (−43 − (−8)(6)) ÷ 1 = 5.
- l₃₃ = √(98 − (−8)² − 5²) = √9 = 3.
- L = [2 0 0; 6 1 0; −8 5 3] and Lᵀ = [2 6 −8; 0 1 5; 0 0 3]; diagonal 2, 1, 3.
- det(A) = (2 × 1 × 3)² = 36; positive definite: yes — every pivot was positive.
How to read the result
To solve A x = b, solve L y = b by forward substitution and then Lᵀ x = y by back substitution. To simulate correlated normal variables with covariance A, multiply a vector of independent standard normals by L. A failed decomposition means the matrix is not positive definite, often because of rounding or an inconsistent covariance estimate.
Common mistakes
- Entering a matrix that is not symmetric.
- Taking square roots of the original diagonal without subtracting earlier terms.
- Confusing L·Lᵀ with Lᵀ·L.
- Expecting a result for a positive semi-definite matrix with a zero pivot.
Frequently asked questions
What is a Cholesky decomposition used for?
Solving symmetric positive-definite systems, least squares and simulating correlated variables.
How do I know if a matrix is positive definite?
If the Cholesky decomposition succeeds with all positive pivots, it is.
Is the decomposition unique?
Yes, when the diagonal entries of L are required to be positive.
Sources: E. W. Weisstein, "Cholesky Decomposition", Wolfram MathWorld