Factor any square matrix A into lower triangular L (unit diagonal) and upper triangular U such that P·A = L·U, where P is a permutation matrix.
LU decomposition (or LU factorization) factors a square matrix A into a product of a lower triangular matrix L and an upper triangular matrix U. In numerical linear algebra, we often incorporate row permutations to ensure stability, leading to the PLU decomposition: P·A = L·U, where P is a permutation matrix. This factorization is fundamental for solving linear systems Ax = b, computing determinants, and finding matrix inverses efficiently.
For an n×n matrix A, the decomposition yields:
P A = L U
L is unit lower triangular (diagonal entries = 1), U is upper triangular, and P encodes row exchanges (partial pivoting).
The concept of triangular factorization emerged from Gaussian elimination, refined by Alan Turing and von Neumann in the 1940s for numerical stability. The Doolittle algorithm (L unit diagonal) and Crout algorithm are standard variants. Partial pivoting — swapping rows to maximize the pivot magnitude — dramatically improves stability and is the default in modern libraries like LAPACK. This calculator implements Doolittle with partial pivoting, ensuring reliable results even for ill‑conditioned matrices.
Our algorithm performs Gaussian elimination with row pivoting:
The resulting L has unit diagonal, and U is upper triangular. The permutation matrix P is reconstructed from the pivot array. This method is backward stable for most matrices.
In a 5‑node electrical network, modified nodal analysis yields a 5×5 sparse matrix. Using LU decomposition with partial pivoting, engineers solve for node voltages 5× faster than explicit inversion. Our tool reproduces the factorization, revealing that the determinant (product of U's diagonal) indicates network stability. The permutation matrix highlights which equations were reordered to avoid zero pivots.
| Matrix A (3x3) | P (permutation) | L (lower) | U (upper) | det(A) |
|---|---|---|---|---|
| [[2,1,1],[4,3,3],[8,7,9]] | P = [[0,0,1],[0,1,0],[1,0,0]] | [[1,0,0],[0.5,1,0],[0.25,0.5,1]] | [[8,7,9],[0,-0.5,-1.5],[0,0,1]] | -4.0 |