MathAlgebraLinear algebraMatrices

Calculating matrix determinant

11 minutes read

Now that you are familiar with the determinant of matrices of size 22, you will know its definition for square matrices of any size.
You'll even derive a general formula for the determinant of any matrix of size 33. In addition, you'll identify some of the matrices whose determinant is very easy to calculate. Get ready to practice a lot!

The building blocks

You already know that the determinant of a 2×22 \times 2 matrix is abcd=adbc\begin{vmatrix}a&b\\c&d \end{vmatrix} = ad -bc. Maybe it's easy to grasp but not so easy to remember.

A good tip is to think about it in terms of the diagonals of the matrix. The determinant is just the product of its forward diagonal minus the product of its backward diagonal:

Determinant in terms of the diagonals

But what about the determinant of larger matrices? The focus here will be to define the determinant of 3×33 \times 3 matrices through the determinant of several 2×22 \times 2 matrices. And you'll use just the same strategy to define the determinant of any n×nn \times n matrix in terms of the determinant of several (n1)×(n1)(n-1) \times (n-1) matrices.

Before you go any further on this road, you need to know a bit of terminology.

The protagonists: minors and cofactors

In order to define the determinant of a larger matrix, you are going to start extracting smaller sub-matrices from it.

Let's take a square matrix AA of size nn and assume that you've already defined the determinant for matrices of size n1n-1.
The (i,j)(i,j)-minor of AA, denoted as mijm_{ij}, is the determinant of the (n1)×(n1)(n-1) \times(n-1) matrix that you obtain by deleting the ii-th row and jj-th column of AA.

Let's illustrate this with a matrix of size 33:

A=(301410051)A=\begin{pmatrix}3&0&-1\\4&1&0 \\ 0&-5&1 \end{pmatrix}For example, the minor m11m_{11} of AA is the determinant of the matrix that results from eliminating the first row and first column of AA:

The (1,1) minor

In turn, the minor m23m_{23} of AA is the determinant of the matrix that results from eliminating the second row and the third column of A.

The (2,3) minor

Let's see the last ingredient you need. The determinant has a certain "alternation" behavior. This is a very particular quality and is manifested in the fact that you need to slightly alter the minors by multiplying them by a simple factor. In some cases, this factor is simply 11 and in the rest is 1-1. The (i,j)(i,j)-cofactor of AA is:

cij=(1)i+jmijc_{ij} = (-1)^{i+j}\, m_{ij}This means that the factor of the mijm_{ij} is 11 when i+ji +j is even, and 1-1 when it is odd. In the previous example, the factor of m11m_{11} is then 11 and the factor of m23m_{23} is 1-1. Thus c11=m11c_{11} = m_{11} and c23=m23c_{23} = -m_{23}

You can visualize the behavior of this factor as if it were a chessboard. White entries have a factor of 1-1 while dark entries have a factor of 11

The alternation of the factors applied to the minors behaves like a checkerboard.

The determinant of any square matrix

Now that you're familiar with cofactors, it's time to take the next step. Let's combine them all. We define the cofactor expansion along the ii-th row of AA as the linear combination of the cofactors of the entries of ii-th row, using the entries of that row as the coefficients (notice that ai1,ai2,,aina_{i1}, a_{i2}, \dots, a_{in} are all the entries of the ii-th row of AA):

ai1ci1+ai2ci2++aincina_{i1} \, c_{i1} + a_{i2} \, c_{i2} + \dots +a_{in} \, c_{in}Let's continue with the matrix from the previous section:

A=(301410051)A=\begin{pmatrix}3&0&-1\\4&1&0 \\ 0&-5&1 \end{pmatrix}For example, the cofactor expansion along the first row from AA is:

a11c11+a12c12+a13c13=3c11+0c12c13=3m11m13=310514105=23a_{11} \, c_{11} + a_{12} \, c_{12} +a_{13} \, c_{13} = 3 \, c_{11} + 0 \, c_{12} - \, c_{13} = 3 \, m_{11} - \, m_{13} =3 \begin{vmatrix}1&0\\-5&1 \end{vmatrix} - \begin{vmatrix}4&1\\0&-5 \end{vmatrix} = 23

If you calculate the expansion of the other two rows, you will notice that the result is the same! You can even define the cofactor expansion along the jj-th column in a similar way (here that a1j,a2j,,anja_{1j}, a_{2j}, \dots, a_{nj} are all the entries of the jj-th column of AA):

a1jc1j+a2jc2j++anjcnja_{1j} \, c_{1j} + a_{2j} \, c_{2j} + \dots +a_{nj} \, c_{nj}Try to calculate the expansion along each column of the example matrix. Not only are they all the same, but their value is the same as the common value of the row expansions! This is more than a coincidence and is in fact true for any matrix. For this reason, we define the determinant of a matrix as any of these expansions!

If AA is a square matrix of size nn, then define its determinant as the value of its expansion along any row or column.

The important thing about the definition is that after having defined the determinant for matrices of size ii you can extend its definition for those of size 22, but then this definition is used for those of size ii and so on.

So, you can find the determinant of any square matrix of size 33 by expanding along any row or column, and you will always have the same result. For example, if you choose the first row, then:

abcdefghi=aefhibdfgi+cdegh=a(eifh)b(difg)+c(dheg)=aei+bfg+cdhcegbdiafh\begin{align*} \begin{vmatrix}a&b&c\\d&e&f \\ g&h&i \end{vmatrix} &= a \begin{vmatrix}e&f \\ h&i \end{vmatrix} -b \begin{vmatrix}d&f \\ g&i \end{vmatrix} + c\begin{vmatrix}d&e \\ g&h \end{vmatrix} \\ &= a (ei-fh) -b(di-fg)+c(dh-eg) \\ &= aei+bfg+cdh−ceg−bdi−afh \end{align*}That's a pretty hard number to memorize. But you can remember it with a trick similar to the one you used for matrices of size 22. The positive terms are the products of the 33 possible diagonals of the matrix, while the negative terms are the products of the 33 possible backward diagonals:

Determinant in terms of the diagonals

Putting theory to work

Let's see some examples. What better than starting with the simplest matrices, the upper triangular matrices? They only have zeros below their diagonal. For instance:

(1201)(123014001)(1234015600170001)\begin{pmatrix} 1 & 2 \\ 0 & 1 \end{pmatrix} \qquad \begin{pmatrix} 1 & 2 & 3 \\ 0 & 1 & 4 \\ 0 & 0 & 1 \end{pmatrix} \qquad \begin{pmatrix} 1 & 2 & 3 & 4 \\ 0 & 1 & 5 & 6 \\ 0 & 0 & 1 & 7 \\ 0 & 0 & 0 & 1 \end{pmatrix}Their determinant is extremely easy to calculate, it's simply the product of its main diagonal! Actually, the same result holds for lower triangular matrices (those that only have zeros below their diagonal), no matter how big they are.

Proof

The case n=2n=2 the result is obvious: a11a120a22=a11a220a12=a11a22\begin{vmatrix}a_{11}&a_{12}\\0&a_{22} \end{vmatrix} = a_{11} a_{22} - 0 a_{12} = a_{11} a_{22}.

The trick of the proof is that we can always expand by cofactors with respect to the first column. Since it only has one entry other than 0, its determinant is simply the first entry multiplied by its cofactor.

In general, for any nn, having proved the result for n1n-1, we can easily extend it for nn. This technique is called mathematical induction. Let's see it in action. If the result holds for n1n-1, then for nn:

a11a12a13a1n0a22a23a2n00a33a3n000ann=a11a22a23a2n0a33a3n00ann=a11a22a33ann\begin{vmatrix} a_{11} & a_{12} & a_{13} & \dots & a_{1n} \\ 0 & a_{22} & a_{23} & \dots & a_{2n} \\ 0 & 0 & a_{33} & \dots & a_{3n} \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & 0 & \dots & a_{nn} \end{vmatrix} = a_{11} \begin{vmatrix} a_{22} & a_{23} & \dots & a_{2n} \\ 0 & a_{33} & \dots & a_{3n} \\ \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & \dots & a_{nn} \end{vmatrix} = a_{11} \, a_{22} \, a_{33} \dots a_{nn}\blacksquare

Here's a little shortcut: if the matrix is upper triangular and one of its diagonal entries is 00, then its determinant is 00.

Let's end up with a slightly larger matrix, say 5×55 \times 5:

A=(2032330451105101030043422)A=\begin{pmatrix} 2&0&-3&2&3\\ -3&0&4&-5&1\\ 1&0&5&1&0\\ 1&0&-3&0&0\\ 4&-3&4&2&-2\\ \end{pmatrix}
Remember that to calculate the determinant, you can expand along any row or column you want. The best strategy is to choose one that has a lot of 00's, as this will reduce the number of cofactors you have to calculate. If you look closely, the second column has a lot of zeros, so it's a good candidate:

det(A)=a12c12+a22c22+a32c32+a42c42+a52c52=0+0+0+03c52=3(1)5+2m52=3(1)m52=3m52=32323345115101300\begin{align*} \det(A) &= a_{12} \, c_{12} + a_{22} \, c_{22} + a_{32} \, c_{32} + a_{42} \, c_{42} + a_{52} \, c_{52} \\ &= 0 + 0 + 0 + 0 -3 \, c_{52} \\ &= -3 \, (-1)^{5+2} m_{52}\\ &= -3 \,( -1) \, m_{52}\\ &= 3 \, m_{52}\\ &= 3 \begin{vmatrix} 2&-3&2&3\\ -3&4&-5&1\\ 1&5&1&0\\ 1&-3&0&0\\\end{vmatrix} \end{align*}Great, now there is only one determinant to solve for a matrix of size 44. If you define:

B=(2323345115101300)B= \begin{pmatrix} 2&-3&2&3\\ -3&4&-5&1\\ 1&5&1&0\\ 1&-3&0&0\\\end{pmatrix}Then det(A)=3det(B)\det(A) = 3 \det(B). But now, which is the best row or column to expand along? Undoubtedly the fourth row, since it has 22 zeros.

det(B)=b41c41+b42c42+b43c43+b44c44=b41c41+b42c42+0c43+0c44=c413c42=m413m42=3234515103223351110\begin{align*} \det(B) &= b_{41} c_{41} + b_{42} c_{42} + b_{43} c_{43} +b_{44} c_{44} \\ &= b_{41} c_{41} + b_{42} c_{42} + 0 c_{43} +0 c_{44} \\ &= c_{41} -3 c_{42} \\ &= -m_{41} - 3 m_{42} \\ &= - \begin{vmatrix} -3&2&3\\ 4&-5&1\\ 5&1&0\\ \end{vmatrix} -3 \begin{vmatrix} 2&2&3\\ -3&-5&1\\ 1&1&0 \end{vmatrix} \\ \end{align*}Now there are 22 determinants of size 33. You can either use the explicit formula or expand across its third line (because it has a 00).

For the first one:

323451510=5c31+c32+0c33=52351 3341 =5(2+15)(312)=100\begin{vmatrix} -3&2&3\\ 4&-5&1\\ 5&1&0\\ \end{vmatrix} = 5 c_{31} + c_{32} + 0 c_{33} = 5 \begin{vmatrix} 2&3\\ -5&1\ \end{vmatrix} - \begin{vmatrix} -3&3\\ 4&1\ \end{vmatrix} = 5(2+15) -(-3-12) = 100And for the second one:

223351110=23512331=(2+15)(2+9)=6\begin{vmatrix} 2&2&3\\ -3&-5&1\\ 1&1&0 \end{vmatrix} = \begin{vmatrix} 2&3\\ -5&1\\ \end{vmatrix} - \begin{vmatrix} 2&3\\ -3&1\\ \end{vmatrix} = (2+15)-(2+9) = 6Thus, det(B)=1003(6)=118\det(B) = -100 -3(6) = -118. Finally, det(A)=3det(B)=3(118)=354\det(A) = 3 \det(B) = 3(-118) = -354

Conclusion

Let's take a square matrix AA of size nn

  • The (i,j)(i,j)-minor of AA, denoted as mijm_{ij}, is the determinant of the (n1)×(n1)(n-1) \times(n-1) matrix that you obtain by deleting the ii-th row and jj-th column of AA.

  • The (i,j)(i,j)-cofactor of AA is cij=(1)i+jmijc_{ij} = (-1)^{i+j}\, m_{ij}.

  • The cofactor expansion along the ii-th row of AA is ai1ci1+ai2ci2++aincina_{i1} \, c_{i1} + a_{i2} \, c_{i2} + \dots +a_{in} \, c_{in}.The cofactor expansion along the jj-th column of AA is a1jc1j+a2jc2j++anjcnja_{1j} \, c_{1j} + a_{2j} \, c_{2j} + \dots +a_{nj} \, c_{nj}.

  • The determinant of AA is the value of its expansion along any row or column.

  • The determinant of a matrix of size 33 is abcdefghi=aei+bfg+cdhcegbdiafh\begin{vmatrix}a&b&c\\d&e&f \\ g&h&i \end{vmatrix} = aei+bfg+cdh −ceg−bdi−afh.

  • The determinant of a triangular matrix is the product of its diagonal.

7 learners liked this piece of theory. 0 didn't like it. What about you?
Report a typo