How to calculate the determinant of a matrix
Four ways to compute a determinant — the 2×2 formula, the rule of Sarrus, Laplace cofactor expansion and Gaussian elimination — and when to use each one.
The determinant is a single number attached to a square matrix. It answers one question above all others: is the matrix invertible? A determinant of zero means the rows are linearly dependent, the matrix is singular, and no inverse exists. Geometrically, the determinant is the signed factor by which the matrix scales area (2×2) or volume (3×3).
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:
| a | b |
| c | d |
So for [[1, 2], [3, 4]] the determinant is 1·4 − 2·3 = −2. Negative is perfectly normal: the sign tells you the transformation flips orientation.
The rule of Sarrus (3×3 only)
For 3×3 matrices, copy the first two columns to the right of the matrix, add the three products running down-right and subtract the three running down-left:
| 1 | 2 | 3 |
| 4 | 5 | 6 |
| 7 | 8 | 10 |
Sarrus is fast and easy to remember, but it only works for 3×3. There is no 4×4 version — a very common exam mistake.
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. Its cost grows like n!, though, so it is hopeless for large matrices.
Gaussian elimination
This is what a computer does. 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.
The cost is about n³/3 operations instead of n!, which is why our calculator uses elimination for anything above 3×3.
Properties worth memorising
det(Aᵀ) = det(A)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