Advertisement
Advertisement
LINEAR ALGEBRA

Cholesky Decomposition Calculator — factor A into L times L transpose

Enter a symmetric matrix and get its lower triangular Cholesky factor, the determinant, and a written explanation when the matrix is not positive definite.

One row per line, values separated by spaces, commas or tabs. Must be square, symmetric and between 2×2 and 8×8.
The internal arithmetic is full double precision; this only controls how the factor is displayed.
Determinant of A
 
Matrix size
Symmetric?
Positive definite?
Largest reconstruction error
Factor L:
Working:
Tip: the reconstruction error is L multiplied by its own transpose, compared entry by entry against the matrix you entered. If it is not effectively zero, the factorisation has broken down.
Advertisement

The Cholesky decomposition calculator above factors a symmetric positive definite matrix A into a lower triangular matrix L such that L multiplied by its own transpose reproduces A exactly. It reports the factor itself, the determinant, and a verification of the product. Where the matrix is not symmetric or not positive definite, it explains in words which condition failed and at which pivot, rather than returning a page of NaN.

Arb Digital publishes it because Cholesky is the workhorse factorisation of applied numerical work — it appears wherever a covariance matrix, a stiffness matrix or a normal-equations system does — and because the failure case is as instructive as the success case. Our LU decomposition calculator handles the general square matrix with two triangular factors and partial pivoting; this page handles the symmetric positive definite special case with one factor, at about half the cost.

What This Cholesky Decomposition Calculator Does

It runs the standard column-by-column algorithm on any square matrix from 2×2 up to 8×8. Before starting it checks symmetry, because the decomposition is defined only for symmetric matrices and a non-symmetric input would silently produce a factor that reproduces only half the entries. It then computes each diagonal entry as a square root and each below-diagonal entry as a division by that root.

Positive definiteness is not checked in advance. It does not need to be, because the algorithm itself is the test: if every square root has a strictly positive radicand, the matrix is positive definite, and if any radicand comes out zero or negative, it is not. That equivalence is one of the neatest facts in numerical linear algebra, and it means the tool never has to compute eigenvalues to tell you the answer.

Alongside the factor it reports the determinant, which is the product of the squared diagonal entries of L, the size of the matrix, and the largest absolute difference between L times L transpose and the matrix you entered. That last figure should be zero or a value at the level of floating-point rounding, and it is displayed precisely so you can see that it is.

How to Use It

  1. Enter the matrix one row per line with values separated by spaces, commas or tabs. Every row must have the same number of entries as there are rows.
  2. Check the symmetry indicator in the grid. If it says no, the tool names the entry pair that disagrees so you can correct it.
  3. Read the factor L in the panel below the grid. It is lower triangular, so everything above the diagonal is zero by construction.
  4. Confirm the reconstruction error is effectively zero. That is your proof the factorisation is right, not merely plausible.
  5. Set the decimal places to whatever your working requires. The arithmetic is always done at full precision regardless.

The Formula and How It Is Calculated

The algorithm processes one column at a time. The diagonal entry is Ljj = √(Ajj − ∑k<j Ljk²), and each entry below it is Lij = (Aij − ∑k<j LikLjk) ÷ Ljj. Everything above the diagonal is zero. Wolfram MathWorld's page on the Cholesky decomposition states the same result in the transposed convention, as an upper triangular U with A equal to U transpose times U, which is the mirror image of what this page produces.

Work the default 3×3 through by hand. A has first row 4, 12, −16. So L₁₁ = √4 = 2, L₂₁ = 12 ÷ 2 = 6, and L₃₁ = −16 ÷ 2 = −8. Second column: L₂₂ = √(37 − 6²) = √1 = 1, and L₃₂ = (−43 − (−8)(6)) ÷ 1 = (−43 + 48) = 5. Third: L₃₃ = √(98 − 64 − 25) = √9 = 3.

So L is the lower triangular matrix with rows (2, 0, 0), (6, 1, 0) and (−8, 5, 3). Multiply it by its transpose and the first row gives 4, 12 and −16; the second gives 12, 36+1 = 37 and −48+5 = −43; the third gives −16, −43 and 64+25+9 = 98. That is A exactly. The determinant is (2 × 1 × 3)² = 36, which our determinant calculator confirms by cofactor expansion.

Advertisement

When the Matrix Is Not Positive Definite

Press the second preset and the tool loads the matrix with rows (1, 2) and (2, 1). The first pivot is fine: L₁₁ = 1 and L₂₁ = 2. The second pivot asks for the square root of 1 − 4 = −3, which has no real value. The matrix is symmetric but not positive definite, and the tool says so, naming the pivot and the negative radicand rather than printing NaN and leaving you to guess.

The equivalence behind that behaviour is worth stating clearly. A symmetric matrix is positive definite if and only if the Cholesky algorithm completes with every radicand strictly positive. Wolfram MathWorld's page on positive definite matrices gives the equivalent characterisations — all eigenvalues positive, all leading principal minors positive — and the running determinant of the leading blocks is exactly what the failing radicand reflects.

The semi-definite boundary case, where a radicand is exactly zero, is worth treating separately. The matrix has a zero eigenvalue, is singular, and the standard algorithm divides by zero on the next column. In floating point the radicand is almost never exactly zero, so a nearly singular matrix produces a tiny positive pivot and a factor with enormous entries instead of an outright failure. That is the case to watch for in practice: a successful decomposition with a suspiciously small diagonal entry is a warning, not a clean result. Our eigenvalue calculator and matrix rank calculator both give a second opinion when a pivot looks marginal.

Why This Factorisation Is Preferred Where It Applies

Three reasons, and they compound. It costs about half of an LU decomposition, roughly n³/3 operations against 2n³/3, because symmetry means only one triangle has to be computed and stored. It needs no pivoting at all: a symmetric positive definite matrix is unconditionally stable under this algorithm, which removes the row-swapping bookkeeping that general LU requires. And it is numerically backward stable without qualification, which is a stronger guarantee than general Gaussian elimination offers.

The consequence is that it is used almost everywhere the conditions hold. Solving the normal equations in least squares fitting, evaluating a multivariate normal density, generating correlated random samples from a covariance matrix, finite element structural analysis with a stiffness matrix, and Kalman filtering all reduce to a Cholesky factorisation of a symmetric positive definite matrix. Once you have L, solving A x = b is two triangular solves — forward substitution then back substitution — which our system of equations calculator performs for general systems.

There is also a square-root-free variant, written A = LDL transpose, where L has ones on the diagonal and D is a diagonal matrix. It avoids square roots entirely, which matters on hardware where they are expensive, and it extends to symmetric indefinite matrices where the standard form fails. This tool computes the standard form; the diagonal of D in the variant is the square of the diagonal of L here.

Getting the Input Right

Two input problems account for almost every failure. The first is asymmetry, usually a typing error in one of the mirrored off-diagonal entries. The tool checks every pair and names the first mismatch it finds, which is faster than scanning the matrix by eye. Note that it demands exact equality, so a matrix built from rounded data may be asymmetric at the last decimal place; symmetrise it by averaging A with its transpose before entering it.

The second is a matrix that is not positive definite because of how it was constructed. A sample covariance matrix estimated from fewer observations than variables is always singular, so it cannot be positive definite, and no amount of care in the arithmetic will change that. A correlation matrix assembled by hand from separately estimated pairwise correlations frequently fails too, because the pairwise values are not mutually consistent. In both cases the failure is a real finding about the data rather than a defect in the calculation, and it is the reason this page reports it as a written explanation. Our matrix calculator will transpose and multiply if you want to check the reconstruction independently.

Need a calculation that shows its own verification?

Arb Digital builds free tools that check their answers and explain their failures instead of returning a blank.

Browse All Free Tools Talk To Our Team

Common Mistakes to Avoid

  • Feeding in a non-symmetric matrix — the decomposition is undefined for it, and any tool that returns a factor anyway has quietly ignored half your entries.
  • Confusing the two conventions — some references write A = U transpose times U with U upper triangular. It is the transpose of the same object, not a different result.
  • Ignoring a tiny diagonal entry — a pivot near zero means the matrix is close to singular, and the factor's other entries will be correspondingly enormous.
  • Assuming any symmetric matrix works — symmetry is necessary but nowhere near sufficient. Positive definiteness is the real requirement.
  • Reading a failure as a bug — a covariance matrix that will not factor is telling you something true about the data it came from.

Related Free Tools From Arb Digital

Factor a general square matrix with the LU decomposition calculator, invert one with the matrix inverse calculator, get the determinant with cofactor expansion from the determinant calculator, find the spectrum with the eigenvalue calculator, or build the signed minors with the cofactor matrix calculator. The full free online tools hub lists every linear algebra tool we publish.

Frequently Asked Questions

What conditions must the matrix satisfy?

It must be square, symmetric, and positive definite. Symmetry is checked before the algorithm starts; positive definiteness is tested by the algorithm itself, which succeeds if and only if the matrix has it.

What happens if the matrix is not positive definite?

A square root of a negative number is required at some pivot. The tool stops there and reports which pivot failed and what the negative radicand was, instead of returning NaN.

Is L lower or upper triangular?

Lower, in the convention used here, so A equals L times L transpose. Some references use the upper triangular form instead, which is the transpose of the same factor and contains identical information.

How is the determinant obtained from the factor?

It is the product of the diagonal entries of L, squared. That is far cheaper than a cofactor expansion and is one of the practical reasons the factorisation is computed at all.

Why is Cholesky faster than LU?

Symmetry means only one triangle has to be computed and stored, which halves the work to roughly n cubed over three operations, and no pivoting is needed because the algorithm is unconditionally stable on these matrices.

Does the algorithm need row swaps?

No. For a symmetric positive definite matrix the pivots are always positive and the process is stable without any reordering, which is one of its main advantages over general Gaussian elimination.

What is the LDL variant?

A square-root-free form where L has ones on its diagonal and a separate diagonal matrix D carries the scale. The entries of D are the squares of the diagonal entries produced here.

Why will my covariance matrix not factor?

Usually because it was estimated from fewer observations than variables, which makes it singular, or because it was assembled from pairwise correlations that are not mutually consistent. Both are properties of the data rather than the arithmetic.

This page explains a numerical linear algebra method for educational purposes. Results are computed in double-precision floating point, so a nearly singular matrix may factor successfully while still being unreliable to use.

Advertisement
Advertisement

Take it further