MatrixCalc

Determinant calculator

Compute the determinant of any square matrix up to 50×50 and see every step — by Gaussian elimination, cofactor expansion, the rule of Sarrus or Montante's method.

Matrix A
rows: 3
cols: 3
Matrix B
rows: 3
cols: 3
Operations
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

Type your matrix above, open the Advanced tab and press det(A). The answer appears immediately; opening the step-by-step panel shows how it was reached, and lets you switch between four different methods for the same matrix — useful when your class was taught one of them in particular. Everything below explains what the number means and how each of those methods works, so you can reproduce the result by hand.

What the determinant tells you

It is a single number, defined only for square matrices, and its most important job is answering one question: is this matrix invertible? If the determinant is zero the matrix is singular — its rows are linearly dependent, it has no inverse, and a system built on it has either no solution or infinitely many. Any non-zero value means the matrix is invertible.

Geometrically it is the factor by which the transformation scales area in 2D or volume in 3D. A determinant of −2 doubles areas and flips orientation; a determinant of 0 flattens space onto a line or a point, which is precisely why the operation cannot be undone. The sign is not an error to be discarded: it records whether the transformation preserves handedness or mirrors it.

The 2×2 formula

For a 2×2 matrix the determinant is the product of the main diagonal minus the product of the anti-diagonal:

ab
cd
= a·d − b·c

So for [[1, 2], [3, 4]] the determinant is 1·4 − 2·3 = −2. The vertical bars are standard notation for the determinant — they are not absolute value, and the result is very often negative.

The rule of Sarrus (3×3 only)

For 3×3 matrices, copy the first two columns to the right of the matrix, then add the three products running down-right and subtract the three running down-left. On the matrix loaded above:

213
041
520
= (2·4·0 + 1·1·5 + 3·0·2) − (3·4·5 + 2·1·2 + 1·0·0) = 5 − 64 = −59

Sarrus is fast and easy to remember, but it only works for 3×3. There is no 4×4 version of it, and inventing one is among the most common mistakes in a first linear algebra exam. Past 3×3 you need cofactor expansion or elimination.

Laplace (cofactor) expansion

Pick any row or column, and write the determinant as a sum of entries times their cofactors. The cofactor C(i,j) is (−1)^(i+j) times the minor — the determinant of the matrix with row i and column j deleted.

Cofactor expansion works for any size, and it is the method to choose by hand when a row or column is mostly zeros: every zero entry kills an entire minor before you compute it. Its cost grows like n!, though, so it is hopeless for large matrices. A 20×20 determinant by cofactors would need more operations than there are atoms in a person.

Gaussian elimination

This is what a computer does, and what this calculator does from 4×4 upward. Reduce the matrix to upper triangular form with elementary row operations, then multiply the diagonal. Three rules keep the bookkeeping honest:

  • Swapping two rows multiplies the determinant by −1.
  • Multiplying a row by k multiplies the determinant by k.
  • Adding a multiple of one row to another leaves the determinant unchanged — this is the workhorse, and the reason elimination is cheap.

The cost is about n³/3 operations instead of n!. The same factorisation that produces the answer is LU decomposition, so if you need the determinant and the factors together, one elimination gives you both.

Montante’s method

Also called the Bareiss algorithm, or fraction-free elimination. It runs the same elimination as above, but after each stage every entry is divided by the previous pivot. That division always comes out exact, so a matrix of integers stays a matrix of integers from start to finish — no fractions appear at any point, and the last pivot is the determinant itself.

By hand this is the method that keeps the arithmetic clean on an integer matrix, since you never carry a denominator. It is also the one to use when the entries are exact and you want the answer to be exact too. Pick it in the step-by-step panel to see the same matrix worked through without a single fraction.

Properties worth memorising

  • det(Aᵀ) = det(A) — anything true of the rows is true of the columns
  • det(A·B) = det(A)·det(B)
  • det(A⁻¹) = 1 / det(A)
  • det(k·A) = kⁿ·det(A) for an n×n matrix — the scalar hits every one of the n rows
  • A triangular matrix has determinant equal to the product of its diagonal
  • The determinant is the product of the eigenvalues, just as the trace is their sum

Common mistakes

  • Using Sarrus on a 4×4. There is no 4×4 version of the rule. Use elimination or cofactor expansion.
  • Reading the bars as absolute value. |A| is standard notation for the determinant, and it is very often negative.
  • Forgetting the sign on a row swap. Every swap during elimination multiplies the determinant by −1.
  • Expecting det(A + B) = det(A) + det(B). That is false. Determinants multiply, they do not add.
  • Taking the determinant of a rectangular matrix. It is undefined. For a non-square matrix you almost certainly want the rank instead.

Frequently asked questions

Can a determinant be negative?
Yes. The sign says the transformation reverses orientation — it mirrors space. Only the magnitude describes the scaling factor.
What does a determinant of zero mean?
The matrix is singular: its rows are linearly dependent, it has no inverse, and it collapses space into a lower dimension.
Can a non-square matrix have a determinant?
No. The determinant is defined only for square matrices. For rectangular ones you probably want the rank instead.
Which method should I use by hand?
Up to 3×3 use the closed formulas. Beyond that, use Gaussian elimination — unless a row or column is mostly zeros, in which case cofactor expansion along it is faster.
Why does the calculator show fractions in the steps?
The step-by-step engine runs on exact rational arithmetic, so 1/3 stays 1/3 instead of drifting to 0.3333. You can switch the panel to decimals at any time.

Other calculators