Advertisement

LU decomposition calculator

Choose the size and enter the matrix row by row. The calculator uses partial pivoting, then shows P, L and U so that P A equals L U.

Calculator

Permutation matrix P
1, 0; 0, 1
Unit lower triangular matrix L
1, 0; 0.5, 1
Upper triangular matrix U
4, 3; 0, -0.5
P A and L U
P A = 4, 3; 2, 1; L U = 4, 3; 2, 1

Advertisement

How this calculator works

LU decomposition records the row operations of Gaussian elimination. L holds the multipliers below the diagonal, and U is the resulting upper triangular matrix. With partial pivoting, rows are swapped first and the swaps are collected in P, giving P A = L U. The multipliers are stored in the permuted order, so L remains unit lower triangular. If a pivot column is entirely zero, the matrix is singular but the factors still exist.

Formula

P A = L U, where L is unit lower triangular and U is upper triangular.

Worked example

For the matrix with rows 4, 3 and 2, 1, no row swap is needed. Eliminating the 2 with a multiplier of 0.5 gives L as 1, 0; 0.5, 1 and U as 4, 3; 0, -0.5. Their product is 4, 3; 2, 1. The matrix with rows 0, 2 and 1, 3 needs a swap, so P is 0, 1; 1, 0.

Advertisement

Frequently asked questions

Why is there a permutation matrix?

Partial pivoting swaps rows to keep the largest available pivot. The swaps are recorded in P so the identity P A = L U remains exact.

When is LU decomposition unique?

Without row swaps, a unit lower triangular L and upper triangular U are unique if every leading principal minor is non-zero. Pivoting can make the factors differ while still satisfying P A = L U.

Can a singular matrix have an LU factorization?

Yes. A singular matrix can still be factored, usually with a zero on the diagonal of U. The factor does not give an inverse, but it still records the elimination steps.

Sources

Advertisement