LU Decomposition Calculator

Factor a square matrix A into PA = LU, where P is a permutation matrix, L is lower triangular, and U is upper triangular. Uses partial pivoting for numerical stability.

Loading calculator…

Notes

What is LU Decomposition?

LU decomposition factors a square matrix as PA = LU where P is a permutation matrix (row reordering), L is unit lower triangular (1s on diagonal, zeros above), and U is upper triangular.

Example Result

For A = [[2,1,1],[4,3,3],[8,7,9]], the decomposition gives L:

100
210
431

And U:

211
011
002

Verify: det(A) = ±(product of U diagonal) = 2·1·2 = 4 (sign depends on row swaps in P).

💡LU decomposition is used to efficiently solve Ax = b. First solve Ly = Pb (forward substitution), then Ux = y (back substitution).

Frequently Asked Questions

Why is a permutation matrix P needed?

Partial pivoting reorders rows to avoid dividing by small numbers (numerical stability). P records these row swaps.

What is LU decomposition used for?

Solving linear systems Ax = b efficiently (O(n³) once, then O(n²) per right-hand side), computing determinants, and matrix inversion.

How do you compute det(A) from LU?

det(A) = det(P⁻¹) · det(L) · det(U) = ±1 · 1 · (product of U diagonal). The sign is positive if P is an even permutation, negative if odd.