ZestCalc

LU Decomposition Calculator

Factor any matrix into L and U with exact fractions, and watch each multiplier move into L as elimination builds U.

Matrix

Enter a matrix of any shape, or start from an example.

Up to 12 rows and 12 columns.

Use integers, decimals, or fractions such as 1/3. Paste rows from a spreadsheet or a Python list into any cell.

Input

A=[2114−60−272]A = \begin{bmatrix} 2 & 1 & 1 \\ 4 & -6 & 0 \\ -2 & 7 & 2 \end{bmatrix}

Factors

Updates as you type.

A=LUA = LU

No row swaps were needed, so L times U gives A exactly.

LL

Lower triangular, with the multipliers from elimination

100
210
-1-11

UU

The echelon form that elimination reaches

211
0-8-2
001

Work it out

UU

211
4-60
-272

LL

100
010
001
U starts as A, and L starts as the identity. Each elimination step moves its multiplier into L.
Step 0 of 3

What LU decomposition is

LU decomposition writes a matrix as a product of two simpler ones:

A=LUA = LU

UU is the upper triangular result of Gaussian elimination. LL is lower triangular, with 11s on its diagonal, and holds the multipliers used along the way. When elimination subtracts mm times one row from a lower row, mm goes straight into LL, in the position being cleared.

So LL is a record of elimination, and LU=ALU = A says that replaying the record from UU rebuilds AA.

If a pivot position holds 00, rows must be swapped first. A permutation matrix PP records the swaps, which gives:

PA=LUPA = LU

Why it's useful

Once a matrix is factored, solving Ax=bAx = b takes two quick triangular solves, for any number of right-hand sides:

Ly=b,Ux=yLy = b, \qquad Ux = y

Elimination does most of its work on AA, not on bb, so the factorization only needs to be computed once. This is why numerical software uses LU to solve systems, rather than computing an inverse.

It also gives the determinant of a square matrix: the product of the diagonal of UU, with the sign flipped once for each row swap.

Tips for using the calculator

  • Open Steps and move one step at a time to watch each multiplier appear in LL as UU changes.
  • Rectangular and singular matrices work too. UU is then in echelon form rather than strictly triangular, and may have zero rows.
  • Row swaps happen here only when a pivot is exactly 00, as in hand calculation. Libraries such as SciPy and LAPACK swap to get the largest pivot for numerical stability, so their PP, LL, and UU may differ from these and still be correct.
  • In Practice, the numbers are chosen so that every multiplier is an integer.

Elimination is explained further in the RREF Calculator, and you can compare the determinant shortcut with the Determinant Calculator. Multiply the factors back with the Matrix Multiplication Calculator.