Enter a square matrix, open the Decompositions tab and press LU(A). Because the answer is a pair of matrices rather than one, it lives entirely in the step-by-step panel, which opens by itself and shows L and U side by side at the end. Cholesky(A) sits in the same tab, for the symmetric case explained below.
What the factors are
LU writes A = L·U, with L lower triangular and U upper triangular. Neither is mysterious: U is exactly the row echelon form you get from Gaussian elimination, and L records the multipliers you used along the way. Doing the elimination once gives you both.
Worked example
| 4 | 3 |
| 6 | 3 |
| 1 | 0 |
| 3/2 | 1 |
| 4 | 3 |
| 0 | −3/2 |
The 3/2 in L is the multiplier that cleared the 6 below the pivot. Notice the determinant is now free: multiply the diagonal of U, giving 4 · (−3/2) = −6, times −1 for each row swap performed.
Why it is worth doing
Because the factorisation is reusable. Solving Ax = b from scratch costs about n³/3 operations. Once you have L and U, each new right-hand side costs only n²: solve Ly = b by forward substitution, then Ux = y by back substitution. If you are solving the same system against many different b vectors — the normal case in engineering and simulation — the saving is enormous. For a 100×100 matrix and fifty right-hand sides, that is one factorisation plus fifty cheap passes, instead of fifty full eliminations.
Forward and back substitution, worked through
Take the 3×3 matrix loaded above. One elimination gives both factors:
| 2 | 1 | 1 |
| 4 | −6 | 0 |
| −2 | 7 | 2 |
| 1 | 0 | 0 |
| 2 | 1 | 0 |
| −1 | −1 | 1 |
| 2 | 1 | 1 |
| 0 | −8 | −2 |
| 0 | 0 | 1 |
The entries of L are exactly the multipliers used during elimination: 2 cleared the 4, −1 cleared the −2, and −1 cleared what was left in the second column. Now solve Ax = b for b = (4, −2, 7). First Ly = b, top row downward, each row giving one new value immediately because everything to its right is zero:
y₁ = 4; then 2·4 + y₂ = −2, so y₂ = −10; then −4 + 10 + y₃ = 7, so y₃ = 1.
Then Ux = y, bottom row upward: x₃ = 1; then −8x₂ − 2 = −10, so x₂ = 1; then 2x₁ + 1 + 1 = 4, so x₁ = 1. The solution is (1, 1, 1), reached without a single division by anything other than a diagonal entry. The determinant comes free from the same factors: 2 · (−8) · 1 = −16.
Pivoting
Not every matrix admits a plain A = L·U: a zero in a pivot position breaks it. The fix is a permutation matrix, giving P·A = L·U. In practice pivoting is used anyway, because choosing the largest available pivot keeps rounding errors under control. The factorisation is unique once you fix a convention; this calculator uses Doolittle’s, which puts ones on the diagonal of L.
Cholesky: the symmetric case
If A is symmetric and positive definite, it factors as A = L·Lᵀ — a square root for matrices, needing only one triangular factor. Symmetric means A = Aᵀ; positive definite means every eigenvalue is greater than zero. That sounds restrictive, but the matrices it describes are everywhere: covariance matrices, Gram matrices, the normal equations of least squares and the stiffness matrices of finite element analysis are all symmetric positive definite by construction.
| 4 | 2 |
| 2 | 5 |
| 2 | 0 |
| 1 | 2 |
| 2 | 1 |
| 0 | 2 |
Each diagonal entry of L is a square root — here √4 = 2 and √(5 − 1²) = 2 — which is why the method needs the quantity under every root to stay positive. That requirement is exactly positive definiteness, and it turns the algorithm into a test: if the decomposition completes, the matrix is positive definite; if it hits a non-positive value under a root, it is not. Cholesky is about twice as fast as LU, uses half the storage, and needs no pivoting to stay stable, which is why solvers test for symmetry first and reach for it whenever they can.
Common mistakes
- Assuming every matrix factors. A zero in a pivot position breaks plain LU. The fix is a permutation matrix:
P·A = L·U. - Using Cholesky on a non-symmetric matrix. A = L·Lᵀ is symmetric by construction, so a non-symmetric input has no such factorisation. Use LU.
- Assuming symmetry is enough. A symmetric matrix with a negative eigenvalue is indefinite and will fail mid-algorithm.
- Expecting integer factors. The Cholesky diagonal involves square roots, so L is usually irrational even when A is not.
- Forgetting the row swaps in the determinant. Each swap flips its sign.