Category

LU Decomposition Calculator — Factor Any Square Matrix into L and U (2×2 to 4×4)

Compute the LU decomposition (PA = LU) of any 2×2, 3×3, or 4×4 square matrix using Doolittle's method with partial pivoting. Instantly get matrices L, U, P and the determinant. Supports metric, US imperial, and 12 world currencies including USD and Russian Ruble.

0 calculations

Calculation Parameters

Enter Parameters

Fill in the form on the left and click "Calculate"

What does it mean to decompose a matrix?

To decompose (or factorize) a matrix means to write the matrix as a product of two or more matrices. This can significantly simplify some matrix operations because the matrices into which we decompose the original matrix have special properties, so we can easily perform various operations on them rather than on the original matrix. To discover matrix decompositions other than the LU decomposition discussed here, visit our Cholesky decomposition calculator and the singular value decomposition (SVD).

What is the LU decomposition?

The LU decomposition factors a square matrix A into the product of two matrices:

PA = LU

where:

  • L — Lower triangular matrix (all elements above the diagonal are zero; diagonal elements equal 1 in Doolittle's method)
  • U — Upper triangular matrix (all elements below the diagonal are zero)
  • P — Permutation matrix that records row swaps during partial pivoting

💡 Did you know that it was the Polish mathematician Tadeusz Banachiewicz who introduced the LU decomposition in 1938?

Does the LU decomposition always exist? LU decomposition problems

Not every square matrix admits an LU decomposition without row permutation. For instance, the matrix:

[0  1]
[2  3]

has a zero in the top-left pivot position, making a direct LU factorization without pivoting impossible. With partial pivoting (PA = LU), however, every nonsingular square matrix admits an LU decomposition. Our calculator always applies partial pivoting.

A singular matrix (det = 0) has no LU decomposition at all, and the calculator will report an error in that case.

How to find the LU decomposition?

The most common algorithm is Doolittle's method with partial pivoting:

  1. Start with A, initialize L = I (identity) and U = A.
  2. For each column, find the row with the largest absolute value in that column (pivot row) and swap it with the current row — record the swap in P.
  3. Eliminate all entries below the pivot by subtracting multiples of the pivot row. The multipliers become the sub-diagonal entries of L.
  4. Repeat until the upper-triangular U and lower-triangular L (with 1s on diagonal) are fully constructed.

The determinant is then simply: det(A) = (−1)^s · u₁₁ · u₂₂ · ⋯ · uₙₙ, where s is the number of row swaps.

How to use this LU decomposition calculator?

  1. Choose the matrix size: 2×2, 3×3, or 4×4.
  2. Select units (optional): abstract numbers, metric (meters), US imperial (feet), or currency (choose from 12 world currencies including USD and RUB).
  3. Enter the matrix entries in the grid — each cell accepts any real number.
  4. Click Decompose to compute L, U, P and the determinant instantly.
  5. Use the Share button to save a link to your calculation or print the result.

Applications of the LU decomposition

  • Solving linear systems Ax = b: Once PA = LU, solve Ly = Pb (forward substitution), then Ux = y (back substitution).
  • Computing the determinant: det(A) equals the product of U's diagonal entries (times the sign from row swaps).
  • Matrix inversion: Solve AX = I column by column using LU.
  • Repeated solutions: Factorize A once, then solve for many right-hand sides cheaply.
  • Numerical stability: Partial pivoting keeps L well-conditioned and reduces floating-point errors.

Metric vs. Imperial vs. Currency

In pure linear algebra the matrix entries are dimensionless numbers. Our calculator lets you tag columns with a unit label for visual clarity:

  • Metric system — entries labeled in meters (m).
  • US Imperial system — entries labeled in feet (ft).
  • Currency — choose from 12 world currencies: US Dollar ($), Russian Ruble (₽), Euro (€), British Pound (£), and more. The Ruble appears second in the list as one of the most-used world currencies.

Note: the unit label is cosmetic — LU decomposition is a purely algebraic operation and does not depend on units.

FAQs

Does the LU decomposition always give unique L and U?
With Doolittle's normalization (diagonal of L = 1) and a fixed permutation matrix P, the L and U factors are unique for a nonsingular matrix.
What if det(A) = 0?
A singular matrix cannot be decomposed. The calculator reports an error in that case.
Can I use LU decomposition for non-square matrices?
Standard LU decomposition applies to square matrices only. For non-square systems, use QR decomposition or SVD instead.
Is partial pivoting always necessary?
Not theoretically, but in practice partial pivoting is strongly recommended to avoid division by near-zero pivots and ensure numerical stability.

Calculation History

Loading...