Math
LU Decomposition Calculator
Enter a square matrix to factor it into a permutation matrix P, a unit lower triangular L, and an upper triangular U with PA = LU.
The calculator uses partial pivoting (largest pivot in each column), records each multiplier l_ij, verifies the product exactly, and shows how the determinant falls out of the pivots.
One row per line. Separate entries with spaces or commas. Integers, decimals, and fractions like 1/3 all work. Up to 8 x 8.
Try an example
Result
L and U
—
- Permutation P
- —
- Row swaps
- —
- det(A)
- —
- Check
- —
Student quick launch
Grade planning, algebra checks, and formulas students reach for most.
Study path
Use this calculator with
Follow these when you want the formula behind the answer, a short lesson, or nearby tools in the same topic.
What LU decomposition is
LU decomposition writes a square A rectangular grid of numbers arranged in rows and columns. as the product of a lower triangular matrix L and an upper triangular matrix U. It is Gaussian elimination with the bookkeeping kept: U is the echelon form and L stores the multipliers that produced it. With partial pivoting, rows are reordered by a permutation matrix P so that PA = LU.
Why pivoting
Without row swaps, elimination breaks down when a pivot is zero and becomes inaccurate when a pivot is tiny. Partial pivoting picks the largest available entry in each column as the pivot. This calculator uses exact fractions, so accuracy is not an issue, but it still pivots so the factorization matches what numerical software (and most textbooks) produce.
How to use it
- Enter a square matrix, one row per line.
- Read P, L, and U in the panel. If P is the identity, A = LU directly.
- Open Show the work to see the pivot chosen in each column and each multiplier l_ij.
- Use the One number computed from a square matrix that tells you whether it can be inverted. line: det(A) = (-1)^swaps times the product of U's diagonal.
Solving systems with LU
- Compute Pb by reordering the constants the same way the rows were swapped.
- Solve Ly = Pb by forward substitution (top row first).
- Solve Ux = y by back substitution (bottom row first).
- Reuse L and U for every new right-hand side b; that is the main reason LU is used in practice.
Common mistakes
- Forgetting to apply the row swaps to the already-computed part of L when pivoting.
- Expecting A = LU without P. Many matrices need at least one swap; the general statement is PA = LU.
- Putting the multipliers in U instead of L. U keeps the eliminated rows; L keeps the factors used.
- Assuming LU is unique. With different pivoting choices you get different (but equally valid) factors.
How to type a matrix into this calculator
- Put each row on its own line. Separate the entries in a row with spaces or commas: 2 1 1 or 2, 1, 1.
- Fractions such as 1/3 and decimals such as 0.25 are accepted and kept exact, so 1/3 stays 1/3 instead of becoming 0.3333.
- Every row must have the same number of entries. A row with a missing entry produces a clear error instead of a wrong answer.
- The largest size supported is 8 x 8. Brackets and semicolons are ignored, so [1 2; 3 4] works too.
Worked examples
3 x 3 with one swap
A = [1 2 4; 3 8 14; 2 6 13]
L and U
L = [1, 0, 0; 1/3, 1, 0; 2/3, -1, 1], U = [3, 8, 14; 0, -2/3, -2/3; 0, 0, 3]
One swap on a 2 x 2
A = [4 3; 6 3]: pivot 6 is larger, so rows swap once
L and U
L = [1, 0; 2/3, 1], U = [6, 3; 0, 1]
Already upper triangular
A = [2 1; 0 3] gives L = I, U = A
L and U
L = [1, 0; 0, 1], U = [2, 1; 0, 3]
Singular matrix
A = [1 2; 2 4] still factors, with a zero pivot in U
L and U
L = [1, 0; 1/2, 1], U = [2, 4; 0, 0]
Fractions
A = [1/2 1/3; 1/4 1/5]
L and U
L = [1, 0; 1/2, 1], U = [1/2, 1/3; 0, 1/30]
Not square
A 2 x 3 matrix cannot be LU-factored here
L and U
Error
Frequently asked questions
What is the difference between LU and Gaussian elimination?+
They are the same process. LU decomposition just stores the multipliers in L and the reduced rows in U so the work can be reused for many right-hand sides.
Why is there a P matrix?+
P records the row swaps made during pivoting. If no swaps happen, P is the identity and A = LU. In general PA = LU.
Does every matrix have an LU decomposition?+
Every square matrix has a PA = LU factorization with pivoting. Without pivoting, some matrices (such as [0 1; 1 0]) cannot be factored because a zero pivot appears immediately.
How do I get the determinant from LU?+
det(A) = (-1)^(number of swaps) times the product of the diagonal entries of U, because det(L) = 1 and det(P) = ±1.
Is the LU decomposition unique?+
For a fixed pivot order and unit-diagonal L (Doolittle form), yes. Different pivoting choices or putting the 1s on U's diagonal (Crout form) give different but equivalent factorizations.
About this calculator
- Written by
- mathcheck editorial team
- Last reviewed
- September 4, 2026
Method
- Uses the values entered by the user and stable formulas documented on the page.
Related calculators
Matrix Determinant Calculator
Find the determinant of any square matrix up to 8 x 8 with exact fractions. Shows cofactor expansion along any row or column for 3 x 3 (with a rule-of-Sarrus check), row-reduction steps for larger matrices, and tells you whether the matrix is invertible.
RREF Calculator
Reduce any matrix up to 8 x 8 to reduced row echelon form with every row operation shown, or enter A and b to solve Ax = b with unique, infinite (parametric), and no-solution reporting. Exact fractions throughout.
Matrix Inverse Calculator
Invert any square matrix up to 8 x 8 with exact fractions. Gauss-Jordan elimination on [A | I] with every row operation shown, the adjugate route for small matrices, a singular-matrix explanation, and an A·A⁻¹ = I check.
Matrix Multiplication Calculator
Multiply two matrices up to 8 x 8 with exact fractions. Checks that the dimensions line up, shows the dot product for every entry of the product, compares AB with BA, and explains why order matters.
System of Equations Calculator
Solve a 2x2 linear system with elimination/determinant steps for x and y.
Eigenvalues and Eigenvectors Calculator
Find the eigenvalues and eigenvectors of a square matrix up to 8 x 8. Shows the characteristic polynomial, exact eigenvalues (including fractions, square roots, and complex pairs), eigenvector bases, multiplicities, and whether the matrix is diagonalizable.
Last updated: September 4, 2026