LU LU Decomposition Calculator

LU Decomposition Calculator

LU decomposition factors a square matrix into a lower triangular matrix L and an upper triangular matrix U such that PA = LU, and this calculator shows both factors. Shows the lower triangular L, upper triangular U, and permutation matrix P with full elimination steps.

LU

LU Decomposition (Doolittle)

PA = LU with partial pivoting

✓ Step-by-Step✓ Pivoting✓ Free⚡ Loading precision engine…
Matrix A
Quick Examples

LU Decomposition

LU decomposition factors a square matrix A as a product of a lower triangular matrix L and an upper triangular matrix U: A = LU (or PA = LU with partial pivoting for numerical stability).

$$PA = LU$$

Structure

  • L: Lower triangular with 1s on diagonal — stores the elimination multipliers
  • U: Upper triangular — the result of Gaussian elimination
  • P: Permutation matrix — records row swaps for partial pivoting

Applications

  • Solving Ax = b efficiently (forward/backward substitution)
  • Computing determinants: det(A) = det(L)×det(U) = product of diagonal of U
  • Computing matrix inverse for multiple right-hand sides

Worked Example (2×2)

For A = [[4,3],[6,3]]: L = [[1,0],[1.5,1]] and U = [[4,3],[0,-1.5]]. Multiplying L by U gives back the original matrix A, confirming the decomposition is correct.

Why Use LU Instead of Solving Directly?

Once you have L and U for a matrix, you can solve Ax = b for many different values of b very quickly, without redoing the full elimination process each time — useful when the same system needs solving repeatedly with different inputs.

Frequently Asked Questions

Partial pivoting swaps rows during the decomposition to avoid dividing by very small numbers, which can cause serious rounding errors. The P in "PA = LU" records which rows were swapped.
Not without pivoting — some matrices need rows rearranged first. With partial pivoting (the method this calculator uses), any square matrix with a non-zero determinant can be decomposed.
LU is generally faster to compute, while QR is more numerically stable and works in more situations, including for non-square matrices, which LU does not handle.

Related Calculators