LU decomposition rewrites a square matrix A as the product of a lower-triangular matrix L and an upper-triangular matrix U, so that A = LU. It's the same arithmetic as ordinary Gaussian elimination, just packaged so the elimination work can be reused — which is exactly why it's the default method most numerical libraries use to solve linear systems, invert matrices, and compute determinants.

Why bother factoring A at all?

If you only need to solve Ax = b once, plain Gaussian elimination on the augmented matrix works fine. LU decomposition pays off when you need to solve Ax = b for the same A against many different b vectors — a common situation in simulations, circuit analysis, and iterative solvers. Once A = LU is computed, each new b only costs a cheap forward-substitution (solve Ly = b) followed by a cheap back-substitution (solve Ux = y), instead of re-running the full O(n³) elimination from scratch every time.

How partial pivoting keeps it correct

Gaussian elimination breaks down the moment a pivot (the diagonal entry you're about to divide by) is zero — you can't divide by zero, and dividing by a very small number amplifies rounding error. Partial pivoting fixes this by scanning the remaining rows in the current column and swapping in whichever one has the largest absolute value before eliminating. Every swap is tracked in a permutation matrix P, so the identity that holds afterward is P·A = L·U rather than A = L·U. This calculator's Steps tab shows exactly when and why each swap happens.

The determinant is a free by-product

Because L is triangular with 1s on its diagonal, det(L) = 1 always. Because U is triangular, its determinant is just the product of its diagonal. And because each row swap flips the sign of a determinant, det(A) works out to (−1)^(number of swaps) × (product of U's diagonal) — no separate cofactor expansion required. This is also why a zero anywhere on U's diagonal signals a singular matrix: the product becomes zero, so det(A) = 0 no matter what pivoting did along the way.