Cholesky Decomposition Calculator - L L^T Factor Solver
Use this Cholesky Decomposition Calculator to factor a 2x2 or 3x3 symmetric positive definite matrix into the lower triangular L and verify L L^T against A.
Cholesky Decomposition Calculator
Results
What Is Cholesky Decomposition Calculator?
Cholesky Decomposition Calculator factors a 2x2 or 3x3 symmetric positive definite matrix A into the lower triangular matrix L that satisfies A = L L^T, and it reports L, det(A), det(L), and a verification. Use it for linear regression covariance, for solving Ax = b efficiently, for sampling from a multivariate normal distribution, or for checking that a numerical matrix is actually positive definite.
- • Linear regression covariance: Take the X^T X matrix from ordinary least squares and turn it into the Cholesky factor so the normal equations can be solved with forward and back substitution.
- • Sampling from a multivariate normal: Use L to convert standard normal noise into correlated samples from a Gaussian with covariance A by computing L z.
- • Positive definiteness check: Run the factorization on a candidate covariance or kernel matrix; if the algorithm fails, the matrix is not positive definite.
- • Solving Ax = b efficiently: Replace one expensive solve against A with a forward substitution against L followed by a back substitution against L^T.
The Cholesky factor is unique for any symmetric positive definite A, so the output does not depend on a choice of method.
The verification line is not optional. Numerical roundoff can hide an indefinite matrix or corrupt the factor, and recomputing L L^T after the fact catches both cases.
Once L is in hand, the Characteristic Polynomial Calculator can expand the characteristic polynomial of the same matrix and show the eigenvalues that the Cholesky factor implicitly describes.
How Cholesky Decomposition Calculator Works
The Cholesky Decomposition Calculator uses the Cholesky-Banachiewicz algorithm. It walks L row by row and column by column, subtracting the dot product of the already-computed off-diagonal entries before dividing by the previous pivot.
- A: The symmetric input matrix whose upper triangle is read from the form and whose lower triangle is mirrored.
- L: The lower triangular Cholesky factor. The diagonal of L is positive for any positive definite A.
- L[i][i] and L[i][j]: Diagonal and off-diagonal entries computed by the recursive formulas. Each new entry reuses the previously computed entries in the same row and column.
The order matters. Each diagonal pivot L[j][j] is the square root of a positive number, so the algorithm doubles as an indefiniteness test: a negative pivot means the input is not positive definite. A zero pivot means the matrix is positive semi-definite. The implementation stores the upper triangle of A and uses the symmetry assumption a[i][j] = a[j][i]. After L is filled, the calculator multiplies L by L^T and subtracts A entry by entry, and the largest absolute value of that difference becomes the verification error.
Worked example
A = [[4, 2], [2, 5]].
L[0][0] = sqrt(4) = 2. L[1][0] = 2 / 2 = 1. L[1][1] = sqrt(5 - 1) = 2.
L = [[2, 0], [1, 2]], det(A) = 16, det(L) = 4, max error = 0.
The 2x2 pivot sequence finishes in two square roots. L[1][0] is the covariance divided by the first-axis standard deviation.
According to Wikipedia Cholesky decomposition, the Cholesky decomposition of a symmetric positive definite matrix A is the unique lower triangular matrix L with positive diagonal entries such that A = L L^T.
The natural next step is to feed L into a downstream solve, and the Linear Regression Calculator uses the same Cholesky factor pattern to invert the X^T X normal equations with forward and back substitution.
Key Concepts Explained
These four ideas show up in every Cholesky calculation.
Symmetric positive definite
A real matrix A is symmetric positive definite when A equals its own transpose and every nonzero x satisfies x^T A x > 0. The Cholesky decomposition exists if and only if A is symmetric positive definite.
The L L^T factorization
The Cholesky factor L is the lower triangular square root of A. The product L L^T reconstructs A, and det(A) = det(L)^2.
Leading principal minors
A real symmetric matrix is positive definite if and only if every leading principal minor is strictly positive. A negative pivot fails the algorithm; a zero pivot signals a singular matrix.
Cholesky versus LU
A general LU decomposition factors any square matrix into L and U without any symmetry requirement. Cholesky is twice as efficient on a symmetric positive definite matrix.
Symmetric positive definiteness is the precondition for everything in the calculator. If you can only see a partial covariance or kernel matrix that is not symmetric by construction, copy the upper triangle over the lower triangle first. The relation between leading principal minors and pivots is what makes the algorithm an indefiniteness test for free, since a negative pivot fails and a zero pivot yields a zero diagonal in L.
Sampling correlated draws from a multivariate Gaussian is the canonical use case for L, and the Normal Distribution Calculator handles the standard normal side of the same L z transformation.
How to Use This Calculator
Enter the upper triangle of A. The calculator mirrors the entries for you and reports L as a bracket matrix along with the verification error and the two determinants.
- 1 Choose the matrix size: Pick 2x2 for a small symmetric matrix or 3x3 for a fuller problem.
- 2 Fill in the upper triangle: Type a, b, c, d, e, and f in row-major order. In 2x2 mode you only need a, b, and d.
- 3 Read L and the determinants: Use L[1,1], L[2,1], L[2,2] for 2x2 inputs or all six L[i,j] entries for 3x3 inputs.
- 4 Check the verification error: The verification error is the largest absolute difference between A and L L^T. For a clean factorization it should be at or below 1e-10.
- 5 Handle a negative-pivot error: If the calculator reports an indefinite matrix, identify the failing pivot, fix the source data, and re-run.
- 6 Export L for downstream work: Copy L from the result panel and use it for forward substitution, sampling, or any other workflow that needs the lower triangular factor.
For a 2x2 input A = [[4, 2], [2, 5]], the calculator reports L = [[2, 0], [1, 2]] and det(A) = 16, det(L) = 4, which matches det(A) = det(L)^2.
When you want to confirm a column of L by hand, the Vector Magnitude Calculator gives a quick check on the dot product and length you would have computed otherwise.
Benefits of Using This Calculator
The main benefit is replacing a hand-written lower triangular square root routine with a tool that returns the factor and verifies it in the same step.
- • Catches indefinite inputs: The first negative pivot stops the algorithm, so the calculator surfaces ill-posed covariance or kernel matrices before they break a downstream solve.
- • Pairs with linear regression workflows: Feed the X^T X matrix from ordinary least squares into the calculator, copy L out, and use forward and back substitution to solve the normal equations.
- • Supports sampling and simulation: Build correlated Gaussian samples by multiplying the factor L by a vector of standard normal draws; the calculator supplies L in a copy-friendly bracket format.
- • Saves a hand verification step: The built-in L L^T check turns a manual cross-multiplication into a single reported number, so the factor can be trusted without retyping the entries.
- • Teaches the recursive structure: Reading the diagonal and the off-diagonal entries next to each other shows how each new pivot uses the rows above it, which is the same structure LAPACK and other libraries use.
The determinant identity det(A) = det(L)^2 turns det(L) into a quick consistency check: square it, and the result should match det(A) to within numerical roundoff.
Use the calculator for verification, not for production-scale solves. Real applications use library routines, but the calculator is a fast way to sanity-check inputs and the factor side by side.
Factors That Affect Your Results
Four factors determine whether the Cholesky decomposition exists and how accurate the factor is.
Symmetry of the input
The calculator uses the upper triangle of A and mirrors it. Any asymmetry is silently overwritten, so copy the upper triangle down before the calculation if symmetry is required.
Positive definiteness
A real symmetric matrix is positive definite only when every leading principal minor is strictly positive, which is the precondition for a unique Cholesky factor with a positive diagonal. The algorithm throws on a negative pivot (indefinite input) and surfaces a zero pivot as positive semidefinite rather than positive definite, since the input is then singular and the factor is no longer unique.
Numerical conditioning
Matrices with a very small minimum eigenvalue can lose several digits of precision during the pivot step. The verification error will rise above 1e-10 and should be read as a warning.
Diagonal scaling
Diagonal-dominant matrices produce a Cholesky factor with small off-diagonal entries relative to the diagonals. The same is not true for poorly scaled matrices.
- • The calculator only handles 2x2 and 3x3 matrices. For larger problems the same formulas apply, but the input grid would not be readable, and library routines such as LAPACK POTRF are the right next step.
- • The output assumes the matrix is real-valued. A complex Hermitian positive definite matrix needs a different factorization that uses the conjugate transpose.
- • A small verification error near 1e-12 is normal floating-point noise. A large error above 1e-6 usually means the matrix is not numerically positive definite, or that a singular block slipped through.
Use the calculator as a quick check on covariance and kernel matrices, not as a replacement for a tuned numerical library. When the input is a kernel matrix with a long-tailed spectrum, rescale the entries first so the smallest pivot is closer to one and the verification error stays well below 1e-10.
According to Wolfram MathWorld Cholesky decomposition, the Cholesky factor of a symmetric positive definite matrix satisfies det(A) = det(L)^2 and can be computed by the recursive formulas L[i][i] = sqrt(A[i][i] - sum of L[i][k]^2) and L[i][j] = (A[i][j] - sum of L[i][k] L[j][k]) / L[j][j].
According to LAPACK POTRF documentation, Cholesky factorization computes the factor L of a symmetric positive definite matrix A and signals an error code when a diagonal entry becomes non-positive, which is the practical definition of 'not positive definite' in numerical software.
The verification step is a row-by-row dot product check between L and L^T, and the Dot Product Calculator applies the same inner-product reduction to individual columns when a hand cross-check is needed.
Frequently Asked Questions
Q: What is Cholesky decomposition used for?
A: Cholesky decomposition factors a symmetric positive definite matrix A into the lower triangular matrix L such that A = L L^T. It is used in ordinary least squares to solve the normal equations efficiently, in multivariate normal sampling, in Kalman filters, and in Monte Carlo simulations where correlated draws are needed.
Q: What does the Cholesky Decomposition Calculator output?
A: The calculator outputs the L factor as a bracket matrix and as individual entries, the determinant of A, the determinant of L, and a verification error that measures how close L L^T is to the original matrix. The verification error stays near zero for a clean factorization.
Q: Can Cholesky decomposition handle a 3x3 matrix?
A: Yes. The calculator supports 2x2 and 3x3 symmetric positive definite matrices. For 3x3 inputs the algorithm runs the same Cholesky-Banachiewicz recursion, which produces three diagonal pivots and three off-diagonal entries before the verification step.
Q: How do I know if a matrix is positive definite?
A: A real symmetric matrix is positive definite when every leading principal minor is strictly positive. The Cholesky algorithm checks this one pivot at a time, so a successful Cholesky decomposition is itself a positive-definiteness certificate for the input.
Q: What happens if I enter a non-positive-definite matrix?
A: The algorithm stops at the first negative pivot and the calculator reports a clear error that points to the failing step. This is the same convention that LAPACK uses for its POTRF routine, and it lets you identify the entry that breaks positive definiteness before plugging the matrix into a downstream solve.
Q: Is Cholesky decomposition the same as LU decomposition?
A: No. Cholesky decomposition is the lower triangular square root of a symmetric positive definite matrix and is roughly twice as efficient as a general LU decomposition on the same matrix. LU decomposition, by contrast, works on any square matrix but does not exploit symmetry or positive definiteness.