LU Decomposition Calculator

LU Decomposition Calculator

Decompose a square matrix into lower and upper triangular matrices using Doolittle's method with partial pivoting.

Last updated: June 2026 | By Patchworkr Team

Matrix Factorization Tool

Invalid or blank entries are rejected. Partial pivoting is enabled, so matrices that need row swaps can still be decomposed.

Partial pivoting is used automatically. If the largest pivot in a column is below the diagonal, the rows are swapped before elimination.
Decomposition
Status
Partial pivoting succeeded
Identity Check
PA = LU

Permutation Matrix P

0
1
0
0
0
1
1
0
0

Lower Matrix L

1
0
0
0
1
0
0.5
0.25
1

Upper Matrix U

4
7
5
0
-2
2
0
0
-2
  1. Swap row 1 with row 2 to bring the largest pivot into place.
  2. Use pivot 4 in row 1, column 1.
  3. Eliminate entry in row 2, column 1 with factor 0.5.
  4. Swap row 2 with row 3 to bring the largest pivot into place.
  5. Use pivot -2 in row 2, column 2.
  6. Eliminate entry in row 3, column 2 with factor 0.25.
  7. Use pivot -2 in row 3, column 3.

What is LU Decomposition?

LU decomposition factors a square matrix A into a lower triangular matrix L and an upper triangular matrix U, so that a pivoted version of the original matrix satisfies PA = LU.

This calculator uses Doolittle's convention, where the diagonal of L is all 1s. When a column needs it, rows are swapped first so the largest available pivot is used. That keeps the computation stable and avoids division by zero.

If a pivot is still zero after partial pivoting, the matrix is singular and the decomposition cannot continue.

How to Use This Calculator

  1. Enter the entries of your square matrix A.
  2. Make sure every cell contains a valid number. Blank and malformed values are rejected.
  3. Review the P, L, and U matrices once the decomposition is complete.
  4. Follow the pivoting steps to see when and why rows are swapped.
  5. Use Load Example to see a matrix that requires partial pivoting.

Worked Example

Matrix:
[0 1 1]
[1 1 0]
[2 1 1]
Pivoting:
The first column needs a row swap because the top pivot is zero. Partial pivoting moves the largest entry into place before elimination begins.
Result:
PA = LU

Frequently Asked Questions

Why does this calculator use partial pivoting?

Pivoting prevents division by zero when the top entry in a column is zero and improves numerical stability.

What happens if my matrix is singular?

If no usable pivot remains in a column, the calculator stops and reports that the decomposition cannot continue.

Why were blank inputs a problem before?

Blank cells should not be silently converted into zero, because that changes the matrix and can produce a misleading result.

What does PA = LU mean?

P is a permutation matrix that records row swaps. After pivoting, the permuted matrix factors cleanly into L and U.

Is Doolittle the only LU method?

No. Doolittle is one common convention. Crout and other variants use different diagonal conventions.

Can I use this for non-square matrices?

No. Standard LU decomposition is defined for square matrices.

Does the calculator always need row swaps?

No. If a good pivot is already in place, the algorithm proceeds without swapping rows.

What if I only want the old unsupported version?

This version has pivoting enabled by default, so it will handle the matrix correctly instead of failing on a zero pivot.

Related Tools