Math - Determinant

Cofactor Expansion, Row Swaps, Singular Matrices, Row Operations, Signed Volume Scaling Factor, Why det(AB) = det(A) det(B), Orthogonal Matrices

Posted by Rico's Nerd Cluster on February 27, 2017

1. Definition: Cofactor Expansion

The determinant can be defined recursively. For an \(N\times N\) matrix with rows \(\mathbf r_1, \dots, \mathbf r_N\),

\[\begin{gather*} A=\begin{bmatrix}\mathbf r_1\\ \mathbf r_2\\ \vdots\\ \mathbf r_N\end{bmatrix}, \qquad \det(A)=\sum_{j=1}^{N}(-1)^{1+j}\,a_{1j}\,\det(M_{1j}) \end{gather*}\]

where:

  • \(a_{1j}\) is the \(j\)-th element of the first row.
  • \(M_{1j}\) is the \((N-1)\times(N-1)\) matrix obtained by deleting row 1 and column \(j\).
  • \((-1)^{1+j}\) generates the alternating signs.

The recursion stops at a \(1\times1\) matrix, where \(\det([a]) = a\). For example, for \(N=2\) this gives \(\det(A) = a_{11}a_{22} - a_{12}a_{21}\).

2. Swapping Two Rows Flips The Sign

2.1 For A 3×3 Matrix

Using the scalar triple product:

\[\begin{gather*} \det(A)=\mathbf r_1\cdot(\mathbf r_2\times\mathbf r_3) \end{gather*}\]

Swap rows 2 and 3:

\[\begin{gather*} \begin{aligned} \det(A') &=\mathbf r_1\cdot(\mathbf r_3\times\mathbf r_2)\\ &=-\mathbf r_1\cdot(\mathbf r_2\times\mathbf r_3)\\ &=-\det(A) \end{aligned} \end{gather*}\]

This follows from the antisymmetry of the cross product:

\[\begin{gather*} \mathbf u\times\mathbf v=-\mathbf v\times\mathbf u \end{gather*}\]

This only covers one swap of one size of matrix, so it is an incomplete proof. The general case is below.

2.2 For An N×N Matrix

We use induction on \(N\). For \(N=2\), swapping the rows gives \(a_{21}a_{12} - a_{22}a_{11} = -(a_{11}a_{22} - a_{12}a_{21})\).

Now assume the claim holds for \((N-1)\times(N-1)\) matrices.

Swapping two rows \(i, k \ge 2\). Row 1 is untouched, so every \(a_{1j}\) stays the same. Each minor \(M_{1j}\) still contains both rows, just swapped, so by induction each \(\det(M_{1j})\) flips sign. Therefore the whole sum flips sign.

Swapping rows 1 and 2. Expand twice: first along row 1, then each minor along its first row, which is row 2 of \(A\). Every term then has the form

\[\begin{gather*} \varepsilon(j,l)\; a_{1j}\,a_{2l}\,\det(M_{12,jl}),\qquad j\neq l \end{gather*}\]

where \(M_{12,jl}\) deletes rows 1, 2 and columns \(j, l\). Column \(l\) sits at position \(l\) in \(M_{1j}\) if \(l<j\), and at position \(l-1\) if \(l>j\), because column \(j\) was removed. So for \(j<l\):

\[\begin{gather*} \varepsilon(j,l)=(-1)^{1+j}(-1)^{1+(l-1)}=(-1)^{j+l+1}, \qquad \varepsilon(l,j)=(-1)^{1+l}(-1)^{1+j}=(-1)^{j+l} \end{gather*}\]

That is, \(\varepsilon(l,j) = -\varepsilon(j,l)\). Swapping rows 1 and 2 turns \(a_{1j}a_{2l}\) into \(a_{2j}a_{1l}\), so that product now carries the sign \(\varepsilon(l,j)\) instead of \(\varepsilon(j,l)\), while \(M_{12,jl}\) is unchanged. Every term flips sign, so the determinant flips sign.

Swapping rows 1 and \(k\), with \(k>2\). Do it in three swaps: swap rows 2 and \(k\), then rows 1 and 2, then rows 2 and \(k\). That is three sign flips, which is one net flip.

\[\begin{gather*} \boxed{\text{Swapping any two rows multiplies }\det(A)\text{ by }-1} \end{gather*}\]

A direct consequence: if two rows are equal, swapping them leaves \(A\) unchanged but flips the sign, so \(\det(A) = -\det(A) = 0\).

3. A Singular Matrix Has Determinant 0

A matrix is singular when its rows are linearly dependent, i.e. some row is a linear combination of the others.

3.1 For A 3×3 Matrix

Say the third row is a combination of the first two:

\[\begin{gather*} A=\begin{bmatrix}\mathbf r_1\\ \mathbf r_2\\ k\mathbf r_1+j\mathbf r_2\end{bmatrix} \end{gather*}\]

Then

\[\begin{gather*} \det(A)=\mathbf r_1\cdot\big(\mathbf r_2\times(k\mathbf r_1+j\mathbf r_2)\big) =k\,\mathbf r_1\cdot(\mathbf r_2\times\mathbf r_1)+j\,\mathbf r_1\cdot(\mathbf r_2\times\mathbf r_2) \end{gather*}\]

Since \(\mathbf r_2\times\mathbf r_2=\mathbf 0\), only \(\mathbf r_2\times k\mathbf r_1\) can be nonzero. But that vector is perpendicular to \(\mathbf r_1\), so its dot product with \(\mathbf r_1\) is 0. Therefore \(\det(A)=0\).

3.2 For An N×N Matrix

The idea for larger matrices comes from the recursive definition: for a 4×4 matrix, if rows 2 to 4 are dependent, then the rows of every minor \(M_{1j}\) are dependent too, so every \(\det(M_{1j})=0\) by the 3×3 case, and so is \(\det(A)\). The same goes for 5×5 and up.

This needs one more step, because the dependence might involve row 1. Two facts make that easy:

  • The determinant is linear in row 1. In the cofactor expansion, the minors \(M_{1j}\) never contain row 1, so \(\det\) is a linear function of \(a_{11},\dots,a_{1N}\). With row swaps, the same holds for any row.
  • Two equal rows give determinant 0, from Section 2.

Now say \(\mathbf r_k=\sum_{i\neq k}c_i\mathbf r_i\). Swap row \(k\) into row 1, which only flips the sign, and use linearity in row 1:

\[\begin{gather*} \det(A)=-\det\begin{bmatrix}\sum_{i\neq k}c_i\mathbf r_i\\ \vdots\end{bmatrix} =-\sum_{i\neq k}c_i\det\begin{bmatrix}\mathbf r_i\\ \vdots\end{bmatrix} \end{gather*}\]

Each matrix on the right has \(\mathbf r_i\) in row 1 and also somewhere below, so it has two equal rows and its determinant is 0. Therefore

\[\begin{gather*} \boxed{A\text{ singular}\;\Rightarrow\;\det(A)=0} \end{gather*}\]

4. Adding A Combination Of Other Rows Does Not Change The Determinant

This is the row operation used in Gaussian elimination, so it is worth seeing why it is safe. It follows from two facts.

First, the determinant is linear in each row, as shown in Section 3.2: with the other rows held fixed, \(\det\) is a linear function of one row. For example, scaling one row by \(c\) scales the determinant by \(c\):

\[\begin{gather*} \det\begin{bmatrix}\mathbf r_1\\ \mathbf r_2\\ c\,\mathbf r_3\end{bmatrix}=c\,\det\begin{bmatrix}\mathbf r_1\\ \mathbf r_2\\ \mathbf r_3\end{bmatrix} \end{gather*}\]

Note that this is linearity in one row at a time, not in the whole matrix. Scaling the whole \(N\times N\) matrix scales every row, so \(\det(cA)=c^N\det(A)\), not \(c\det(A)\).

Second, two equal rows give determinant 0, from Section 2.

Now add \(c\) times row 1 to row 3:

\[\begin{gather*} A=\begin{bmatrix}\mathbf r_1\\ \mathbf r_2\\ \mathbf r_3\end{bmatrix}, \qquad A'=\begin{bmatrix}\mathbf r_1\\ \mathbf r_2\\ \mathbf r_3+c\,\mathbf r_1\end{bmatrix} \end{gather*}\]

By linearity in row 3,

\[\begin{gather*} \det(A')=\det\begin{bmatrix}\mathbf r_1\\ \mathbf r_2\\ \mathbf r_3\end{bmatrix}+c\,\det\begin{bmatrix}\mathbf r_1\\ \mathbf r_2\\ \mathbf r_1\end{bmatrix} =\det(A)+c\cdot 0=\det(A) \end{gather*}\]

Adding a linear combination \(\sum_i c_i\mathbf r_i\) of other rows works the same way: linearity splits it into one extra determinant per \(\mathbf r_i\), and each of those has a repeated row, so each is 0.

\[\begin{gather*} \boxed{\det\big(\dots,\ \mathbf r_k+\textstyle\sum_{i\neq k}c_i\mathbf r_i,\ \dots\big)=\det(A)} \end{gather*}\]

4.1 Example: Eliminating An Entry

\[\begin{gather*} M=\begin{bmatrix}2&1\\ 6&5\end{bmatrix} \end{gather*}\]

We can eliminate the 6 with

\[\begin{gather*} R_2\leftarrow R_2-3R_1 \end{gather*}\]

giving

\[\begin{gather*} M'=\begin{bmatrix}2&1\\ 0&2\end{bmatrix} \end{gather*}\]

Check: \(\det(M)=2\cdot5-1\cdot6=4\) and \(\det(M')=2\cdot2-1\cdot0=4\). Same determinant.

4.2 Block Triangular Matrices

Let

\[\begin{gather*} M=\begin{bmatrix}A&0\\ C&D\end{bmatrix} \end{gather*}\]

where \(A\) and \(D\) are square. Assume \(A\) is invertible for now. Since adding a linear combination of other rows to a row doesn’t change the determinant, we can clear \(C\) the same way we cleared the 6 above:

\[\begin{gather*} \text{Rows}(C) \leftarrow \text{Rows}(C)-CA^{-1}\,\text{Rows}(A) \end{gather*}\]

Each row of the bottom block gets a combination of the top rows \(\begin{bmatrix}A&0\end{bmatrix}\) subtracted from it:

\[\begin{gather*} \begin{bmatrix}C&D\end{bmatrix}-CA^{-1}\begin{bmatrix}A&0\end{bmatrix}=\begin{bmatrix}0&D\end{bmatrix} \end{gather*}\]

Therefore we get

\[\begin{gather*} \boxed{M'=\begin{bmatrix}A&0\\ 0&D\end{bmatrix}},\qquad \det(M)=\det(M') \end{gather*}\]

and for the block diagonal matrix,

\[\begin{gather*} \boxed{\det(M')=\det(A)\det(D)} \end{gather*}\]

To see this last step, use row operations inside each block to bring \(A\) and \(D\) to lower triangular form. These operations never mix the two blocks, and they change \(\det(A)\) or \(\det(D)\) by exactly the same factor (a sign per swap) as they change \(\det(M')\). Now \(M'\) is lower triangular, and a lower triangular matrix has determinant equal to the product of its diagonal: in the cofactor expansion along row 1, only \(a_{11}\) is nonzero, and its minor is again lower triangular. The diagonal of \(M'\) is the diagonal of \(A\) followed by the diagonal of \(D\), so the product splits into \(\det(A)\det(D)\).

If \(A\) is singular, its rows are dependent, so the top rows \(\begin{bmatrix}A&0\end{bmatrix}\) of \(M\) are dependent too. Then \(\det(M)=0=\det(A)\det(D)\) by Section 3, and the formula still holds:

\[\begin{gather*} \boxed{\det\begin{bmatrix}A&0\\ C&D\end{bmatrix}=\det(A)\det(D)} \end{gather*}\]

5. Determinant As A Signed Volume Scaling Factor

Define the signed volume formed by three vectors u, v, w as the scalar triple product:

\[\begin{gather*} V(\mathbf u,\mathbf v,\mathbf w)=\mathbf u^T(\mathbf v\times\mathbf w) \end{gather*}\]

Two properties of V do all the work below:

  • Repeated vectors give zero. If two of the vectors are identical, the parallelepiped is flat, e.g. a_1ᵀ(a_1 × a_2) = 0.
  • Swapping two vectors flips the sign, e.g. a_1ᵀ(a_2 × a_3) = −a_1ᵀ(a_3 × a_2).

Also, V(u, v, w) equals the determinant of the matrix with columns u, v, w (expand the determinant along its first column to see this):

\[\begin{gather*} \mathbf u^T(\mathbf v\times\mathbf w) =\begin{bmatrix}u_1&u_2&u_3\end{bmatrix} \begin{bmatrix} v_2w_3-v_3w_2\\ v_3w_1-v_1w_3\\ v_1w_2-v_2w_1 \end{bmatrix} =\det\begin{bmatrix}\mathbf u&\mathbf v&\mathbf w\end{bmatrix} \end{gather*}\]

We want to prove that applying a linear transformation A scales any signed volume by det(A):

\[\begin{gather*} \boxed{(A\mathbf u)^T\big((A\mathbf v)\times(A\mathbf w)\big)=\det(A)\,\mathbf u^T(\mathbf v\times\mathbf w)} \end{gather*}\]

5.1 Expand In The Standard Basis

Write the three vectors in the standard basis e_1, e_2, e_3:

\[\begin{gather*} \mathbf u=u_1\mathbf e_1+u_2\mathbf e_2+u_3\mathbf e_3 \\ \mathbf v=v_1\mathbf e_1+v_2\mathbf e_2+v_3\mathbf e_3 \\ \mathbf w=w_1\mathbf e_1+w_2\mathbf e_2+w_3\mathbf e_3 \end{gather*}\]

Apply A to each one. For simplicity, define a_i = A e_i, which are just the three columns of A:

\[\begin{gather*} A\mathbf u=u_1\mathbf a_1+u_2\mathbf a_2+u_3\mathbf a_3 \\ A\mathbf v=v_1\mathbf a_1+v_2\mathbf a_2+v_3\mathbf a_3 \\ A\mathbf w=w_1\mathbf a_1+w_2\mathbf a_2+w_3\mathbf a_3 \end{gather*}\]

Now the transformed signed volume is

\[\begin{gather*} V(A\mathbf u,A\mathbf v,A\mathbf w) =(u_1\mathbf a_1+u_2\mathbf a_2+u_3\mathbf a_3)^T \big[(v_1\mathbf a_1+v_2\mathbf a_2+v_3\mathbf a_3)\times(w_1\mathbf a_1+w_2\mathbf a_2+w_3\mathbf a_3)\big] \end{gather*}\]

Since the dot and cross products are both linear in each argument, expanding gives 3³ = 27 terms:

\[\begin{gather*} V(A\mathbf u,A\mathbf v,A\mathbf w)=\sum_{i,j,k=1}^{3}u_iv_jw_k\,\mathbf a_i^T(\mathbf a_j\times\mathbf a_k) \end{gather*}\]

5.2 Only 6 Terms Survive

Every term with a repeated index (i = j, j = k, or i = k) is zero. That leaves the 3! = 6 terms where (i, j, k) is a permutation of (1, 2, 3). Each of those can be swapped back into the order (a_1, a_2, a_3), picking up a minus sign per swap:

\[\begin{gather*} V(A\mathbf u,A\mathbf v,A\mathbf w) =\big(u_1v_2w_3-u_1v_3w_2-u_2v_1w_3+u_2v_3w_1+u_3v_1w_2-u_3v_2w_1\big)\,V(\mathbf a_1,\mathbf a_2,\mathbf a_3) \end{gather*}\]

Every surviving term contains the same V(a_1, a_2, a_3), which is why it factors out.

5.3 Identify The Two Factors

The first factor is exactly the original signed volume. Compare it with the expansion of uᵀ(v × w) above:

\[\begin{gather*} u_1(v_2w_3-v_3w_2)+u_2(v_3w_1-v_1w_3)+u_3(v_1w_2-v_2w_1)=\mathbf u^T(\mathbf v\times\mathbf w) \end{gather*}\]

The second factor is the signed volume of the columns of A, which is det(A):

\[\begin{gather*} \mathbf a_1^T(\mathbf a_2\times\mathbf a_3) =(A\mathbf e_1)^T\big((A\mathbf e_2)\times(A\mathbf e_3)\big) =\det\begin{bmatrix}\mathbf a_1&\mathbf a_2&\mathbf a_3\end{bmatrix} =\det(A) \end{gather*}\]

Therefore,

\[\begin{gather*} \boxed{(A\mathbf u)^T\big((A\mathbf v)\times(A\mathbf w)\big)=\det(A)\,\mathbf u^T(\mathbf v\times\mathbf w)} \end{gather*}\]

So regardless of the original shape or volume formed by u, v, w, applying A scales its signed volume by exactly det(A). In particular, det(A) is the signed volume of the unit cube after A is applied.

6. Why det(AB) = det(A) det(B)

Start with the unit cube formed by e_1, e_2, e_3, whose signed volume is 1.

First, apply B to each vector:

\[\begin{gather*} \mathbf u=B\mathbf e_1,\quad\mathbf v=B\mathbf e_2,\quad\mathbf w=B\mathbf e_3 \end{gather*}\]

These are the columns of B, so the signed volume is now

\[\begin{gather*} V_1=\mathbf u^T(\mathbf v\times\mathbf w)=\det(B) \end{gather*}\]

Then apply A to the transformed vectors. Using the identity from Section 5:

\[\begin{gather*} V_2=(A\mathbf u)^T\big((A\mathbf v)\times(A\mathbf w)\big) =\det(A)\,\mathbf u^T(\mathbf v\times\mathbf w) =\det(A)\det(B) \end{gather*}\]

However, applying B first and then A is the same as applying AB, and AB e_i are the columns of AB:

\[\begin{gather*} V_2=(AB\mathbf e_1)^T\big((AB\mathbf e_2)\times(AB\mathbf e_3)\big)=\det(AB) \end{gather*}\]

Therefore,

\[\begin{gather*} \boxed{\det(AB)=\det(A)\det(B)} \end{gather*}\]

Although this proof uses the 3D scalar triple product, the same argument extends to any N×N matrix. The only properties used were that the volume function is linear in each argument (multilinear) and flips sign when two arguments swap (alternating), and the determinant has both properties in any dimension.

7. Determinant Of An Orthogonal Matrix

For an orthogonal matrix Q (i.e., QᵀQ = I), det(Q) = ±1. Using det(AB) = det(A) det(B) and det(Qᵀ) = det(Q):

\[\begin{gather*} Q^\top Q=I \\ \Rightarrow\det(Q^\top Q)=\det(I)=1 \\ \Rightarrow\det(Q^\top)\det(Q)=1 \\ \Rightarrow(\det Q)^2=1 \\ \Rightarrow\det Q=\pm1 \end{gather*}\]

In the signed volume picture, Q preserves lengths and angles, so the unit cube stays a unit cube. Only its orientation can flip. In particular, if Q ∈ SO(n) (special orthogonal group), then det Q = 1, and a reflection has det Q = −1.

8. Determinant And Eigenvalues

det(A) = ∏ λ_i, counting eigenvalues with multiplicity. The proof compares the constant terms of the characteristic polynomial, the same way as trace equals the sum of eigenvalues. So det(A) = 0 exactly when some eigenvalue is zero, i.e. when A squashes some direction flat and can’t be inverted.