This week we'll discuss the determinant of a matrix (Chapter 5).
The determinant is a certain number defined for any square matrix that can be used to check invertibility. It has a ton of interesting and useful properties, including a geometric interpretation in terms of linear transformations and volume. However, it's actually pretty tough to give a simple definition for the determinant, and the most straightforward definition isn't the easiest one to use. So, we'll begin with some small cases.
The determinant of a \(1 \times 1\) matrix \(A = \begin{bmatrix} a \end{bmatrix}\) is just the number \(a.\) This is not interesting.
Let \(A = \begin{bmatrix} a & b \\ c & d \end{bmatrix}\) be a \(2 \times 2\) matrix. You may recall that when we talked about matrix inverses, we gave a simple formula for the inverse of a \(2 \times 2\) matrix: \[ A^{-1} = \frac{1}{ad-bc} \begin{bmatrix} d & -b \\ -c & a \end{bmatrix}.\] This formula doesn't make sense if \(ad-bc=0,\) and in fact, in this case \(A\) is not invertible. (If \(ad-bc=0,\) observe that \(d\) times the first column of \(A\) equals \(c\) times the second column of \(A.\) If \((c, d) \neq (0,0),\) this proves that the columns are linearly dependent. If \(c = d = 0,\) then the columns are also linearly dependent since they both are of the form \((x, 0).\) Therefore \(A\) is not invertible.)
This quantity \(ad-bc\) is called the determinant of the matrix \(A.\)
Definition (determinant of 2x2 matrix)
The determinant of the \(2 \times 2\) matrix \(A = \begin{bmatrix} a & b \\ c & d \end{bmatrix}\) is \[\text{det}(A) = ad - bc.\]
The key property of the determinant is that a matrix is invertible if and only if its determinant is nonzero. Because we have an explicit formula for the inverse in the \(2 \times 2\) case, this is easy to see here. However, this property will continue to hold for matrices of any size.
Here is the definition of the determinant in the \(3 \times 3\) case:
Definition (determinant of 3x3 matrix)
The determinant of the \(3 \times 3\) matrix \(A = \begin{bmatrix} a & b & c \\ d & e & f \\ g & h & i \end{bmatrix}\) is \[\text{det}(A) = aei + bfg + cdh - afh - bdi - ceg.\]
As you can see, this definition is substantially messier than the \(2 \times 2\) case. Luckily, there is a nice trick to work with this formula visually. Given a \(3 \times 3\) matrix, take its first two columns and copy them over to the right of the matrix (so that we have columns 1, 2, 3, 1, 2 from left to right): \[ \begin{bmatrix} a & b & c & a & b \\ d & e & f & d & e\\ g & h & i & g & h \end{bmatrix} \] There are three diagonals in the resulting grid that look like \(\searrow\), and three diagonals that look like \(\swarrow.\) On each such line, multiply the three entries. Then add the ones for the \(\searrow\) diagonals, and subtract the ones for the \(\swarrow\) diagonals. You'll see that the \(\searrow\) diagonals give the terms \(aei,\) \(bfg,\) and \(cdh,\) while the \(\swarrow\) diagonals give the terms \(afh,\) \(bdi,\) and \(ceg.\)
Example (3x3 determinant trick)
To compute the determinant of \(A = \begin{bmatrix} 1 & 2 & 0 \\ -1 & -2 & 1 \\ 0 & 0 & 1 \end{bmatrix}\), we write out the first two columns again to get \[\begin{bmatrix} 1 & 2 & 0 & 1 & 2 \\ -1 & -2 & 1 & -1 & -2 \\ 0 & 0 & 1 & 0 & 0 \end{bmatrix}.\] The three \(\searrow\) diagonals give us the terms \((1)(-2)(1) = -2,\) \((2)(1)(0) = 0,\) and \((0)(-1)(0) = 0.\) The three \(\swarrow\) diagonals give us the terms \((0)(-2)(0) = 0,\) \((1)(1)(0) = 0,\) and \((2)(-1)(1) = -2.\) Therefore, \[\text{det}(A) = -2 + 0 + 0 - 0 - 0 - (-2) = 0.\] Because \(\det(A) = 0,\) this should mean that \(A\) is not invertible. Indeed, this is the case because the first two columns are scalar multiples of each other.
Be warned: this method will NOT extend to \(4 \times 4\) matrices and higher! This only works in the \(3 \times 3\) case because the number of terms is comparatively small.
Once again, it is true that \(A\) is invertible if and only if \(\det(A) \neq 0.\) However, in the \(3 \times 3\) case, it is already very difficult to see why this is true. We'll revisit this after the next section, in which we give the full definition of the determinant for any \(n \times n\) matrix.
There are several methods to compute the determinant of an \(n \times n\) matrix in general. One popular method, which we'll see on Wednesday, is a recursive procedure called Laplace expansion. (Laplace is a French name, pronounced "luh-ploss.") For today, we will look at the Leibniz formula for computing the determinant, which is theoretically valuable but extremely inpractical to actually use. Then, by analyzing the Leibniz formula, we'll see how row reduction can be used to compute the determinant much more easily.
Note: This presentation of the determinant is quite different than the one in your textbook. They do not mention the definition I'm about to present at all; however, I believe that it is important to see the following concepts, even if you won't actually use them to compute a determinant. (They also refer to Laplace expansion by an alternate name, cofactor expansion.)
To even write down the Leibniz formula, we will need some definitions. (As a warning, these are not standard terminology.)
Definition (pattern in a matrix)
Let \(A = \begin{bmatrix} a_{11} & a_{12} & \dotsm & a_{1n} \\ a_{21} & a_{22} & \dotsm & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{n1} & a_{n2} & \dotsm & a_{nn} \end{bmatrix}\) be an \(n \times n\) matrix. A pattern in \(A\) is a way to choose \(n\) entries in \(A\) such that each row and each column contains one of the chosen entries.
For instance, in a \(3 \times 3\) matrix \(A = \begin{bmatrix} a & b & c \\ d & e & f \\ g & h & i \end{bmatrix}\), there are six different patterns: \[\begin{bmatrix} \boxed{a} & b & c \\ d & \boxed{e} & f \\ g & h & \boxed{i} \end{bmatrix}, \quad \begin{bmatrix} a & \boxed{b} & c \\ d & e & \boxed{f} \\ \boxed{g} & h & i \end{bmatrix}, \quad \begin{bmatrix} a & b & \boxed{c} \\ \boxed{d} & e & f \\ g & \boxed{h} & i \end{bmatrix}, \quad \begin{bmatrix} \boxed{a} & b & c \\ d & e & \boxed{f} \\ g & \boxed{h} & i \end{bmatrix}, \quad \begin{bmatrix} a & \boxed{b} & c \\ \boxed{d} & e & f \\ g & h & \boxed{i} \end{bmatrix}, \quad \begin{bmatrix} a & b & \boxed{c} \\ d & \boxed{e} & f \\ \boxed{g} & h & i \end{bmatrix}.\] You may notice that these correspond to the six terms in the formula for a \(3 \times 3\) determinant, \[\det(A) = aei + bfg + cdh - afh - bdi - ceg.\] This will be true for determinants in general: there will be one term for each pattern, consisting of the product of the numbers in the pattern. The only thing left to understand is which terms are added and which are subtracted in the formula.
Remark (How many patterns?)
In general, the number of patterns in an \(n \times n\) matrix is the product \(n(n-1)(n-2)\cdots(2)(1).\) This is because, going row by row, there are \(n\) choices for the entry in the first row, then \(n-1\) choices for the entry in the second row, and so on down to 1. This number is called \(n\) factorial and is denoted \(n!\).
The factorial numbers grow extremely quickly; in fact, they grow faster than every exponential function. We have \(2! = 2 \cdot 1 = 2\) and \(3! = 3 \cdot 2 \cdot 1 = 6,\) matching the number of terms in the formulas for \(2 \times 2\) and \(3 \times 3\) determinants. However, \(4! = 4 \cdot 3 \cdot 2 \cdot 1 = 24\) and \(5! = 5 \cdot 4 \cdot 3 \cdot 2 \cdot 1 = 120,\) which will already produce formulas that are inpractical to compute by hand. Going a bit further, \(10!\) is already in the millions: \(10! = 3,\!628,\!800.\)
Here is the definition that will help us determine which terms are added and subtracted:
Definition (inversion in a pattern)
An inversion in a pattern is a pair of entries in the pattern, one of which is above and to the right of the other.
Therefore, the six patterns shown above have respectively \(0,\) \(2,\) \(2,\) \(1,\) \(1,\) and \(3\) inversions. (For example, in the second pattern, \(g\) and \(b\) form an inversion, as do \(g\) and \(f,\) but \(b\) and \(f\) do not form an inversion.)
With this idea, you may be able to see the pattern (pun intended): a pattern will be added in the formula if it has an even number of inversions, and subtracted if it has an odd number of inversions. In other words, the sign (\(+1\) or \(-1\)) of a pattern will equal \(-1\) raised to the power of the number of inversions.
Finally, with all this said, we can state the complete formula for the determinant of an \(n \times n\) matrix:
Definition (determinant in general)
The determinant of an \(n \times n\) matrix \(A\) is \[\det(A) = \sum_{\text{patterns in } A} (-1)^{\# \text{ inversions}} \; (\text{product of entries in pattern}).\] That is, for each of the \(n!\) patterns in \(A,\) we take the product of the numbers in \(A\). We then put a sign on this number: \(+\) if there are an even number of inversions in the pattern, or \(-\) if there are an odd number of inversions. Then we add up all these signed terms to get the determinant.
As previously stated, this formula has great theoretical significance — we'll use it shortly to derive some essential facts about the determinant — but is really terrible for actually computing a determinant, because \(n!\) grows so quickly.
Now that we have the complete definition for the determinant, let's see why this strange definition actually produces a number with the magic property I claimed it has: namely, a matrix \(A\) is invertible if and only if \(\det(A) \neq 0.\) To understand why this is true, we'll establish a pretty long list of facts about the determinant. These facts will be useful in their own right as well.
Determinant Fact #1 (all-zeros row/column)
If \(A\) has a row of all zeros, or a column of all zeros, then \(\det(A) = 0.\)
Why is this true? Let's suppose \(A\) has a row of all zeros. Notice that every pattern in \(A\) must contain one of the entries from that row (since it must contain one entry from every row and column). Then the product of the entries in that pattern must be zero. But \(\det(A)\) is just a sum of these products with certain signs, so \(\det(A) = 0\) too, as we claimed. The same logic works if \(A\) instead has a column of all zeros.
Determinant Fact #2 (triangular matrices)
If \(A\) is triangular, then \(\det(A)\) equals the product of the entries of \(A\) along the diagonal: \(\det(A) = a_{11} a_{22} \dotsm a_{nn}.\)
The relevant definitions here: a square matrix is upper triangular if all the entries below the diagonal are zero (in other words, all nonzero entries are on or above the diagonal). It is lower triangular if all the entries above the diagonal are zero (all nonzero entries are on or below the diagonal). Finally, a matrix is triangular if it is either upper triangular or lower triangular.
For example, \(\begin{bmatrix} 1 & 2 & 3 \\ 0 & 4 & 5 \\ 0 & 0 & 6 \end{bmatrix}\) is upper triangular, while \(\begin{bmatrix} 1 & 0 & 0 \\ 2 & 3 & 0 \\ 4 & 5 & 6 \end{bmatrix}\) is lower triangular. (Both are triangular.)
Why is this fact true? The key idea is to consider which patterns can have a nonzero product. In our upper triangular example, for a pattern to have a nonzero product, it has to have the first entry in the first column (since all the other entries are zeros). But then, it must have the second entry in the second column (since it can't also have the first entry in that column, and all other entries are zeros). This continues for every column, and we see that the only pattern we can get is the one where we just take all the diagonal entries. All other patterns will necessarily have a zero. This pattern has no inversions, so its sign is \((-1)^0 = +1,\) and therefore \(\det(A)\) is just the product of the entries in that pattern, which is what we claimed. Similar logic applies to the lower triangular example.
In particular, the determinant of the identity matrix is always 1:
Determinant Fact #3 (identity matrix)
We have \(\det(I_n) = 1\) for all \(n.\)
Next, we'll introduce a trio of Determinant Facts that concern what row operations do to a determinant.
Determinant Fact #4 (scaling rows/columns)
Suppose that we multiply a row (or column) of \(A\) by a scalar \(c\) to get \(B.\) Then \[\det(B) = c \cdot \det(A).\] In other words, scaling a row (or a column) multiplies the determinant by that amount.
To see why this is true, we again think about patterns. Because of the definition, every pattern in \(A\) will contain exactly one entry from the row (or column) we are scaling. Therefore, scaling that row (or column) by \(c\) will cause every term in \(\det(A)\) to be multiplied by \(c.\) Therefore, \(\det(A)\) will also be multiplied by \(c.\)
Here are two final facts about the determinant, which I won't prove, but can also be shown by analyzing patterns:
Determinant Fact #5 (switching rows/columns)
Suppose that we switch two rows (or two columns) of \(A\) to get \(B.\) Then \[\det(B) = -\det(A).\] In other words, switching two rows or two columns negates the determinant.
Determinant Fact #6 (adding a multiple of a row/column to another)
Suppose that, in \(A,\) we add a multiple of one row to another row (or add a multiple of one column to another column) to get \(B.\) Then \[\det(B) = \det(A).\] In other words, adding a multiple of one row to another row (or adding a multiple of one column to another column) does not change the determinant.