# LU Decomposition Calculator

Decompose a 2x2 or 3x3 matrix into L and U triangular matrices. Uses Doolittle's method with determinant. Free online LU decomposition tool.

## What this calculates

Decompose a 2x2 or 3x3 matrix into a lower triangular matrix (L) and an upper triangular matrix (U) using Doolittle's method. The calculator also computes the determinant from the U diagonal.

## Inputs

- **Matrix Size** — options: 2 x 2, 3 x 3 — Choose the dimension of your square matrix.
- **a₁₁ (Row 1, Col 1)**
- **a₁₂ (Row 1, Col 2)**
- **a₁₃ (Row 1, Col 3)** — Only used for 3x3 matrices.
- **a₂₁ (Row 2, Col 1)**
- **a₂₂ (Row 2, Col 2)**
- **a₂₃ (Row 2, Col 3)** — Only used for 3x3 matrices.
- **a₃₁ (Row 3, Col 1)** — Only used for 3x3 matrices.
- **a₃₂ (Row 3, Col 2)** — Only used for 3x3 matrices.
- **a₃₃ (Row 3, Col 3)** — Only used for 3x3 matrices.

## Outputs

- **L (Lower Triangular)** — formatted as text — The lower triangular matrix with 1s on the diagonal.
- **U (Upper Triangular)** — formatted as text — The upper triangular matrix.
- **Determinant** — det(A) = product of U diagonal entries.
- **Status** — formatted as text — Whether the decomposition was successful.

## Details

LU decomposition factors a square matrix A into the product of a lower triangular matrix L and an upper triangular matrix U, so that A = L × U.

**Why LU Decomposition?**

Once you have L and U, solving a system Ax = b becomes two easy steps:
1. Solve Ly = b (forward substitution)
2. Solve Ux = y (back substitution)

This is much faster than Gaussian elimination when you need to solve the same system with many different right-hand sides.

**Doolittle's Method:**

In Doolittle's version, L has 1s on its diagonal. The algorithm fills in U row by row and L column by column:

- Row i of U: u_ij = a_ij - sum(l_ik × u_kj) for k = 1 to i-1
- Column j of L: l_ij = (a_ij - sum(l_ik × u_kj)) / u_jj for k = 1 to j-1

**2x2 Example:**

For A = [[4, 3], [6, 3]]:

- U: u11 = 4, u12 = 3
- L: l21 = 6/4 = 1.5
- U: u22 = 3 - 1.5 × 3 = -1.5

Result: L = [[1, 0], [1.5, 1]], U = [[4, 3], [0, -1.5]]

**Determinant Shortcut:**

Since det(A) = det(L) × det(U), and det(L) = 1 (all 1s on diagonal), the determinant is simply the product of U's diagonal entries.

## Frequently Asked Questions

**Q: What is LU decomposition used for?**

A: LU decomposition is primarily used to solve systems of linear equations efficiently, especially when you need to solve Ax = b for many different b vectors. It is also used to compute determinants and matrix inverses. Numerical software like MATLAB and NumPy rely on LU decomposition internally.

**Q: What happens if a pivot is zero during decomposition?**

A: A zero pivot means the decomposition cannot continue without row swaps. In practice, this is handled by partial pivoting (PA = LU, where P is a permutation matrix). This calculator uses Doolittle's method without pivoting, so it will report an error if a zero pivot is encountered.

**Q: What is the difference between Doolittle and Crout methods?**

A: Both produce A = LU, but they differ in which matrix gets the 1s on the diagonal. Doolittle's method puts 1s on the diagonal of L (lower matrix). Crout's method puts 1s on the diagonal of U (upper matrix). The results are related but not identical. Both are mathematically valid.

**Q: How does LU decomposition compare to Gaussian elimination?**

A: LU decomposition is essentially Gaussian elimination stored in matrix form. The advantage is reusability. If you need to solve Ax = b for 100 different b vectors, Gaussian elimination repeats all the work each time. LU decomposition does the factoring once, then each solve is just fast forward and back substitution.

---

Source: https://vastcalc.com/calculators/math/lu-decomposition
Category: Math
Last updated: 2026-04-08
