Skip to content

Computing determinants

Slide a parallelogram into a rectangle without changing its area, read the determinant from the pivots, and see why cofactors are for small matrices only.

Helps to know first
This topic

First, the picture

Shear a parallelogram, or slide one side along the other, and its area stays the same. Watch elimination turn it into a rectangle.

Sliding a shape keeps its area

An elimination step, then a column step: two shears, and the area meter.

The parallelogram on (2, 1) and (−1, 1), area 3.

signed area
3
0.00 / 10.60 s
Describe this picture

The parallelogram on the columns (2,1)(2,1) and (−1,1)(-1,1), with an area meter reading 3. After a second’s rest it changes in two steps, each a slide of 2.6 s followed by a rest. First the elimination step “row 2 minus half of row 1” shears it vertically into the parallelogram on (2,0)(2,0) and (−1,1.5)(-1,1.5): each vertical slice of the shape slides up or down and keeps its length, so the area stays 3. Then the second side slides along the first until the shape is an upright rectangle, 2 wide and 1.5 tall. Each shear slides in a straight line, so the meter reads 3 throughout, and the rectangle’s sides are labelled as the pivots, 2 and 1.5. A transport plays, pauses and steps. After the clip, a Row exchange button swaps the two rows of the matrix. The shape is mirrored, and the meter reads −3-3.

Three rules

The determinant as area gave the meaning: the factor by which a matrix scales area. To compute it for a big matrix, use elimination from Elimination, and three rules about rows.

  1. Subtract a multiple of one row from another: the determinant does not change. The step is multiplication by an elimination matrix, which is a shear with determinant 1. In the picture at the top of the page, it sheared the parallelogram vertically: each vertical slice slid up or down at full length, so the area stayed 3.
  2. Exchange two rows: the determinant changes sign. That is a mirror. After the clip, press the exchange button and watch the meter turn to −3-3.
  3. Multiply a row by cc: the determinant is multiplied by cc. That stretches one direction.

The same three rules hold for columns, because det⁡A⊤=det⁡A\det\mathbf{A}^\top=\det\mathbf{A}. The second slide in the picture was a column step.

The pivots

Elimination turns A\mathbf{A} into an upper triangle U\mathbf{U} using only rule 1, and perhaps rule 2. A triangular matrix’s determinant is the product of its diagonal, the pivots: in the picture, the rectangle is 2 by 1.5. So

det⁡A=± (product of the pivots),\det\mathbf{A}=\pm\,(\text{product of the pivots}),

with a minus sign for each row exchange. For [2−111]\begin{bmatrix}2&-1\\1&1\end{bmatrix}, the pivots are 2 and 1.5, and 2⋅1.5=32\cdot1.5=3.

The 3×33\times3 matrix of the elimination page, A=[121381041]\mathbf{A}=\begin{bmatrix}1&2&1\\3&8&1\\0&4&1\end{bmatrix}, had pivots 1, 2 and 5, so det⁡A=10\det\mathbf{A}=10. The matrix [110101011]\begin{bmatrix}1&1&0\\1&0&1\\0&1&1\end{bmatrix} has pivots 1, −1-1 and 2, so its determinant is −2-2, the box turned inside out from the area page.

With an exchange: [0231]\begin{bmatrix}0&2\\3&1\end{bmatrix} has a zero first pivot. Exchange the rows to get [3102]\begin{bmatrix}3&1\\0&2\end{bmatrix}, with pivots 3 and 2, product 6. One exchange, so det⁡=−6\det=-6. The 2×22\times2 formula agrees: 0⋅1−2⋅3=−60\cdot1-2\cdot3=-6.

Cofactors

There is also a formula that needs no elimination. Pick a row pp. For each entry apqa_{pq} in it, cross out row pp and column qq; the determinant of what is left is the minor MpqM_{pq}. Give it the sign (−1)p+q(-1)^{p+q}, a chessboard of signs starting with ++ at the top left; the signed minor is the cofactor. Then

det⁡A=∑qapq (−1)p+qMpq.\det\mathbf{A}=\sum_q a_{pq}\,(-1)^{p+q}M_{pq}.

For the 3×33\times3 matrix A\mathbf{A} above, along row 1:

det⁡A=1⋅(8⋅1−1⋅4)−2⋅(3⋅1−1⋅0)+1⋅(3⋅4−8⋅0)=4−6+12=10.\begin{aligned} \det\mathbf{A}&=1\cdot(8\cdot1-1\cdot4)-2\cdot(3\cdot1-1\cdot0)\\ &\quad+1\cdot(3\cdot4-8\cdot0)\\ &=4-6+12=10 . \end{aligned}

Any row gives the same answer. The cofactors of A\mathbf{A} are 4,−3,124,-3,12 in row 1, 2,1,−42,1,-4 in row 2 and −6,2,2-6,2,2 in row 3. Along row 2: 3⋅2+8⋅1+1⋅(−4)=103\cdot2+8\cdot1+1\cdot(-4)=10. Along row 3: 0+4⋅2+1⋅2=100+4\cdot2+1\cdot2=10.

The inverse and Cramer’s rule

Put the cofactors in a matrix and transpose it. That is the adjugate, adj A\mathrm{adj}\,\mathbf{A}. Then

A−1=1det⁡A adj A=110[42−6−31212−42].\mathbf{A}^{-1}=\frac{1}{\det\mathbf{A}}\,\mathrm{adj}\,\mathbf{A} =\frac1{10}\begin{bmatrix}4&2&-6\\-3&1&2\\12&-4&2\end{bmatrix}.

Check: row 1 of A\mathbf{A} times column 1 of the adjugate is 4−6+12=104-6+12=10, and times column 2 is 2+2−4=02+2-4=0. So A adj A=10 I\mathbf{A}\,\mathrm{adj}\,\mathbf{A}=10\,\mathbf{I}. For a 2×22\times2 matrix this is the swap-and-change-signs formula of The inverse matrix.

Cramer’s rule solves Ax=b\mathbf{A}\mathbf{x}=\mathbf{b} with determinants alone. Replace column qq of A\mathbf{A} by b\mathbf{b} to get Aq\mathbf{A}_q. Then

xq=det⁡Aqdet⁡A.x_q=\frac{\det\mathbf{A}_q}{\det\mathbf{A}}.

For the system 2x−y=42x-y=4, x+y=5x+y=5 of Two pictures of a linear system, det⁡A=3\det\mathbf{A}=3, and

x=det⁡[4−151]3=93=3,y=det⁡[2415]3=63=2.x=\frac{\det\begin{bmatrix}4&-1\\5&1\end{bmatrix}}{3}=\frac93=3,\qquad y=\frac{\det\begin{bmatrix}2&4\\1&5\end{bmatrix}}{3}=\frac63=2 .

Why programs eliminate

Expanding by cofactors again and again, down to 1×11\times1 pieces, makes n!n! products for an n×nn\times n matrix. Elimination needs about n3/3n^3/3 steps.

15101520n, the size of the matrix110⁵10¹⁰10¹⁵stepscofactors, n!elimination, n³/3
Fig. Cofactors need n! products; elimination about n³/3 steps. Each mark up the side is 100 000 times the one below.

For a 3×33\times3 matrix, cofactors are fine. For n=20n=20, they need 20!=2.43×101820!=2.43\times10^{18} products. At a billion a second, that is about 77 years. Elimination needs about 203/3≈270020^3/3\approx2700 steps.

Two warnings about determinants. They do not add: det⁡(A+B)\det(\mathbf{A}+\mathbf{B}) is not det⁡A+det⁡B\det\mathbf{A}+\det\mathbf{B}. For the 2×22\times2 identity, det⁡(I+I)=det⁡(2I)=4\det(\mathbf{I}+\mathbf{I})=\det(2\mathbf{I})=4, not 2. And a tiny determinant does not mean a matrix is nearly singular. The 100×100100\times100 matrix 0.1 I0.1\,\mathbf{I} has determinant 0.1100=10−1000.1^{100}=10^{-100}, yet inverting it is perfectly safe: its inverse is 10 I10\,\mathbf{I}. Conditioning measures how close to singular a matrix really is.

Worked example

  1. By pivots. [121381041]\begin{bmatrix}1&2&1\\3&8&1\\0&4&1\end{bmatrix}: pivots 1, 2, 5, so det⁡=10\det=10.
  2. By cofactors. Along row 1: 4−6+12=104-6+12=10.
  3. The inverse. A−1=110[42−6−31212−42]\mathbf{A}^{-1}=\tfrac1{10}\begin{bmatrix}4&2&-6\\-3&1&2\\12&-4&2\end{bmatrix}.
  4. With an exchange. det⁡[0231]=−6\det\begin{bmatrix}0&2\\3&1\end{bmatrix}=-6.
  5. Cramer. 2x−y=42x-y=4, x+y=5x+y=5 gives x=9/3=3x=9/3=3 and y=6/3=2y=6/3=2.
  6. Quick ones. Pivots 2, 3, −4-4 with no exchanges: det⁡=−24\det=-24. Exchange two rows of a matrix with determinant 5: −5-5. det⁡[1234]=−2\det\begin{bmatrix}1&2\\3&4\end{bmatrix}=-2. A 3×33\times3 matrix with det⁡A=2\det\mathbf{A}=2: det⁡(3A)=33⋅2=54\det(3\mathbf{A})=3^3\cdot2=54.

Where you’ll meet this

Cramer’s rule is a common way to code where two lines in a drawing meet: one 2×22\times2 solve, written out. Programs that build meshes for 3-D models test which side of a plane a point lies on by the sign of a 3×33\times3 determinant. Circuit simulators and SciPy never expand cofactors for large systems; they eliminate, as LU factorisation does, and read the determinant from the pivots if they need it.

Reference card

QuantityFormulaNotes
Row steprow pp minus a multiple of row qqdeterminant unchanged
Exchangeswap two rowssign changes
Scale a rowmultiply a row by ccdeterminant times cc
Pivotsdet⁡A=±∏pupp\det\mathbf{A}=\pm\prod_p u_{pp}minus for each exchange
Cofactorsdet⁡A=∑qapq(−1)p+qMpq\det\mathbf{A}=\sum_q a_{pq}(-1)^{p+q}M_{pq}any row pp
AdjugateA−1=adj A/det⁡A\mathbf{A}^{-1}=\mathrm{adj}\,\mathbf{A}/\det\mathbf{A}transposed cofactors
Cramerxq=det⁡Aq/det⁡Ax_q=\det\mathbf{A}_q/\det\mathbf{A}column qq replaced by b\mathbf{b}
Costcofactors n!n!, elimination ≈n3/3\approx n^3/3eliminate for large nn

Keep reading with a free account.

By creating an account you accept the terms of use.

Sign in

Already have an account? Use the service you signed up with.

Or keep reading: get new lessons by email

Are you 13 or over?

Accounts and email updates are for people aged 13 or over. We keep only your answer, never your date of birth.

End of the lesson

Where to go next.

Phasorium

Account

Sign inKeep your place on any device

Subjects

Site

Look