LU Decomposition Calculator

Enter your matrix values into the LU Decomposition Calculator and decompose any square matrix into its lower triangular matrix (L) and upper triangular matrix (U). Choose a matrix size from 2×2 up to 4×4, fill in the matrix entries, and get the full L and U factor matrices plus the determinant and pivot values computed via Gaussian elimination with partial pivoting.

Select the dimension of your square matrix

Results

Determinant of A

--

Lower Triangular Matrix (L)

--

Upper Triangular Matrix (U)

--

Number of Row Swaps (Pivoting)

--

Matrix Singular?

--

Diagonal Pivot Values of U

Results Table

Frequently Asked Questions

What is LU decomposition?

LU decomposition (also called LU factorization) factors a square matrix A into the product of a lower triangular matrix L and an upper triangular matrix U, so that A = LU. L has 1s on its diagonal and zeros above it, while U is zero below its diagonal. This factorization is foundational in solving linear systems, computing determinants, and inverting matrices efficiently.

What is partial pivoting in LU decomposition?

Partial pivoting involves reordering the rows of a matrix during Gaussian elimination to place the largest available pivot element on the diagonal. This improves numerical stability and prevents division by zero. When pivoting occurs, the factorization takes the form PA = LU, where P is a permutation matrix recording the row swaps.

How is the determinant calculated from LU decomposition?

Once A is factored into L and U, the determinant of A equals the product of the diagonal elements of U (since L has all 1s on its diagonal). If partial pivoting was used, the sign of the determinant is adjusted by (-1) raised to the number of row swaps performed during pivoting.

Can every matrix be decomposed using LU factorization?

Not every matrix has an LU decomposition without row permutations. If a zero pivot is encountered during elimination, row swapping (partial pivoting) is required. Singular matrices — those with a determinant of zero — cannot be fully decomposed because the process breaks down at a zero diagonal in U.

What is the difference between LU and LDU decomposition?

LU decomposition factors A into L (lower triangular with 1s on the diagonal) and U (upper triangular). LDU decomposition goes further by extracting a diagonal matrix D from U, so U = DU', giving A = LDU'. LDU provides a normalized form where both L and U' have 1s on their diagonals.

Why is LU decomposition useful for solving linear systems?

Given Ax = b, once you have A = LU you can solve the system in two fast steps: forward substitution to solve Ly = b, then back substitution to solve Ux = y. This is especially efficient when solving multiple systems with the same matrix A but different right-hand side vectors b, since L and U only need to be computed once.

What matrix sizes does this calculator support?

This LU Decomposition Calculator supports square matrices of size 2×2, 3×3, and 4×4. You select the size from the dropdown, fill in the matrix entries, and the calculator computes both the L and U matrices along with the determinant and pivot information.

How do I verify that the LU decomposition is correct?

Multiply the computed L and U matrices together. If the decomposition is correct, the product L × U should equal the original matrix A (or PA if row pivoting was performed). Checking a few entries of the product against the original matrix entries is a quick way to validate the result.

More Math Tools