Cholesky Decomposition Simulator Back
Numerical Methods

Cholesky Decomposition Simulator

Factor a symmetric 3×3 matrix into the product of a lower-triangular matrix and its transpose, A=LLᵀ. Adjust the diagonal and off-diagonal entries to see the positive-definiteness verdict from Sylvester's criterion, every entry of the factor L, the determinant and the operation count — half that of LU decomposition.

Parameters
Set the three diagonal and three off-diagonal entries of the symmetric matrix A. Symmetry is enforced automatically, so A[i][j]=A[j][i].
Diagonal entry a₁₁
Diagonal entry a₂₂
Diagonal entry a₃₃
Off-diagonal a₁₂ = a₂₁
Off-diagonal a₁₃ = a₃₁
Off-diagonal a₂₃ = a₃₂
Large off-diagonal entries make the matrix lose positive-definiteness.
Results
Positive-definite
L₁₁
L₂₁
L₂₂
L₃₃
Determinant det(A)
Matrix A and lower factor L — factorisation animation

The left grid is the input matrix A, the right grid is the lower-triangular factor L. Each cell is colour-shaded by magnitude, and the L entries are highlighted in the computation order L₁₁→L₂₁→L₃₁→L₂₂→L₃₂→L₃₃. If A is not positive-definite, the panel says so.

Leading principal minors (Sylvester's criterion)
Operation-count comparison (Cholesky, LU, inversion)
Theory & Key Formulas

$$A=LL^{\mathsf T},\qquad L_{jj}=\sqrt{A_{jj}-\sum_{k\lt j}L_{jk}^2}$$

A symmetric positive-definite matrix A factors into a lower-triangular matrix L and its transpose Lᵀ. Each diagonal entry L_jj is the square root of the corresponding A diagonal entry minus the sum of squares already computed in that row.

$$L_{ij}=\frac{1}{L_{jj}}\Big(A_{ij}-\sum_{k\lt j}L_{ik}L_{jk}\Big)\quad(i\gt j)$$

Each off-diagonal entry L_ij (i>j) is A_ij minus the sum of products of previously computed entries, divided by the diagonal L_jj. If a value under the square root becomes zero or negative, the matrix is not positive-definite.

$$\det(A)=(L_{11}L_{22}L_{33})^2,\qquad \text{cost}\approx \tfrac{n^3}{3}$$

The determinant equals the square of the product of the diagonal entries of L. The cost of Cholesky is about n³/3 — exactly half that of LU decomposition (about 2n³/3).

What is the Cholesky Decomposition Simulator?

🙋
I've heard the name "Cholesky decomposition", but what does the computation actually do?
🎓
Roughly, it rewrites a matrix A as "a lower-triangular matrix L times its transpose Lᵀ" — that is, A=LLᵀ. It is a lot like factoring a number into a square root: it is the matrix version of √. Just as you split 4 into 2×2, you split A into L×Lᵀ. Once you have that, the linear system Ax=b can be solved quickly in two triangular sweeps.
🙋
Can any matrix be decomposed? When I raise the off-diagonal a₂₃ on the left, it suddenly turns red and says "not positive-definite".
🎓
Good catch. Cholesky only works for matrices that are both symmetric and positive-definite. Symmetric means A[i][j]=A[j][i]; positive-definite means xᵀAx is always positive for any vector x you throw at it. Push the off-diagonals too far and the matrix stops being positive-definite — then the factorisation tries to take the square root of a negative number and breaks down. So the red chart you saw is exactly the signal that you have entered the "cannot be factored" region.
🙋
How do you tell whether a matrix is positive-definite? Testing every vector by hand is impossible.
🎓
That is where Sylvester's criterion comes in. You compute the determinants of the small squares growing from the top-left corner — the leading principal minors M1, M2, M3 — and if all three are positive, the matrix is positive-definite. The bar chart below shows exactly those M1, M2 and M3. Even better: the Cholesky factorisation itself is the cheapest test. If a value under the square root goes zero or negative mid-way, you know immediately the matrix is not positive-definite — no separate check needed.
🙋
I also learned about LU decomposition. When do I pick Cholesky over LU?
🎓
LU decomposition is the all-rounder — it works on any square matrix. Cholesky is the specialised version for symmetric positive-definite matrices, and being specialised makes it faster. LU costs about 2n³/3 operations; Cholesky uses symmetry and costs about n³/3 — exactly half. Look at the "operation-count comparison" chart below: even against a full inversion at n³, Cholesky is the cheapest. So the rule of thumb is: if you know the matrix is symmetric positive-definite, reach straight for Cholesky.
🙋
If it's that fast and stable, is it really used in actual analysis software?
🎓
Absolutely. Finite element method (FEM) stiffness matrices are usually symmetric positive-definite, so Cholesky decomposition is at the heart of the direct solver for those systems. It also shows up in the least-squares normal equations, in the covariance matrices behind Kalman filters and Gaussian processes, and in sampling correlated random numbers — anywhere a symmetric positive-definite matrix appears. It is unglamorous, but it is a workhorse of numerical computing.

Frequently Asked Questions

The Cholesky decomposition A = L·Lᵀ exists only for symmetric positive-definite (SPD) matrices. Symmetric means A[i][j]=A[j][i]; positive-definite means xᵀAx>0 for every non-zero vector x. In practice you can verify positive-definiteness with Sylvester's criterion: all leading principal minors must be positive. Cholesky does not apply to non-symmetric or non-positive-definite matrices — for those you use LU decomposition or LDLᵀ decomposition instead.
For a symmetric matrix, positive-definiteness can be checked with Sylvester's criterion: all leading principal minors must be positive. For a 3×3 matrix, compute M1=a11, M2=a11·a22−a12² and M3=det(A); the matrix is positive-definite if all three are positive. This tool plots M1, M2 and M3 as a bar chart. In fact, attempting the Cholesky factorisation is itself the cheapest positive-definiteness test: if a value under the square root becomes zero or negative, the matrix is not positive-definite.
LU decomposition factors a general square matrix as A=LU, while Cholesky is specialised for symmetric positive-definite matrices and factors A=LLᵀ. By exploiting symmetry it needs only about n³/3 operations — exactly half the roughly 2n³/3 of LU decomposition — and stores only the lower triangle. Cholesky also requires no pivoting and is numerically stable, so it is preferred over LU for symmetric positive-definite systems.
Finite element method (FEM) stiffness matrices are usually symmetric positive-definite, and the standard direct solver for the resulting system Ku=f is Cholesky decomposition. It is also used for the least-squares normal equations AᵀA x = Aᵀb, for the covariance matrices that appear in Gaussian processes and Kalman filters, and for sampling correlated random numbers — wherever a symmetric positive-definite matrix appears.

Real-World Applications

Finite element structural analysis: The global stiffness matrix K assembled in a linear static analysis becomes symmetric positive-definite once the supports are applied correctly. Cholesky decomposition — and its sparse variant, sparse Cholesky — is the core of the direct solver that solves Ku=f. When several load cases change only the load vector f for the same K, the factor L can be reused, so each case is solved quickly with only forward and back substitution.

Least squares and regression: The coefficient matrix AᵀA of the normal equations AᵀA x = Aᵀb that appear when fitting a model to data is symmetric and positive-semidefinite. If A has full rank it is positive-definite and can be solved stably and quickly with Cholesky. This is used in polynomial fitting, sensor calibration, survey network adjustment and any over-determined system.

Kalman filters and Gaussian processes: The covariance matrices handled in state estimation and machine learning are symmetric positive-definite. Numerically stable implementations of the Kalman filter (square-root filters) update the Cholesky factor directly. In Gaussian process regression, the Cholesky factor of the kernel matrix is used both to compute the predictive distribution and to evaluate the log-likelihood.

Sampling correlated random numbers: To draw samples from a multivariate normal distribution N(μ, Σ), you Cholesky-factor the covariance matrix Σ=LLᵀ and form x=μ+Lz from independent standard normal numbers z, which produces random vectors with the desired correlation. This is a fundamental technique in Monte Carlo simulation and quantitative finance risk analysis.

Common Misconceptions and Pitfalls

The most common mistake is assuming "any symmetric matrix can be Cholesky-factored". Cholesky requires positive-definiteness on top of symmetry. If a symmetric matrix has any negative eigenvalues (it is indefinite or negative-definite), a value under the square root goes negative mid-factorisation and the process breaks down. That is why the verdict in this tool flips to "not positive-definite" as you increase the off-diagonal entries. To handle a symmetric but non-positive-definite matrix, use the square-root-free LDLᵀ decomposition or a pivoted factorisation.

Next, the belief that "solving the normal equations AᵀA with Cholesky is always safe". In theory AᵀA is symmetric positive-definite, but if A is ill-conditioned the condition number of AᵀA is its square, which amplifies numerical error. For ill-conditioned least-squares problems, factoring A directly with QR is more stable than the normal equations plus Cholesky. Cholesky being fast is no reason to use it without checking the conditioning.

Finally, the oversimplification that "half the operations means half the run time". The theoretical floating-point operation count of Cholesky is half that of LU, but actual run time depends strongly on the memory-access pattern, cache efficiency and, for sparse matrices, the fill-in (entries that become non-zero during factorisation). For large sparse matrices, how much fill-in you can suppress through node reordering often dominates over the coefficient of the operation count. Treat "n³/3" as a guide for dense matrices only.

How to Use

  1. Enter symmetric 3×3 matrix coefficients: a11, a22, a33 (diagonal) and a12, a13, a23 (off-diagonal). Use a11Range, a22Range, a33Range sliders for rapid parameter sweeps.
  2. Click Decompose to factor A = LLᵀ where L is lower triangular. The simulator applies Sylvester's criterion: check leading principal minors (1×1, 2×2, 3×3 determinants) to verify positive-definiteness before proceeding.
  3. Read output: L₁₁, L₂₁, L₂₂, L₃₁, L₃₂, L₃₃ factors, plus det(A) and positive-definite status. If det(A) ≤ 0 or any leading minor fails, decomposition halts and flags the constraint violation.

Worked Example

Structural analysis: composite laminate stiffness matrix in MPa. Input a11=12500, a22=10200, a33=9800, a12=2100 (representing transverse-isotropic ply). Leading minors: M₁=12500 (✓), M₂=(12500)(10200)−(2100)²=125,150,900 (✓), M₃≈1.23×10¹¹ (✓). Decomposition yields L₁₁≈111.8, L₂₁≈18.76, L₂₂≈99.23, L₃₃≈98.45, det(A)≈1.23×10¹¹. Positive-definite confirmed; matrix suitable for FEA assembly.

Practical Notes

  1. Ill-conditioned matrices (condition number >10⁶) near singularity: a11=5000, a22=5001, a12=4999 produces numerical drift in L factors. Use higher precision input or reformulate.
  2. Rank-deficient test: a11=4, a22=9, a12=6 yields M₂=0 (singular). Simulator rejects; add perturbation δ=0.01 to a22 to restore positive-definiteness.
  3. Engineering workflow: verify material symmetry (orthotropic/isotropic) before Cholesky. For FEA global stiffness matrices 1000×1000+, preprocessing with Cholesky filters zero-energy modes.