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.
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:
| 1 | 0 | 0 |
| 2 | 1 | 0 |
| 4 | 3 | 1 |
And U:
| 2 | 1 | 1 |
| 0 | 1 | 1 |
| 0 | 0 | 2 |
Verify: det(A) = ±(product of U diagonal) = 2·1·2 = 4 (sign depends on row swaps in P).
- Matrix Calculations Guide — LU Decomposition — In-depth notes on LU Decomposition with worked examples
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.