Cholesky Decomposition Calculator
Factor a symmetric positive definite matrix into a lower triangular matrix and its transpose.
What it does
Cholesky decomposition writes a symmetric positive definite matrix as the product of a lower triangular matrix and its transpose. The lower triangular matrix is usually called L, so the statement is A = L L transpose. It is the matrix version of taking a square root.
The method was published by André-Louis Cholesky and later popularised for numerical work. Lecture notes from the University of Illinois Chicago and Chalmers University explain the same construction: compute one row of L at a time, using values already found to keep every square root argument positive when the matrix qualifies.
For a 2 by 2 matrix the steps are short. The first diagonal entry is the square root of A(1,1). The entry below it is A(2,1) divided by that root. The second diagonal entry is the square root of A(2,2) minus the square of the entry below it.
This tool accepts the lower triangle of a 2 by 2 or 3 by 3 matrix. It reports each entry of L and stops with a clear message if the matrix is not positive definite, which happens when a square root argument is zero or negative.
Cholesky factors are used to solve linear systems, to draw correlated random samples and in optimisation. They only apply to matrices that pass the symmetry and positive definite conditions.
How to use
- Choose a 2 by 2 or 3 by 3 matrix from the size selector.
- Enter the entries of the lower triangle, including the diagonal. The matrix is assumed to be symmetric.
- For a 2 by 2 matrix, only A(1,1), A(2,1) and A(2,2) are used.
- For a 3 by 3 matrix, add A(3,1), A(3,2) and A(3,3).
- Read the entries of L below the main result. Entries above the diagonal are zero.
- Multiply L by its transpose on paper to confirm that you recover the input matrix.
Formula
- A
- A symmetric matrix with the positive definite property.
- L
- The lower triangular Cholesky factor.
- L transpose
- The transpose of L, an upper triangular matrix.
- A(i,j)
- The matrix entry in row i and column j.
The engine reads the lower triangle only, because symmetry fixes the upper triangle. Each diagonal step checks that the value under the square root is strictly positive. If it is not, the matrix is not positive definite and no real Cholesky factor exists.
Worked example
Example: a 2 by 2 factor
A has lower triangle A(1,1) = 4, A(2,1) = 2 and A(2,2) = 5.
- The first diagonal entry is L11 = sqrt(4) = 2.000000.
- The entry below it is L21 = A(2,1)/L11 = 2/2 = 1.000000.
- The second diagonal is L22 = sqrt(5 - 1²) = sqrt(4) = 2.000000.
- The tool reports L11 2.000000, L21 1.000000 and L22 2.000000, with order 2.
- Check: L times L transpose gives [[4, 2], [2, 1 + 4]] = [[4, 2], [2, 5]], the input matrix.
- The 3 by 3 default adds L31 = 0.500000, L32 = 0.250000 and L33 = 2.384848.
Reference table
| Entry | Formula | Value in the 2 by 2 example |
|---|---|---|
| L11 | sqrt(A11) | 2.000000 |
| L21 | A21 / L11 | 1.000000 |
| L22 | sqrt(A22 - L21²) | 2.000000 |
| L31 | A31 / L11 | 0.500000 in the 3 by 3 example |
| L32 | (A32 - L31 L21) / L22 | 0.250000 in the 3 by 3 example |
| L33 | sqrt(A33 - L32² - L31²) | 2.384848 in the 3 by 3 example |
Limits
- The tool handles 2 by 2 and 3 by 3 matrices only.
- The matrix must be symmetric. Only the lower triangle is entered, so the upper triangle is assumed to match.
- A matrix that is not positive definite produces an error instead of a factor.
- Results use ordinary floating point arithmetic and are shown to six decimal places.
Common mistakes
- Entering an upper triangle value where a lower triangle value belongs.
- Trying to factor a matrix with a zero or negative leading diagonal.
- Assuming any symmetric matrix works, when positive definiteness is also required.
- Forgetting that L has zeros above the diagonal when checking the product.
- Entering a singular matrix, which fails at the second or third square root.
Try it yourself
Quick checks. Answers sit tucked under each question.
For A = [[4,2],[2,5]], what is L?
L11 = 2, L21 = 1 and L22 = 2. The product L L transpose is the original matrix.
What happens if A(1,1) is zero?
The tool reports an error, because sqrt(0) cannot be divided into A(2,1) and the matrix is not positive definite.
Why is no pivoting needed?
For a positive definite matrix every leading square root argument is strictly positive, so the construction is stable without row swaps.
Questions
What is Cholesky decomposition used for?
Solving linear systems, matrix square roots, simulation of correlated variables and numerical optimisation.
What matrices can be factored?
Real symmetric positive definite matrices. The tool checks the diagonal conditions as it goes.
How is it different from LU factorisation?
Cholesky needs no pivoting and roughly half the arithmetic because it uses the symmetry of the matrix.
Why do I only enter the lower triangle?
The upper triangle equals the transpose of the lower one for a symmetric matrix, so entering it would be redundant.
Is the factor unique?
Yes, when L is required to be lower triangular with strictly positive diagonal entries.
What if the matrix is only positive semidefinite?
A square root argument can reach zero. The tool stops because it requires a strictly positive definite matrix.
Sources
- University of Illinois Chicago, MCS 471: The Cholesky factorization
- Chalmers University, Applied Numerical Linear Algebra Lecture 6