BYTETOOLS

LU Decomposition Calculator

Factor a square matrix into P, L and U by Doolittle elimination with partial pivoting, then use the factorisation to get the determinant and solve A·x = b.

3×3
Size
1
Row swaps
-16
det(A)
verified
P·A = L·U

L — unit lower triangular

100
1/210
-1/211

U — upper triangular

4-60
041
001

P — permutation matrix

010
100
001

Row order after pivoting: R2, R1, R3. Partial pivoting always moves the largest available entry into the pivot position, which keeps the factorisation numerically stable and works even when a zero would otherwise appear on the diagonal.

Determinant from the factorisation

det(A) = (−1)1 × 4 × 4 × 1 = -16

L has 1s on its diagonal so it contributes a factor of 1; the determinant is the product of U’s diagonal, with one sign flip per row swap.

Solving A·x = b

Step 1 — forward substitution L·y = P·b: y = (-2, 6, 2)

Step 2 — back substitution U·x = y: x = (1, 1, 2)

x1 = 1

x2 = 1

x3 = 2

What is the LU Decomposition Calculator?

The ByteTools LU Decomposition Calculator factors a square matrix into a unit lower-triangular L and an upper-triangular U, with a permutation matrix P recording the row swaps: P·A = L·U.

  • Doolittle factorisation with partial pivoting, producing P·A = L·U
  • Exact rational arithmetic, so L and U print as fractions
  • Determinant from (−1)^swaps × the product of U's diagonal, shown term by term
  • Optional A·x = b solving by forward then back substitution, with y shown
  • Self-verifying: L·U is multiplied back out and compared with P·A
  • Runs entirely in your browser, no uploads

How to use the LU Decomposition Calculator

  1. 1

    Enter the square matrix A, one row per line, with values separated by spaces or commas.

  2. 2

    Read the L, U and P matrices, and check the P·A = L·U verification tile.

  3. 3

    Read the determinant panel, where the product of U's diagonal and the sign from row swaps are shown.

  4. 4

    Leave 'Also solve A·x = b' ticked and type your right-hand side vector to solve the system.

  5. 5

    Follow the forward and back substitution results, and copy the solution.

About the LU Decomposition Calculator

The ByteTools LU Decomposition Calculator factors a square matrix into a unit lower-triangular L and an upper-triangular U, with a permutation matrix P recording the row swaps: P·A = L·U. It uses the Doolittle method with partial pivoting, which always moves the largest available entry into the pivot position — that is what keeps the factorisation working even when a zero would otherwise land on the diagonal.

Once factored, two things become easy. The determinant is (−1) raised to the number of row swaps, times the product of U's diagonal, and the page prints that product term by term. And A·x = b is solved in two cheap triangular passes: forward substitution for L·y = P·b, then back substitution for U·x = y. Both intermediate vectors are shown, and everything is computed in exact fractions.

All arithmetic is JavaScript running in your browser — your matrix is never uploaded and no data is stored. The page verifies its own answer by multiplying L·U back out and comparing it with P·A.

Frequently asked questions

What is LU decomposition used for?

It splits the expensive part of solving a linear system away from the right-hand side. Once you have L and U, every new b is solved with two quick triangular substitutions instead of a full elimination, which is why it underpins most numerical linear-algebra libraries.

Why do you need a permutation matrix P?

Plain LU fails whenever a zero appears in a pivot position, and it loses accuracy when a pivot is very small. Swapping rows so the largest entry becomes the pivot fixes both problems, and P is simply the record of which swaps were made.

What is the difference between Doolittle and Crout LU?

They differ only in where the 1s go. Doolittle puts 1s on the diagonal of L, Crout puts them on the diagonal of U. Both give valid factorisations of the same matrix. This calculator uses Doolittle, which is the more common textbook convention.

How do you find the determinant from LU decomposition?

Multiply the diagonal entries of U together, then flip the sign once for every row swap that was performed. L contributes nothing because its diagonal is all 1s. It is far cheaper than a cofactor expansion for anything bigger than 3×3.

Can every matrix be LU decomposed?

Every square matrix has a factorisation of the form P·A = L·U once row swaps are allowed. Without a permutation, LU can fail — [[0,1],[1,0]] is the classic example, because its first pivot is zero. Singular matrices still factor, but then U has a zero on its diagonal and no unique solution exists.

Related tools