LU Decomposition Calculator
Factor any matrix into L and U with exact fractions, and watch each multiplier move into L as elimination builds U.
Matrix
Enter a matrix of any shape, or start from an example.
Up to 12 rows and 12 columns.
Use integers, decimals, or fractions such as 1/3. Paste rows from a spreadsheet or a Python list into any cell.
Input
Factors
Updates as you type.
No row swaps were needed, so L times U gives A exactly.
Lower triangular, with the multipliers from elimination
The echelon form that elimination reaches
Work it out
What LU decomposition is
LU decomposition writes a matrix as a product of two simpler ones:
is the upper triangular result of Gaussian elimination. is lower triangular, with s on its diagonal, and holds the multipliers used along the way. When elimination subtracts times one row from a lower row, goes straight into , in the position being cleared.
So is a record of elimination, and says that replaying the record from rebuilds .
If a pivot position holds , rows must be swapped first. A permutation matrix records the swaps, which gives:
Why it's useful
Once a matrix is factored, solving takes two quick triangular solves, for any number of right-hand sides:
Elimination does most of its work on , not on , so the factorization only needs to be computed once. This is why numerical software uses LU to solve systems, rather than computing an inverse.
It also gives the determinant of a square matrix: the product of the diagonal of , with the sign flipped once for each row swap.
Tips for using the calculator
- Open Steps and move one step at a time to watch each multiplier appear in as changes.
- Rectangular and singular matrices work too. is then in echelon form rather than strictly triangular, and may have zero rows.
- Row swaps happen here only when a pivot is exactly , as in hand calculation. Libraries such as SciPy and LAPACK swap to get the largest pivot for numerical stability, so their , , and may differ from these and still be correct.
- In Practice, the numbers are chosen so that every multiplier is an integer.
Elimination is explained further in the RREF Calculator, and you can compare the determinant shortcut with the Determinant Calculator. Multiply the factors back with the Matrix Multiplication Calculator.
Related calculators
Keep working with matrices.
RREF Calculator
Row reduce any matrix with exact fractions, step through every row operation, and practice Gaussian elimination.
Determinant Calculator
Find the determinant of a square matrix with exact fractions, drag a live area picture, and step through elimination or cofactor expansion.
Matrix Inverse Calculator
Invert a square matrix with exact fractions, step through [A | I] to [I | A⁻¹], and see the inverse undo the transformation.