MathsLinear Algebra

Matrix Determinant
calculator.

Find the determinant of a square matrix by cofactor expansion or by row reduction.

How it's worked out

The determinant is one number worked out from a square matrix. For a 2 by 2 matrix it is the product down the main diagonal minus the product down the other diagonal.

det⁡[abcd]\displaystyle \det\begin{bmatrix} a & b \\ c & d \end{bmatrix}=ad−bc\displaystyle {}= ad - bc

Cofactor expansion handles larger matrices. Pick a row or a column. Each entry in it gets a minor, which is the smaller matrix left when you cross out that entry's row and column. The cofactor is the minor's determinant with a sign from a checkerboard pattern that starts with plus in the top left corner. Multiply each entry by its cofactor and add the results.

Cij\displaystyle C_{ij}=(−1)i+jdet⁡(Aij)\displaystyle {}= (-1)^{i+j} \det(A_{ij})
det⁡(A)\displaystyle \det(A)=ai1Ci1+ai2Ci2+⋯+ainCin\displaystyle {}= a_{i1}C_{i1} + a_{i2}C_{i2} + \cdots + a_{in}C_{in}

Interactive Linear Algebra states that every row and every column gives the same number. So the tool expands along the line with the most zeros, since a zero entry needs no minor at all.

Row reduction is the second route. Adding a multiple of one row to another leaves the determinant alone, and each row swap flips its sign. Once the matrix is triangular, the determinant is the product of the diagonal, with one sign flip per swap. Each method is checked against the other in the last step.

Worked examples

Maya expands a 3 by 3 matrix along its zero

Maya has this matrix in her homework and wants to check her answer before she hands it in.

A\displaystyle A=[2−3120−1145]\displaystyle {}= \begin{bmatrix} 2 & -3 & 1 \\ 2 & 0 & -1 \\ 1 & 4 & 5 \end{bmatrix}

Row 2 holds a 0, so she expands along it and needs only two minors. The signs in row 2 run minus, plus, minus. The first term is −(2)(−19)=38-(2)(-19) = 38, the middle term is 0, and the last is −(−1)(11)=11-(-1)(11) = 11.

det⁡(A)\displaystyle \det(A)=38+0+11\displaystyle {}= 38 + 0 + 11=49\displaystyle {}= 49

If she had expanded along row 1 instead, she would have worked out three minors and still reached 49.

Open this example in the tool

Jon finds the determinant by row reduction

Jon's course asks for row reduction, not expansion.

A\displaystyle A=[1−42−28−9−170]\displaystyle {}= \begin{bmatrix} 1 & -4 & 2 \\ -2 & 8 & -9 \\ -1 & 7 & 0 \end{bmatrix}

Adding 2 times row 1 to row 2 and row 1 to row 3 clears column 1. That leaves a 0 in the second pivot spot, so he swaps rows 2 and 3, which flips the sign once. The triangular form has 1, 3, −5 on its diagonal.

det⁡(A)\displaystyle \det(A)=−(1)(3)(−5)\displaystyle {}= -(1)(3)(-5)=15\displaystyle {}= 15

Cofactor expansion gives 15 as well. Forgetting the swap is the slip that gives −15.

Open this example in the tool

Priya tests a matrix for an inverse

Priya needs to know if this matrix can be inverted before she tries.

A\displaystyle A=[123456789]\displaystyle {}= \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{bmatrix}

Row 3 minus row 2 equals row 2 minus row 1, so the rows depend on each other. Expansion along row 1 gives terms −3, 12, −9, which cancel to 0. The matrix is singular, so it has no inverse and she can stop there.

Open this example in the tool

Reading your result

Zero or not zero. A square matrix has an inverse exactly when its determinant is not 0, as Interactive Linear Algebra section 4.1 puts it. A zero also tells you that Ax = b has either no solution or infinitely many.

The size is a scale factor. By section 4.3, the absolute value is the area of the parallelogram the columns of a 2 by 2 matrix span, or the volume of the box for a 3 by 3. For the matrix with rows 3, 8 and 4, 6 the determinant is −14, so it stretches every area by 14. Swapping its rows gives 14, the same size with the other sign.

The sign is orientation. A negative determinant means the map flips space, like a mirror. For 2 by 2, it means column 2 sits clockwise from column 1.

Row operations have set effects. The table applies each one to the matrix with rows 1, 2 and 3, 4, whose determinant is −2.

Each change applied to a matrix with determinant −2
ChangeNew detEffect
Swap the two rows2Sign flips
Multiply row 1 by 3−6Times 3
Add 2 × row 1 to row 2−2No change
Transpose−2No change

Two more rules help as checks: det(AB) is det(A) times det(B), and det of the inverse is 1 over det(A). Scaling a whole n by n matrix by k scales the determinant by k to the power n, so doubling a 2 by 2 matrix takes −2 to −8.

Common mistakes

  • Dropping the checkerboard sign. The signs depend on where the entry sits, not on the entry. Row 2 of a 3 by 3 matrix starts with minus.
  • Losing count of swaps. Every row swap flips the sign, so an even number of swaps leaves the sign alone and an odd number flips it.
  • Expanding along row 1 out of habit. It is never wrong, but it can be slow. In the matrix with rows 1, 5, 0 and 2, 4, −1 and 0, −2, 0, row 3 has two zeros, so expanding along it needs one minor and gives −2 at once.
  • Scaling a row and not undoing it. Dividing a row by 2 to get a 1 halves the determinant, so multiply back by 2 at the end.
  • Using the diagonal rule on a 4 by 4. The shortcut of diagonal products works for 3 by 3 only. Larger matrices need expansion or row reduction.

Questions people ask

A zero means the matrix flattens space into fewer dimensions, so some nonzero vector lands on 0. Two different inputs then share one output, and no matrix can undo that. In row terms, at least one row is a mix of the others.

Sources