LU Decomposition Calculator
Decompose a square matrix A into A = LU using Doolittle's method.
Get the lower-triangular L and upper-triangular U for 2x2, 3x3, or 4x4 matrices.
LU decomposition factors a square matrix A into the product of a lower-triangular matrix L and an upper-triangular matrix U: A = LU. This is one of the most useful matrix factorizations because it turns the problem of solving Ax = b into two easy triangular solves: Ly = b (forward substitution), then Ux = y (back substitution).
This calculator uses Doolittle’s algorithm, which forces L to have 1s on its diagonal. The diagonal of U then absorbs the scaling. The alternative convention (Crout) puts 1s on U’s diagonal — the two are equivalent up to a diagonal scaling.
Once you have L and U, solving multiple systems with the same A but different right-hand sides is essentially free: the expensive O(n³) factorization happens only once. This is why direct linear solvers in numerical libraries factor the matrix first and reuse it.
LU exists for any square matrix where you don’t hit a zero pivot during elimination. Some matrices need row permutations first (PA = LU, called PLU decomposition with a permutation matrix P) to avoid dividing by zero. This calculator does not pivot — if a zero appears on the diagonal during elimination, it returns an error and you should rearrange the input rows manually.
Worked example: A = [[4,3],[6,3]]. Doolittle gives L = [[1,0],[1.5,1]], U = [[4,3],[0,-1.5]]. Check: L*U = [[4,3],[6,3]]. ✓
The determinant of A equals the product of U’s diagonal entries (since L’s diagonal is all 1s and det(LU) = det(L)det(U)). For the example: det = 4 * (-1.5) = -6. Matches the direct 2x2 computation 43 - 3*6 = -6. ✓
LU is preferred over computing A inverse explicitly. Inverting is wasteful — you almost never need the inverse itself, only its action on a vector, which the LU factorization gives you faster and more accurately.
How we build and check this calculator
This calculator runs entirely in your browser, so the numbers you enter stay on your device. The math behind it is written by hand and tested against worked examples and standard references before the page goes live.
SuperGlobalCalculator is independently built and maintained. See how we build and verify our calculators.