Cofactor Expansion
Cofactor expansion finds the determinant of any square matrix. Pick one row or column, multiply each entry by its cofactor, and add the products. Each cofactor is a smaller determinant with a + or − sign, so a 4 × 4 determinant becomes 3 × 3 ones. Expanding along the line with the most zeros saves the most work.
Before this lesson: Determinant of a Matrix, Invertible Matrix Theorem and LU Decomposition
What cofactor expansion means
You may already know how to find a 3 × 3 determinant by expanding along the first row. Cofactor expansion is the same idea for any size, and it lets you expand along any row or column. The answer is always the same, so you get to choose the easiest line.
Each term pairs an entry with a smaller determinant: the one left after you delete that entry’s row and column. A 4 × 4 determinant breaks into four 3 × 3 determinants, and each of those breaks into 2 × 2 ones. A zero entry kills its whole term, so a row with three zeros leaves only one 3 × 3 determinant to find.
Minors, cofactors and the expansion formula
For an n × n matrix A, the minor Mᵢⱼ is the determinant of the (n − 1) × (n − 1) matrix left after deleting row i and column j. The cofactor Cᵢⱼ is the minor with a sign attached:
C_{ij} = (-1)^{i+j} M_{ij}The sign (−1)ⁱ⁺ʲ is + when i + j is even and − when i + j is odd. That gives a checkerboard of signs that starts with + in the top-left corner. The cofactor expansion (also called the Laplace expansion) along row i, or down column j, is
\det A = a_{i1}C_{i1} + a_{i2}C_{i2} + \cdots + a_{in}C_{in} = a_{1j}C_{1j} + a_{2j}C_{2j} + \cdots + a_{nj}C_{nj}Every row and every column gives the same number, det A. The proof uses the fact that det A can be written as one sum over all n! ways to pick one entry from each row and each column; grouping that sum by the entries of any one row or column gives the formula above.
How to use cofactor expansion
- Choose the row or column with the most zeros.
- For each nonzero entry aᵢⱼ in that line, delete row i and column j and find the minor Mᵢⱼ.
- Attach the sign from the checkerboard: Cᵢⱼ = (−1)ⁱ⁺ʲMᵢⱼ.
- Multiply each entry by its cofactor and add: det A = Σ aᵢⱼCᵢⱼ.
- If a minor is still 3 × 3 or larger, expand it the same way.
A useful result follows right away. For a triangular matrix (all zeros above or below the diagonal), expanding down the first column again and again shows that det A is the product of the diagonal entries.
Cofactor expansion examples
Example 1: Find a minor and a cofactor
Let A = [2 0 1 3; 1 4 0 −2; 5 1 −1 0; 0 3 2 1] (rows separated by semicolons). Find M₂₃ and C₂₃.
M_{23} = \begin{vmatrix} 2 & 0 & 3 \\ 5 & 1 & 0 \\ 0 & 3 & 1 \end{vmatrix}Delete row 2 and column 3 of A.
= 2\begin{vmatrix} 1 & 0 \\ 3 & 1 \end{vmatrix} - 0\begin{vmatrix} 5 & 0 \\ 0 & 1 \end{vmatrix} + 3\begin{vmatrix} 5 & 1 \\ 0 & 3 \end{vmatrix}Expand along row 1 (see 3 × 3 determinants).
= 2(1 - 0) - 0 + 3(15 - 0)
Find each 2 × 2 determinant as ad − bc.
= 2 + 45
Multiply.
= 47
Add.
C_{23} = (-1)^{2+3} M_{23}Write the cofactor formula with i = 2 and j = 3.
= (-1)^{5}(47)Add the exponents: 2 + 3 = 5.
= -47
An odd power of −1 is −1.
Answer: M₂₃ = 47 and C₂₃ = −47. The sign chart agrees: position (2, 3) holds a minus sign.
Example 2: A column with one nonzero entry
Find det A for A = [3 0 2 −1; 1 0 4 2; −2 5 1 3; 4 0 −3 1].
\det A = 5C_{32}Column 2 is (0, 0, 5, 0), so expand down column 2. Only a₃₂ = 5 gives a nonzero term.
C_{32} = (-1)^{3+2}M_{32} = -M_{32}Position (3, 2) has 3 + 2 = 5, an odd sum, so the sign is −.
M_{32} = \begin{vmatrix} 3 & 2 & -1 \\ 1 & 4 & 2 \\ 4 & -3 & 1 \end{vmatrix}Delete row 3 and column 2.
= 3\begin{vmatrix} 4 & 2 \\ -3 & 1 \end{vmatrix} - 2\begin{vmatrix} 1 & 2 \\ 4 & 1 \end{vmatrix} + (-1)\begin{vmatrix} 1 & 4 \\ 4 & -3 \end{vmatrix}Expand along row 1.
= 3(4 + 6) - 2(1 - 8) + (-1)(-3 - 16)
Find each 2 × 2 determinant.
= 30 + 14 + 19
Multiply (see multiplying integers).
= 63
Add.
\det A = 5(-63)
Substitute C₃₂ = −63.
= -315
Multiply.
Answer: det A = −315. Expanding along row 1 would have needed three 3 × 3 determinants instead of one.
Example 3: A row with two zeros
Find det A for A = [1 2 0 3; 0 1 0 −1; 2 −1 3 0; 4 0 1 2].
\det A = 1 \cdot C_{22} + (-1)C_{24}Row 2 is (0, 1, 0, −1). Expand along row 2; the two zeros drop out.
C_{22} = (+1)\begin{vmatrix} 1 & 0 & 3 \\ 2 & 3 & 0 \\ 4 & 1 & 2 \end{vmatrix}Delete row 2 and column 2. The sign at (2, 2) is +.
= 1(6 - 0) - 0 + 3(2 - 12)
Expand along row 1 and find each 2 × 2 determinant.
= 6 - 30
Multiply.
= -24
Subtract.
C_{24} = (+1)\begin{vmatrix} 1 & 2 & 0 \\ 2 & -1 & 3 \\ 4 & 0 & 1 \end{vmatrix}Delete row 2 and column 4. The sign at (2, 4) is + because 2 + 4 = 6 is even.
= 1(-1 - 0) - 2(2 - 12) + 0
Expand along row 1 and find each 2 × 2 determinant.
= -1 + 20
Multiply.
= 19
Add.
\det A = 1(-24) + (-1)(19)
Substitute the two cofactors.
= -24 - 19
Multiply.
= -43
Subtract.
Answer: det A = −43.
Example 4: A 5 × 5 triangular matrix
Find det A for the upper triangular matrix A = [2 1 −3 0 5; 0 −1 4 2 1; 0 0 3 −2 6; 0 0 0 1 7; 0 0 0 0 4].
\det A = 2\begin{vmatrix} -1 & 4 & 2 & 1 \\ 0 & 3 & -2 & 6 \\ 0 & 0 & 1 & 7 \\ 0 & 0 & 0 & 4 \end{vmatrix}Expand down column 1. Only a₁₁ = 2 is nonzero, and its sign is +.
= 2(-1)\begin{vmatrix} 3 & -2 & 6 \\ 0 & 1 & 7 \\ 0 & 0 & 4 \end{vmatrix}Expand the 4 × 4 down its first column the same way.
= 2(-1)(3)\begin{vmatrix} 1 & 7 \\ 0 & 4 \end{vmatrix}Expand the 3 × 3 down its first column.
= 2(-1)(3)(4 - 0)
Find the 2 × 2 determinant.
= -24
Multiply.
Answer: det A = −24, the product of the diagonal entries 2, −1, 3, 1 and 4. The entries above the diagonal never matter.
Example 5: Can every nutrient target be met?
A pet-food maker blends four ingredients. Per scoop, ingredient 1 gives 3 g protein and 1 g fiber; ingredient 2 gives 1 g protein and 2 g fat; ingredient 3 gives 4 g fiber and 1 g calcium; ingredient 4 gives 2 g protein, 1 g fat and 3 g calcium. Does every target for protein, fat, fiber and calcium have exactly one blend that meets it?
A = \begin{bmatrix} 3 & 1 & 0 & 2 \\ 0 & 2 & 0 & 1 \\ 1 & 0 & 4 & 0 \\ 0 & 0 & 1 & 3 \end{bmatrix}Rows are protein, fat, fiber and calcium; columns are the ingredients.
\det A = 2C_{22} + 1 \cdot C_{24}Expand along row 2, (0, 2, 0, 1).
C_{22} = (+1)\begin{vmatrix} 3 & 0 & 2 \\ 1 & 4 & 0 \\ 0 & 1 & 3 \end{vmatrix}Delete row 2 and column 2. The sign is +.
= 3(12 - 0) - 0 + 2(1 - 0)
Expand along row 1 and find each 2 × 2 determinant.
= 36 + 2
Multiply.
= 38
Add.
C_{24} = (+1)\begin{vmatrix} 3 & 1 & 0 \\ 1 & 0 & 4 \\ 0 & 0 & 1 \end{vmatrix}Delete row 2 and column 4. The sign is +.
= 1\begin{vmatrix} 3 & 1 \\ 1 & 0 \end{vmatrix}Expand along row 3; only its last entry, 1, is nonzero, and position (3, 3) has sign +.
= 0 - 1
Find the 2 × 2 determinant: 3(0) − 1(1).
= -1
Subtract.
\det A = 2(38) + 1(-1)
Substitute the two cofactors.
= 76 - 1
Multiply.
= 75
Subtract.
Answer: det A = 75, which is not 0, so A is invertible. By the invertible matrix theorem, Ax = b has exactly one solution for every target b. (Some targets may need a negative amount of an ingredient, so the maker still checks that each amount is 0 or more.)
Common mistakes
| Mistake | Example of the error | Fix |
|---|---|---|
| Forgetting the sign | Using C₂₃ = M₂₃ | Cᵢⱼ = (−1)ⁱ⁺ʲMᵢⱼ. Position (2, 3) has an odd sum, so C₂₃ = −M₂₃. |
| Using the row 1 signs on another row | Expanding along row 2 with + − + − | Row 2 starts with −: its signs are − + − +. |
| Deleting the wrong row or column | Deleting row 3 and column 3 to find M₃₂ | Mᵢⱼ deletes row i and column j, the entry’s own row and column. |
| Mixing a row and a column | Using a₁₁, a₂₁ with C₁₁, C₁₂ | Every term must come from the same line: entry aᵢⱼ always pairs with its own cofactor Cᵢⱼ. |
| Expanding along a line with no zeros | Expanding a 4 × 4 along row 1 when column 2 has three zeros | Scan every row and column first and expand along the one with the most zeros. |
Related ideas
Why expansion gets slow. Full cofactor expansion of an n × n matrix ends in n! products. That is 24 products for a 4 × 4 matrix but about 3.6 million for a 10 × 10 one. For large matrices, row-reduce to triangular form instead and multiply the pivots, as in LU decomposition. The next lesson, Properties of Determinants, shows how each row operation changes the determinant, so you can mix the two methods.
Cofactors and the inverse. The cofactors of A also build its inverse, through the adjugate matrix (coming soon in this unit). For 2 × 2 and 3 × 3 matrices, see inverse matrices and Cramer’s rule.
Practice problems
- Let A = [4 −1 2; 3 5 0; 1 −2 6]. Find M₂₁ and C₂₁.
- What sign does C₄₄ have in a 4 × 4 matrix? What sign does C₅₂ have in a 5 × 5 matrix?
- Find det A for A = [2 0 1; 3 4 −1; 1 0 5] by expanding down column 2.
- Find det A for A = [1 3 −2 4; 0 0 2 0; 5 −1 0 2; 3 1 1 −1].
- Find det A for A = [2 1 0 −1; 3 0 1 2; 1 4 0 3; 0 2 5 1] by expanding down column 3.
- Find det A for the lower triangular matrix A = [3 0 0 0; 7 −2 0 0; −1 4 5 0; 2 9 −3 2].
- For which value of k is A = [1 0 2 0; 0 k 0 1; 3 0 4 0; 0 2 0 1] not invertible?
- Find det A for A = [3 −1 4 2; 0 0 0 0; 5 2 −6 1; 7 0 3 −2].
- Find det A for A = [1 0 2 0 3; 0 0 1 4 0; 2 3 −1 0 1; 0 0 0 2 1; 0 0 1 0 −1].
- The pet-food maker in Example 5 replaces ingredient 4 with a new one that gives 4 g protein, 2 g fat, 5 g fiber and 1 g calcium per scoop. Does every target still have exactly one blend?
Show answers
1.
M_{21} = \begin{vmatrix} -1 & 2 \\ -2 & 6 \end{vmatrix}Delete row 2 and column 1.
= -6 - (-4)
Find ad − bc: (−1)(6) − (2)(−2).
= -2
Subtract.
C_{21} = (-1)^{2+1}(-2)Attach the sign; 2 + 1 = 3 is odd.
= 2
Multiply.
Answer: M₂₁ = −2 and C₂₁ = 2.
2.
(-1)^{4+4} = (-1)^{8} = 1For C₄₄, the sum 4 + 4 = 8 is even.
(-1)^{5+2} = (-1)^{7} = -1For C₅₂, the sum 5 + 2 = 7 is odd.
Answer: C₄₄ has sign + and C₅₂ has sign −. Every diagonal position has sign +.
3.
\det A = 4C_{22}Column 2 is (0, 4, 0), so only a₂₂ = 4 counts.
C_{22} = (+1)\begin{vmatrix} 2 & 1 \\ 1 & 5 \end{vmatrix}Delete row 2 and column 2. The sign is +.
= 10 - 1
Find ad − bc.
= 9
Subtract.
\det A = 4(9) = 36
Multiply.
Answer: det A = 36.
4.
\det A = 2C_{23}Row 2 is (0, 0, 2, 0), so expand along row 2.
C_{23} = -\begin{vmatrix} 1 & 3 & 4 \\ 5 & -1 & 2 \\ 3 & 1 & -1 \end{vmatrix}Delete row 2 and column 3. The sign at (2, 3) is −.
\begin{vmatrix} 1 & 3 & 4 \\ 5 & -1 & 2 \\ 3 & 1 & -1 \end{vmatrix} = 1(1 - 2) - 3(-5 - 6) + 4(5 + 3)Expand the minor along row 1 and find each 2 × 2 determinant.
= -1 + 33 + 32
Multiply.
= 64
Add.
\det A = 2(-64) = -128
Substitute C₂₃ = −64 and multiply.
Answer: det A = −128.
5.
\det A = 1 \cdot C_{23} + 5C_{43}Column 3 is (0, 1, 0, 5). Expand down column 3.
C_{23} = -\begin{vmatrix} 2 & 1 & -1 \\ 1 & 4 & 3 \\ 0 & 2 & 1 \end{vmatrix}Delete row 2 and column 3. The sign at (2, 3) is −.
\begin{vmatrix} 2 & 1 & -1 \\ 1 & 4 & 3 \\ 0 & 2 & 1 \end{vmatrix} = 2(4 - 6) - 1(1 - 0) + (-1)(2 - 0)Expand along row 1.
= -4 - 1 - 2 = -7
Multiply, then add.
C_{43} = -\begin{vmatrix} 2 & 1 & -1 \\ 3 & 0 & 2 \\ 1 & 4 & 3 \end{vmatrix}Delete row 4 and column 3. The sign at (4, 3) is − because 4 + 3 = 7.
\begin{vmatrix} 2 & 1 & -1 \\ 3 & 0 & 2 \\ 1 & 4 & 3 \end{vmatrix} = 2(0 - 8) - 1(9 - 2) + (-1)(12 - 0)Expand along row 1.
= -16 - 7 - 12 = -35
Multiply, then add.
\det A = 1(7) + 5(35)
Substitute C₂₃ = 7 and C₄₃ = 35.
= 7 + 175 = 182
Multiply, then add.
Answer: det A = 182.
6.
\det A = 3 \cdot (-2) \cdot 5 \cdot 2
A is triangular, so multiply the diagonal entries.
= -60
Multiply.
Answer: det A = −60.
7.
\det A = 1 \cdot C_{11} + 2C_{13}Row 1 is (1, 0, 2, 0). Expand along row 1.
C_{11} = \begin{vmatrix} k & 0 & 1 \\ 0 & 4 & 0 \\ 2 & 0 & 1 \end{vmatrix} = 4\begin{vmatrix} k & 1 \\ 2 & 1 \end{vmatrix}Delete row 1 and column 1, then expand along the minor’s row 2 (only the 4 counts; its sign is +).
= 4(k - 2)
Find the 2 × 2 determinant.
C_{13} = \begin{vmatrix} 0 & k & 1 \\ 3 & 0 & 0 \\ 0 & 2 & 1 \end{vmatrix} = -3\begin{vmatrix} k & 1 \\ 2 & 1 \end{vmatrix}Delete row 1 and column 3 (sign +), then expand along the minor’s row 2 (only the 3 counts; its sign is −).
= -3(k - 2)
Find the 2 × 2 determinant.
\det A = 4(k - 2) + 2(-3)(k - 2)
Substitute both cofactors.
= -2(k - 2)
Combine like terms: 4 − 6 = −2.
-2(k - 2) = 0 \Rightarrow k = 2
A is not invertible when det A = 0. Divide by −2, then add 2.
Answer: k = 2.
8.
\det A = 0C_{21} + 0C_{22} + 0C_{23} + 0C_{24}Expand along row 2, which is all zeros.
= 0
Every term has a factor of 0.
Answer: det A = 0. Any square matrix with a row or column of zeros has determinant 0.
9.
\det A = 3C_{32}Column 2 is (0, 0, 3, 0, 0), so only a₃₂ = 3 counts.
C_{32} = -\begin{vmatrix} 1 & 2 & 0 & 3 \\ 0 & 1 & 4 & 0 \\ 0 & 0 & 2 & 1 \\ 0 & 1 & 0 & -1 \end{vmatrix}Delete row 3 and column 2. The sign at (3, 2) is −.
\begin{vmatrix} 1 & 2 & 0 & 3 \\ 0 & 1 & 4 & 0 \\ 0 & 0 & 2 & 1 \\ 0 & 1 & 0 & -1 \end{vmatrix} = 1\begin{vmatrix} 1 & 4 & 0 \\ 0 & 2 & 1 \\ 1 & 0 & -1 \end{vmatrix}Expand the 4 × 4 minor down column 1; only its first entry is nonzero.
= 1(-2 - 0) - 4(0 - 1) + 0
Expand along row 1 and find each 2 × 2 determinant.
= -2 + 4 = 2
Multiply, then add.
\det A = 3(-2) = -6
Substitute C₃₂ = −2 and multiply.
Answer: det A = −6.
10.
A = \begin{bmatrix} 3 & 1 & 0 & 4 \\ 0 & 2 & 0 & 2 \\ 1 & 0 & 4 & 5 \\ 0 & 0 & 1 & 1 \end{bmatrix}Replace column 4 with the new ingredient (4, 2, 5, 1).
\det A = 1 \cdot C_{43} + 1 \cdot C_{44}Row 4 is (0, 0, 1, 1). Expand along row 4.
C_{43} = -\begin{vmatrix} 3 & 1 & 4 \\ 0 & 2 & 2 \\ 1 & 0 & 5 \end{vmatrix} = -(30 + 2 - 8) = -24Delete row 4 and column 3 (sign −); expand along row 1: 3(10 − 0) − 1(0 − 2) + 4(0 − 2).
C_{44} = \begin{vmatrix} 3 & 1 & 0 \\ 0 & 2 & 0 \\ 1 & 0 & 4 \end{vmatrix} = 3(8 - 0) - 1(0 - 0) + 0 = 24Delete row 4 and column 4 (sign +); expand along row 1.
\det A = -24 + 24 = 0
Add the two terms.
Answer: det A = 0, so no. The new ingredient’s column is the sum of the other three columns, so some targets have no blend and others have infinitely many.
Cofactor expansion FAQ
What is the difference between a minor and a cofactor?
The minor Mᵢⱼ is the determinant left after deleting row i and column j. The cofactor is that minor with a sign: Cᵢⱼ = (−1)ⁱ⁺ʲMᵢⱼ, so the two are equal when i + j is even and opposite when it is odd.
Can you expand along any row or column?
Yes. Every row and every column gives the same determinant, so choose the line with the most zeros. Just use the sign pattern for the line you choose.
How do you find the determinant of a 4 × 4 matrix?
Expand along a row or column to get four 3 × 3 cofactors (fewer if there are zeros), then find each 3 × 3 determinant. For a 4 × 4 matrix with few zeros, row-reducing to triangular form first is usually faster.
Is cofactor expansion the same as Laplace expansion?
Yes. Cofactor expansion, Laplace expansion and expansion by minors are three names for the same method.
Summary
- The minor Mᵢⱼ deletes row i and column j; the cofactor is Cᵢⱼ = (−1)ⁱ⁺ʲMᵢⱼ.
- det A = Σ aᵢⱼCᵢⱼ along any one row or column, using the checkerboard of signs that starts with +.
- Expand along the row or column with the most zeros.
- The determinant of a triangular matrix is the product of its diagonal entries.
- Full expansion takes n! products, so large matrices are better handled by row reduction.
Previous lesson: LU Decomposition
Next lesson: Properties of Determinants
Back to the Linear Algebra Index