Use this free LU factorisation calculator to decompose a square matrix into lower and upper triangular matrices. The tool applies partial pivoting for better numerical stability and returns P, L, and U such that:
Interactive LU Factorisation Calculator
Enter matrix A, then click Compute LU.
What is LU factorisation?
LU factorisation (also called LU decomposition) rewrites a square matrix A as the product of two triangular matrices:
- L: a lower triangular matrix (entries above the diagonal are zero)
- U: an upper triangular matrix (entries below the diagonal are zero)
In practical computation, we usually include a permutation matrix P for row swaps, so the most robust form is: PA = LU.
How to use this calculator
1) Set matrix size
Choose n from 2 to 6. The tool generates an n × n input grid.
2) Enter matrix values
Type your coefficients into the matrix cells. Decimals and negative numbers are supported.
3) Compute decomposition
Click Compute LU. The calculator returns:
- Permutation matrix P
- Lower triangular matrix L
- Upper triangular matrix U
- Residual error norm for verification
- Determinant estimate from the decomposition
Why pivoting matters
If a pivot element is zero (or very small), direct elimination can fail or become unstable. Partial pivoting solves this by swapping the current row with a row that has a larger absolute pivot in the same column. This improves reliability and is standard in scientific computing.
Common applications
- Solving linear systems Ax = b efficiently for multiple right-hand sides
- Computing determinants using diagonal entries of U
- Building matrix inverses (via repeated triangular solves)
- Numerical simulation, data science, optimization, and engineering analysis
Interpreting the result
Triangular structure
In L, values above the main diagonal should be 0, and diagonal values are typically 1 in Doolittle form. In U, values below the main diagonal should be 0.
Residual check
The calculator computes a residual norm for PA - LU. A value close to zero indicates a correct numerical decomposition.
Tips for better accuracy
- Avoid entering values with excessively large magnitude differences when possible.
- Increase output precision if you need to inspect tiny rounding effects.
- If the matrix is singular, decomposition may not exist in standard form.
FAQ
Does every matrix have an LU decomposition?
Not in the simple no-pivot form. With pivoting, most nonsingular matrices can be decomposed as PA = LU.
What if the calculator says the matrix is singular?
That means at least one pivot is effectively zero. The matrix may be singular (non-invertible) or numerically near-singular.
Can I use this for homework verification?
Yes. It is great for checking manual Gaussian elimination steps and validating computed triangular factors.