LU Decomposition Calculator

Enter a square matrix to factor it into lower and upper triangular matrices.

Matrix A
Size
2

A square matrix from 2 by 2 to 5 by 5, rows separated by semicolons.

Try

Result

You enteredLU decomposition of (0110)\text{LU decomposition of } \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}

P=(0110),  L=(1001),  U=(1001)\displaystyle P = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix},\ \ L = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix},\ \ U = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}
Show the work
  1. LU decomposition

    Write the matrix as a product of a lower-triangular matrix LL (with 1s on its diagonal) and an upper-triangular matrix UU. A pivot of 0 cannot be used to clear the column below it, so rows are swapped, and the swaps are recorded in a permutation matrix PP.

    Using PA=LUP A = L U

    A=(0110)A = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}
  2. Row swaps for a zero pivot

    A zero in the pivot position cannot be used, so the row is swapped with a lower row that has a non-zero entry in that column. 1 swap was needed.

    R1↔R2R_{1} \leftrightarrow R_{2}
  3. Multipliers for one column

    Each multiplier likl_{ik} is the entry to clear divided by the pivot in column 1. Subtracting that multiple of the pivot row from row ii makes the entry 0, and likl_{ik} is stored in LL.

    Using lik=uikukkl_{ik} = \frac{u_{ik}}{u_{kk}}

    l21=0l_{21} = 0
  4. Check by multiplying back

    Multiplying LL by UU should give PAP A.

    LU=(1001)(1001)=(1001)=PA=(1001)L U = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}\begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} = P A = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}
  5. Result

    So P=(0110),  L=(1001),  U=(1001)P = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix},\ \ L = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix},\ \ U = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}.

Worked examples