MatrixCalc

Matrix Calculator

Add, subtract, multiply, transpose, determinant, inverse, rank, trace and power. Up to 50×50.

Matrix A
rows: 3
cols: 3
Matrix B
rows: 3
cols: 3
Operations

Open the steps below to see the full answer.

Result
Pick an operation to see the result here. Errors will show up in this area.

Tips: adjust sizes (max 50×50). For A×B, cols(A)=rows(B). det/inverse/trace/power require square matrices.

React, Tailwind & shadcn/ui. No external math deps. — English

LU decomposition calculator

Factor a square matrix into lower and upper triangular parts, with every multiplier shown. Cholesky decomposition included for symmetric positive-definite matrices.

Enter a square matrix, open the Decompositions tab and press LU(A). Because the answer is a pair of matrices rather than one, it lives entirely in the step-by-step panel, which opens by itself and shows L and U side by side at the end.

What the factors are

LU writes A = L·U, with L lower triangular and U upper triangular. Neither is mysterious: U is exactly the row echelon form you get from Gaussian elimination, and L records the multipliers you used along the way. Doing the elimination once gives you both.

Worked example

43
63
=
10
3/21
×
43
0−3/2

The 3/2 in L is the multiplier that cleared the 6 below the pivot. Notice the determinant is now free: multiply the diagonal of U, giving 4 · (−3/2) = −6.

Why it is worth doing

Solving Ax = b from scratch costs about n³/3 operations. With L and U in hand, each additional right-hand side costs only : forward substitution followed by back substitution. If you are solving the same system against many different b vectors — which is the normal case in engineering and simulation — the saving is enormous.

Common mistakes

  • Assuming every matrix factors. A zero in a pivot position breaks plain LU. The fix is a permutation matrix: P·A = L·U.
  • Using Cholesky on the wrong matrix. It requires symmetry and positive definiteness; the calculator tells you when the condition fails.
  • Forgetting the row swaps in the determinant. Each swap flips its sign.

Frequently asked questions

Why does the calculator say my matrix needs row swaps?
A pivot came out zero, so there is no plain A = L·U factorisation. Only the permuted form P·A = L·U exists for that matrix.
Is LU decomposition unique?
It is once you fix the convention. This calculator uses Doolittle's, which puts ones on the diagonal of L.
When should I use Cholesky instead?
When the matrix is symmetric and positive definite. It is about twice as fast and needs only one triangular factor, since A = L·Lᵀ.
Can I get the determinant from LU?
Yes — it is the product of the diagonal of U, times −1 for each row swap performed.

Want the full explanation? Read the guide: LU decomposition, step by step

Other calculators