# 28. Cofactor expansion

## 28. Cofactor expansion

Recall that the determinant of a 3-by-3 matrix $M=\begin{pmatrix}M_{11}&M_{12}&M_{13}\\ M_{21}&M_{22}&M_{23}\\ M_{31}&M_{32}&M_{33}\end{pmatrix}$ is $M_{11}M_{22}M_{33}-M_{11}M_{23}M_{32}-M_{12}M_{21}M_{33}+M_{12}M_{23}M_{31}+M_% {13}M_{21}M_{32}-M_{13}M_{22}M_{31}.$ We can group these into three sets of terms according to the factor $M_{1k}$ : those which contain a factor of $M_{11}$ , those with an $M_{12}$ and those with an $M_{13}$ : $M_{11}(M_{22}M_{33}-M_{23}M_{32})-M_{12}(M_{21}M_{33}-M_{23}M_{31})+M_{13}(M_{% 21}M_{32}-M_{22}M_{31}).$ Note that the terms in brackets are themselves determinants of 2-by-2 submatrices: $M_{11}\det\begin{pmatrix}M_{22}&M_{23}\\ M_{32}&M_{33}\end{pmatrix}-M_{12}\det\begin{pmatrix}M_{21}&M_{23}\\ M_{31}&M_{33}\end{pmatrix}+M_{13}\det\begin{pmatrix}M_{21}&M_{22}\\ M_{31}&M_{32}\end{pmatrix}.$ When we group our determinant according to the choice of the factor $M_{1k}$ , the expansion we get is: $\det(M)=M_{11}\det(C_{11})-M_{12}\det(C_{12})+M_{13}\det(C_{13})-\cdots\pm M_{% 1n}\det(C_{1n}).$ Here:

• signs alternate; in particular, the last $\pm$ is $+$ if $n$ is odd and $-$ if $n$ is even.

• $C_{ij}$ is the submatrix of $M$ obtained by removing the $i$ th row and the $j$ th column. For example, $C_{22}=\begin{pmatrix}M_{11}&X&M_{13}\\ X&X&X\\ M_{31}&X&M_{33}\end{pmatrix}=\begin{pmatrix}M_{11}&M_{13}\\ M_{31}&M_{33}\end{pmatrix}$ (where the $X$ s show which columns/rows we have removed).

This makes sense: if you pick $M_{ij}$ then you can't pick anything else from row $i$ or from column $j$ .

Example:

For the 3-by-3 matrix $M$ as above, $C_{12}=\begin{pmatrix}M_{21}&M_{23}\\ M_{31}&M_{33}\end{pmatrix}$ .

More generally, we could group terms according to the choice of factor $M_{2k}$ , or $M_{3k}$ , or any other row. The result of expanding about row $i$ would have been: $\det(M)=\pm M_{i1}\det(C_{i1})\mp M_{i2}\det(C_{i2})\pm\cdots,$ where the signs alternate (I'll talk more about exactly which signs occur below).

Or we could group terms according to the choice of entry in column 1, or column 2, etc. The result of expanding down column $j$ would have been $\det(M)=\pm M_{1j}\det(C_{1j})\mp M_{2j}\det(C_{2j})\pm\cdots$ where the signs alternate.

### Signs

The sign you put in front of $M_{ij}\det(C_{ij})$ is the $ij$ th entry of this matrix: $\begin{pmatrix}+&-&+&-&\cdots\\ -&+&-&+&\cdots\\ +&-&+&-&\cdots\\ -&+&-&+&\cdots\\ \vdots&\vdots&\vdots&\vdots&\ddots\end{pmatrix}$ For example, expanding a 3-by-3 matrix down column 2 would give $-M_{12}\det(C_{12})+M_{22}\det(C_{22})-M_{32}\det(C_{32}).$

### Examples

Rather than prove any of these formulae, which would be painful for everybody, let's do some examples.

Example:

Let's compute the determinant of $A=\begin{pmatrix}1&2&3\\ 4&5&6\\ 7&8&9\end{pmatrix}$ using the cofactor expansion along the first row: $\det(A)=1\times\det\begin{pmatrix}5&6\\ 8&9\end{pmatrix}-2\det\begin{pmatrix}4&6\\ 7&9\end{pmatrix}+3\det\begin{pmatrix}4&5\\ 7&8\end{pmatrix}$ $=5\times 9-6\times 8-2(4\times 9-6\times 7)+3(4\times 8-5\times 7)$ $=45-48-2(36-42)+3(32-35)$ $=-3+12-9$ $=0.$

Example:

Just for comparison, let's expand down the first column (I said row in the video): $\det(A)=1\det\begin{pmatrix}5&6\\ 8&9\end{pmatrix}-4\det\begin{pmatrix}2&3\\ 8&9\end{pmatrix}+7\det\begin{pmatrix}2&3\\ 5&6\end{pmatrix}$ $=-3-4(18-24)+7(12-15)$ $=-3+24-21$ $=0.$ Which, reassuringly, gives the same answer.

Example:

Let's calculate the determinant of $B=\begin{pmatrix}1&1&2&3\\ 0&0&4&5\\ -1&2&1&1\\ 0&0&2&3\end{pmatrix}$ Expanding along the top row would give us four terms to calculate. If instead we expand around the first or second columns or the second or fourth rows, then we only have two terms to calculate. Let's do the second column (because the signs will be more fun that way).

We get: $\det(B)=-1\det\begin{pmatrix}0&4&5\\ -1&1&1\\ 0&2&3\end{pmatrix}-2\det\begin{pmatrix}1&2&3\\ 0&4&5\\ 0&2&3\end{pmatrix}$ (care with signs!). For the first 3-by-3 submatrix ($C_{12}$ ) we have (expanding down the first column): $\det\begin{pmatrix}0&4&5\\ -1&1&1\\ 0&2&3\end{pmatrix}=-(-1)(4\times 3-5\times 2)=2$ For the second, we get (expanding down the first column): $\det\begin{pmatrix}1&2&3\\ 0&4&5\\ 0&2&3\end{pmatrix}=4\times 3-5\times 2=2,$ so overall we get $\det(B)=-1\times 2-2\times 2=-6.$

Example:

As a final sanity check, let's compute this again using row operations. If we do $R_{3}\mapsto R_{3}+R_{1}$ , then $B$ becomes $\begin{pmatrix}1&1&2&3\\ 0&0&4&5\\ 0&3&3&4\\ 0&0&2&3\end{pmatrix}.$ Now we switch $R_{2}\leftrightarrow R_{3}$ and then $R_{3}\leftrightarrow R_{4}$ (so the original row 2 ends up at the bottom) to get: $\begin{pmatrix}1&1&2&3\\ 0&3&3&4\\ 0&0&2&3\\ 0&0&4&5\end{pmatrix}.$ Finally $R_{4}\mapsto R_{4}-2R_{3}$ yields: $\begin{pmatrix}1&1&2&3\\ 0&3&3&4\\ 0&0&2&3\\ 0&0&0&-1\end{pmatrix}.$ This is in echelon form. We did two row-switches, so the determinant changed sign twice (i.e. didn't change sign overall), so that $\det(B)$ is just the product of the diagonal entries in this echelon matrix. In other words, $\det(B)=1\times 3\times 2\times(-1)=-6,$ which agrees with the previous example.