How to use the cholesky decomposition calculator
- Enter the symmetric matrix, one row per line. Up to 8 by 8.
- Optionally enter the right-hand side b to solve A x = b.
- Read the determinant, the lower triangular factor L and its transpose, and the solution if you gave b.
- If the matrix is not symmetric or not positive definite, the page says which entry or pivot causes the problem.
Formula
A = L L^T, with L lower triangular and positive numbers on its diagonal
L(j,j) = sqrt(A(j,j) - sum of L(j,k)^2 for k < j)
L(i,j) = (A(i,j) - sum of L(i,k) L(j,k) for k < j) / L(j,j) for i > j
det A = (product of the diagonal of L) squared; solve L y = b forward, then L^T x = y backward
A matrix is positive definite exactly when this process never takes the square root of a number that is zero or negative.
A textbook 3 by 3 and a small system
The matrix with rows (4, 12, -16), (12, 37, -43), (-16, -43, 98) factors with L having rows (2, 0, 0), (6, 1, 0), (-8, 5, 3). Multiplying L by its transpose gives the matrix back, and the determinant is (2 x 1 x 3) squared = 36.
For the matrix with rows (4, 2) and (2, 3) and the right side (2, 5), L has rows (2, 0) and (1, 1.41421), the determinant is 8, and the solution is x = (-0.5, 2). The matrix with rows (1, 2) and (2, 1) is symmetric but not positive definite; the second pivot is 1 - 4 = -3, and the page reports it.
Why use Cholesky
Cholesky is the standard method for solving systems with a symmetric positive definite matrix. It takes about half the work of general elimination, needs no row swapping, and is numerically stable. It also gives a quick test: if the factorization fails, the matrix is not positive definite. Covariance matrices in statistics and the stiffness matrices of structures are common examples.
For general matrices, use the matrix calculator for inverses and determinants with exact fractions, or the SVD calculator to study rank and conditioning.
Reading the results
The diagonal of L holds the square roots of the pivots, so a very small diagonal entry means the matrix is nearly singular. The determinant comes free from the diagonal. When you add b, the page performs two quick substitutions, one forward through L and one backward through the transpose, and shows the solution.
The page checks symmetry first, within a tiny tolerance for rounding. If you need a least squares fit from data, the linear regression calculator solves the normal equations for a line.
Assumptions and limits
- The matrix is real, square and at most 8 by 8.
- Symmetry is checked with a relative tolerance of 1e-9.
- Results are floating point numbers shown to 6 significant digits.
- A positive semidefinite matrix with a zero pivot is reported as not positive definite.
Frequently asked questions
What is a Cholesky factor?
A lower triangular matrix L with positive diagonal such that L times its transpose equals the matrix.
What is a positive definite matrix?
A symmetric matrix for which x^T A x is above 0 for every nonzero x. Equivalently, all its pivots in the Cholesky process are positive.
How do I solve A x = b?
Enter b. The page solves L y = b and then L^T x = y, and shows x.
Why does it say the pivot is negative?
The matrix is symmetric but has a direction in which it acts like a negative number, so it cannot be written as L L^T with real numbers.