terican

Last verified · v1.0

Calculator · math

Cholesky Decomposition Calculator

Compute the lower triangular Cholesky factor L of a symmetric positive definite matrix A where A = LL^T. Supports 2x2 and 3x3 matrices.

FreeInstantNo signupOpen source

Inputs

Cholesky Output Value

Explain my result

0/3 free

Get a plain-English breakdown of your result with practical next steps.

Cholesky Output Value

The formula

How the
result is
computed.

What Is Cholesky Decomposition?

The Cholesky decomposition factors any symmetric positive definite (SPD) matrix A into the product A = LLT, where L is a unique lower triangular matrix with strictly positive diagonal entries. Named after French military officer André-Louis Cholesky (1875–1918), who developed the technique for geodetic surveying calculations, this factorization is the cornerstone of numerical linear algebra and appears throughout scientific computing, statistics, and machine learning. Because it exploits the symmetry of A, Cholesky decomposition requires roughly half the arithmetic of a general LU factorization and is numerically the most stable direct method for SPD systems.

Prerequisites: Symmetric Positive Definite Matrices

The Cholesky decomposition exists and is unique if and only if the input matrix satisfies two conditions simultaneously:

  • Symmetry: Every off-diagonal entry satisfies aij = aji, so A = AT. The calculator enforces this by accepting a single value for each symmetric pair (e.g., A[1,2] = A[2,1]).
  • Positive definiteness: All eigenvalues are strictly positive, equivalently xTAx > 0 for every non-zero real vector x. A practical test known as Sylvester’s criterion requires all leading principal minors to be positive: for a 2×2 matrix, a11 > 0 and a11a22 − a122 > 0; for a 3×3 matrix, additionally det(A) > 0.

If either condition fails, the algorithm encounters the square root of a non-positive number during computation, and no real Cholesky factor exists. Real-world covariance matrices from multivariate data and Hessian matrices at strict local minima are naturally SPD.

The Cholesky-Banachiewicz Formulas

Given an n×n SPD matrix A, the entries of the lower triangular factor L are computed column by column using two recurrences. The diagonal entries are:

Lii = √(aii − ∑k=1i−1 Lik2)

The sub-diagonal entries (j > i) are:

Lji = (aji − ∑k=1i−1 LjkLik) / Lii

All entries strictly above the main diagonal of L are zero. According to Cornell CS4210 (Golub & Van Loan, Chapter 7) and UCLA EE133A Lecture 12 on Cholesky Factorization, this algorithm requires approximately n3/3 floating-point multiply-add operations — roughly half the cost of LU factorization — making it the standard solver whenever the coefficient matrix is SPD.

Step-by-Step: 2×2 Matrix

For A = [[a11, a12], [a12, a22]], compute three non-zero entries of L in order:

  • L11 = √a11
  • L21 = a12 / L11
  • L22 = √(a22 − L212)

Step-by-Step: 3×3 Matrix

After completing the 2×2 block, three additional sub-diagonal entries extend the factor:

  • L31 = a13 / L11
  • L32 = (a23 − L31 ⋅ L21) / L22
  • L33 = √(a33 − L312 − L322)

Worked Numerical Example

Let A = [[4, 2], [2, 3]]. First verify positive definiteness: a11 = 4 > 0 and det(A) = (4)(3) − (2)2 = 8 > 0. Apply the formulas:

  • L11 = √4 = 2.0000
  • L21 = 2 / 2 = 1.0000
  • L22 = √(3 − 12) = √2 ≈ 1.4142

Verification: [[2, 0], [1, 1.4142]] × [[2, 1], [0, 1.4142]] = [[4, 2], [2, 3]] = A. The matrix determinant equals the square of the product of diagonal entries: (2 × 1.4142)2 = 8, consistent with direct computation.

Numerical Stability

The Cholesky algorithm is backward stable for SPD matrices: the computed factor L satisfies (A + E) = LLT where the perturbation E is small relative to machine precision. No row interchanges (pivoting) are needed, which simplifies implementation and avoids the fill-in overhead that partial pivoting introduces in LU. A closely related variant, the LDLT decomposition, avoids square roots entirely by writing A = LDLT with D diagonal, offering a modest speed advantage on architectures where square roots are expensive.

Key Applications

  • Solving linear systems: Factor A = LLT, forward-substitute to solve Ly = b, then back-substitute to solve LTx = y — two O(n2) triangular solves after an O(n3/3) factorization.
  • Monte Carlo simulation: Generate correlated random vectors via x = Lz, where z is a vector of independent standard normal draws; the sample covariance of x matches the target matrix A.
  • Kalman filtering: Maintain numerical positive definiteness of covariance matrices across hundreds of prediction-update cycles in navigation and robotics.
  • Optimization: Compute Newton search directions efficiently when the Hessian at the current iterate is confirmed positive definite.
  • Gaussian process regression: Evaluate multivariate normal log-likelihoods and draw posterior samples in Bayesian machine learning pipelines, where the kernel (covariance) matrix is SPD by construction.
  • Portfolio risk: Decompose asset return covariance matrices to sample correlated return scenarios and compute portfolio variance in O(n) per draw after factorization.

Reference

Frequently asked questions

What is a Cholesky decomposition calculator and what does it compute?
A Cholesky decomposition calculator accepts the entries of a symmetric positive definite matrix A and returns the lower triangular factor L satisfying A = LL^T. Each diagonal entry L_ii equals the square root of a_ii minus the sum of squares of all earlier entries in that row, and each sub-diagonal entry L_ji is obtained by a division involving L_ii. The resulting factor L is used to solve linear systems, generate correlated random samples for Monte Carlo methods, and compute the matrix determinant as the square of the product of all diagonal entries of L.
What types of matrices are valid inputs for Cholesky decomposition?
Only symmetric positive definite matrices qualify as valid inputs. Symmetry requires every off-diagonal pair to satisfy a_ij = a_ji, which is why the calculator accepts a single value for each such pair. Positive definiteness requires all leading principal minors to be positive: for a 2x2 matrix, a_11 > 0 and a_11*a_22 - a_12^2 > 0. Real covariance matrices from multivariate data and Hessian matrices evaluated at strict local minima of smooth functions are naturally symmetric positive definite and are always valid inputs.
How do you manually compute the Cholesky factor of a 2x2 matrix?
For a 2x2 symmetric positive definite matrix [[a, b],[b, d]], three sequential steps produce L. First, set L_11 = sqrt(a). Second, compute L_21 = b / L_11. Third, set L_22 = sqrt(d - L_21^2). As a concrete example, given A = [[9, 3],[3, 5]]: L_11 = sqrt(9) = 3, L_21 = 3/3 = 1, L_22 = sqrt(5 - 1) = 2. The Cholesky factor is L = [[3, 0],[1, 2]], and multiplying L by its transpose recovers [[9, 3],[3, 5]] exactly.
What are the most important real-world applications of Cholesky decomposition?
Cholesky decomposition drives six major application areas. In Monte Carlo simulation, multiplying L by a vector of independent standard normal draws produces correlated random variables matching the target covariance. In Kalman filtering, the Cholesky factor maintains numerical positive definiteness of covariance matrices across hundreds of update steps in robotics and navigation. In Gaussian process regression, it evaluates multivariate normal log-likelihoods in O(n^3) time. In finite-element structural solvers, it handles large symmetric stiffness systems. In portfolio optimization, it decomposes asset covariance matrices for efficient risk scenario sampling. In nonlinear optimization, it computes Newton search directions when the Hessian is positive definite.
How does Cholesky decomposition differ from LU decomposition in efficiency and applicability?
LU decomposition factors any invertible square matrix A into a lower triangular L and upper triangular U, requiring roughly n^3/2 multiply-add operations and typically needing partial pivoting for numerical stability. Cholesky decomposition exploits symmetry and positive definiteness to produce A = LL^T in approximately n^3/3 operations, about half the cost, with no pivoting required. The restriction is that Cholesky applies only to symmetric positive definite matrices, whereas LU handles the general invertible case. For SPD systems such as covariance matrices and positive definite Hessians, Cholesky is always the preferred choice.
What causes Cholesky decomposition to fail and how can the problem be resolved?
Failure occurs when the expression under the square root in the diagonal formula, a_ii minus the accumulated sum of squared earlier row entries, becomes zero or negative. This indicates the matrix is not positive definite. Common causes include a matrix with a zero or negative eigenvalue such as a singular covariance matrix built from collinear variables, numerical rounding that makes a nearly singular matrix appear indefinite, or incorrectly entered off-diagonal values that violate symmetry. Resolution strategies include verifying positive definiteness via Sylvester's criterion before factoring, adding a small regularization term epsilon times the identity matrix, or removing linearly dependent rows and columns.