Computing Determinants by Cofactor Expansion
How can we compute the determinant of a large matrix? We want to do this without writing out all of its permutation terms. For an matrix, the Leibniz Permutation Formula sums signed products. This number explodes catastrophically. A modest matrix already has terms. We need a method that trades this single enormous sum for a manageable recursive procedure. This procedure should mirror how humans and machines actually compute determinants. This applies to computation by hand or in exact arithmetic. Cofactor expansion, also called Laplace expansion, answers this need. It expresses the determinant of an matrix as a signed sum. This sum involves determinants of matrices. These are chosen along any single row or column. Applied recursively, it reduces the computation of any determinant to a base case. That base case is matrices. This gives both a concrete algorithm and a powerful proof technique. That technique helps establish properties of determinants by induction on size. The idea matters because it bridges two views of the determinant. One is the abstract, permutation-based definition that guarantees existence and uniqueness. The other is a hands-on recursive formula suitable for direct computation and for inductive proofs. Historically, Laplace's expansion predates a fully rigorous treatment of permutations. It remains the standard tool taught for computing determinants by hand. This applies to matrices of size or . It is also used for proving structural facts by induction on matrix size. These facts include multilinearity in rows, the effect of row operations, and the formula for the inverse via the adjugate. This article gives the precise definition of a minor and a cofactor. It states and proves the Laplace expansion theorem along an arbitrary row or column. This proof comes directly from the Leibniz formula. It also works through two nontrivial numerical examples. It examines what goes wrong if expansion is attempted along a "row" that does not exist in the matrix. It previews how cofactor expansion sets up further study. This includes Determinant Properties and Row Operations and the construction of the adjugate matrix in The Adjugate and Cofactor Matrix.
- The minor of an matrix is the determinant of the matrix left after deleting row and column .
- The cofactor is the signed minor: .
- Laplace expansion along row : ; an analogous formula holds along any column.
- Every choice of row or column gives the same number — the determinant is well-defined independent of the expansion line.
- The proof is a direct algebraic regrouping of the terms of the Leibniz Permutation Formula by the entry each permutation selects in the chosen row.
- Key idea: cofactor expansion turns one giant sum of signed products into smaller determinants, giving both a recursive algorithm and an induction tool.
Where this lives today
Cofactor expansion remains the standard method for computing determinants of small matrices by hand — and cases appear throughout physics (moment of inertia tensors, Levi-Civita/cross-product computations) and engineering (stiffness and stress tensors). In symbolic computation and computer algebra systems, cofactor-based (Laplace) expansion is used for matrices over general commutative rings (not necessarily fields) where division-based Gaussian elimination is unavailable or introduces unwanted denominators; this matters in exact symbolic computation and in algorithms for computing resultants and characteristic polynomials over polynomial rings. The recursive structure underlying the theorem is the standard inductive scaffold for proving deeper facts about determinants, including multilinearity in each row, the alternating property under row swaps, and the behavior of determinants under Determinant Properties and Row Operations. It also directly produces the entries of the adjugate matrix used in The Adjugate and Cofactor Matrix and in Cramer's Rule for solving linear systems and computing matrix inverses in closed form. In algebraic geometry and combinatorics, expansions by minors generalize to the Laplace expansion along several rows at once (the general Laplace expansion theorem), which underlies the Cauchy–Binet formula relating minors of a product of rectangular matrices. Cofactor-based reasoning also appears in graph theory, via the Matrix-Tree Theorem, where cofactors of the graph Laplacian count spanning trees.
Ask the tutor: Why does mismatching a row's entries with another row's cofactors always sum to zero, and how does that fact underlie the adjugate identity?
Let be an matrix over a field , with .
Minor. For indices , the minor of , denoted , is the determinant of the matrix obtained from by deleting row and column .
Cofactor. The cofactor of is the signed minor
Cofactor expansion along row : the expression
Cofactor expansion along column : the expression
For , we take by convention (base case; no minors are defined).
Intuition
Think of the determinant of an matrix as a signed volume of the parallelepiped spanned by its rows (or columns). Cofactor expansion says: to compute this volume, pick one row, and for each entry in that row, weight the volume of the "opposite" -dimensional parallelepiped (the minor, obtained by deleting that entry's row and column) by the entry itself, alternating signs as you move across the row. Summing these signed, weighted sub-volumes reconstructs the whole volume. The alternating sign pattern is not arbitrary — it is exactly the correction needed so that swapping two rows of still flips the overall sign, consistent with the alternating property built into the Leibniz formula. Geometrically, the checkerboard sign pattern below shows where each cofactor's sign comes from.
The recursive nature of this expansion means a determinant of size reduces, in one step, to determinants of size ; iterating, it bottoms out at determinants (single entries). This recursion is the natural setting for induction proofs about determinants, and it is also literally how the formula is derived from the Leibniz sum.
Let be an matrix over a field , , and let be defined by the Leibniz formula
Then for every fixed row index ,
and for every fixed column index ,
In particular, the value obtained by expanding along any row or any column is the same, and equals .
We prove the row-expansion formula for a fixed row index ; the column formula follows by the identical argument applied to , using (a fact itself provable directly from the Leibniz formula by the substitution , which we invoke here as an already-established property of the permutation sum, not as a consequence of cofactor expansion, so there is no circularity).
Step 1: Group the Leibniz sum by the value . Fix . Every permutation sends to some unique value . Partition into the disjoint blocks
Then
where we pulled out of the product since it is constant on . It remains to show that the inner sum
equals .
Step 2: Bijection between and . Let denote the matrix obtained from by deleting row and column ; by definition . Index the rows of by and its columns by , in their original (increasing) order, so its entry (for in the compressed indexing) equals where is the -th element and is the -th element of the respective index sets. Given , define by for ; this is well defined because is a bijection sending , so it must send bijectively onto . Composing with the order-preserving relabelings of and as , we obtain a permutation . The map is a bijection , since is completely determined by together with its restriction to . Under this bijection,
so
where is the constant by which differs from (constant across the block because it depends only on , not on the particular , as shown next).
Step 3: Compute the sign factor . We compute by relating to through explicit transpositions. First handle the case : here , so restricted to is literally an element of (no relabeling needed), and directly from the definition of sign via inversions restricted to (the pair for contributes no inversion since never holds... more precisely, since is the maximum value, no inversion involves index ). Hence . For general , construct from (viewed, after relabeling, as a bijection ) by setting and for . We relate to a permutation of the form handled above by conjugating with cyclic shifts: let be the cycle , which moves position to position by a cyclic shift, i.e. has sign (a cycle of length has sign ). Similarly let be the cycle with sign . One checks directly that where and restricted to corresponds to under the appropriate relabeling; taking signs,
using and . Hence for all , independent of the particular , confirming the constant claimed in Step 2.
Step 4: Conclude. Combining Steps 1–3,
and therefore
which is exactly the row- cofactor expansion. Since was an arbitrary fixed row index, this holds for every row. For columns, apply the row result to : the minor of equals the minor of (deleting row , column of is the same submatrix, transposed, as deleting row , column of , and transposition does not change a determinant by the already-cited fact applied to the smaller matrices). Hence expanding along its row gives , and since , this is the column- expansion of . Since the right-hand side was shown equal to (the Leibniz sum) for every choice of , and likewise for every choice of , all expansions (over rows and columns) give the same value, namely .
∎Worked examples
Example 1 — a matrix, expansion along a chosen row. Let
We expand along row 2, chosen deliberately (not the first row) to illustrate that any row works, and this row has a zero entry that simplifies the arithmetic. The cofactors needed are .
Row-2 expansion:
Check by expanding along column 1 instead, to confirm the theorem's claim of row/column independence.
Column-1 expansion:
Both expansions agree: .
Example 2 — a matrix, exploiting a sparse column and full recursion. Let
Column 3 has entries : only two nonzero entries, so we expand along column 3 to minimize work.
Compute : delete row 2, column 3 of :
Expand this determinant along its row 2 (again sparse: ):
So . Compute : delete row 3, column 3 of :
Expand along row 2 (entries ):
Compute the two determinants:
So
Then . Finally,
Verification via a different column. As a check, expand along column 1 of , entries .
Expand along row 1 ():
Expand along column 2 (entries ):
Expand along row 1 (entries ):
Column-1 expansion, using :
Both expansions give , confirming the theorem.
The theorem requires expanding along a genuine row or column of the matrix, using the actual matrix entries paired with the correctly indexed cofactor (same for a row, same for a column). If one instead tries to build an "expansion" by pairing entries from a row with cofactors computed for a different row, the resulting sum is generally not the determinant — this shows the hypothesis "sum over with fixed used consistently in both and " cannot be dropped or mismatched. Take
The row-1 cofactors are , . The correct row-1 expansion is
matching the theorem. Now mismatch row 2's entries with row 1's cofactors:
This "false expansion" (entries of one row paired with cofactors of another) does not compute ; in fact this particular sum equals zero, which is not a coincidence — it is the determinant of the matrix obtained by replacing row 1 with a copy of row 2 (a matrix with two equal rows, hence determinant , by the alternating property of the Leibniz sum). This illustrates precisely why the proof needed the index to match between and : the bijection in Step 2 of the proof is built entirely around a single fixed row , and breaking that match destroys the identity.
Scope, edge cases & common traps
| Situation | What to do | Common pitfall |
|---|---|---|
| , no expansion needed | Trying to "expand" a matrix | |
| Cofactor expansion reduces to | Forgetting the sign on off-diagonal cofactors | |
| Row/column with zeros | Expand along it to reduce arithmetic | Choosing a dense row out of habit, wasting effort |
| Choosing sign | Use the checkerboard pattern, start with at | Misplacing which corner is ; sign errors compound recursively |
| Large (e.g. ) | Cofactor expansion is in the worst case; combine with row reduction | Treating cofactor expansion as an efficient general algorithm |
| Mixing rows/columns mid-computation | Not standard; each single expansion must use one fixed row or column | Pairing with for (see counterexample) |
The mathematician behind it
Origins · 1 minPierre-Simon Laplace and how this was discovered
Laplace was a towering figure of French mathematical physics and probability theory, known for his work on celestial mechanics (culminating in Mécanique Céleste) and for foundational contributions to probability (Théorie Analytique des Probabilités). His 1772 memoir on the theory of elimination among linear equations introduced the expansion of determinants by minors along a row or column, which is why the technique bears his name — although determinant-like calculations for solving linear systems were already implicit in earlier work by Leibniz and, independently and more systematically, by Cramer and Vandermonde.
Does it matter which row or column I choose to expand along?
No — the Laplace expansion theorem guarantees that expanding along any row or any column of an matrix produces the same value, namely . This is not an assumption but a proven fact, following from regrouping the terms of the Leibniz formula by the entry selected in the chosen row (or column) and matching the remaining terms bijectively with a smaller symmetric group. In practice you should choose the row or column with the most zero entries, since each zero entry eliminates the need to compute its corresponding minor entirely, saving substantial arithmetic.
Why does the sign pattern alternate as rather than some other rule?
The sign is forced by the requirement that the cofactor expansion reproduce the alternating Leibniz sum exactly. In the proof, this sign arises as the parity difference between a permutation fixing and the induced permutation on the remaining indices, computed via explicit cyclic shifts moving position and to the last slot. The checkerboard pattern (starting with at position ) is simply the visual encoding of this parity computation.
Is cofactor expansion an efficient way to compute large determinants?
No. Naive cofactor expansion has worst-case cost growing like , since each level of recursion multiplies the number of subproblems by roughly . For an matrix with no helpful zero entries, this becomes computationally infeasible beyond roughly or even on fast computers. In practice, determinants of large matrices are computed via Gaussian elimination (LU decomposition) in time, tracking the sign changes from row swaps, as developed under Determinant Properties and Row Operations. Cofactor expansion remains valuable for small matrices, symbolic computation, and theoretical proofs by induction.
Can I combine cofactor expansion with row operations to simplify a computation?
Yes, and this is standard practice. Since row operations such as adding a multiple of one row to another do not change the determinant (a fact studied under Determinant Properties and Row Operations), you can first use such operations to introduce zeros into a row or column, then expand along that sparsified row or column with much less arithmetic. This hybrid approach is often the most efficient hand-computation method for matrices of size to .
What is the relationship between cofactor expansion and the adjugate matrix?
The adjugate (or classical adjoint) of is the transpose of the matrix of cofactors, . The Laplace expansion theorem is precisely the statement that multiplying by its own cofactor matrix in the matching-index way gives on the diagonal; the off-diagonal terms of vanish by the "false expansion" phenomenon illustrated in the counterexample above (entries of one row paired with cofactors of a different row sum to zero). This identity, , is developed fully in The Adjugate and Cofactor Matrix and yields a closed-form inverse when .
Does cofactor expansion work over rings that are not fields, such as the integers or polynomial rings?
Yes. The Leibniz formula and hence the Laplace expansion theorem require only a commutative ring, since the proof uses only addition, multiplication, and the sign of permutations — no division is used anywhere in the argument. This is precisely why cofactor expansion (rather than Gaussian elimination, which requires dividing by pivots) is the preferred method for computing determinants symbolically over polynomial rings, e.g. when computing a characteristic polynomial .
What happens if two rows of the matrix are identical — does cofactor expansion still work?
Cofactor expansion still computes the determinant correctly in this case, and the answer will always come out to , consistent with the alternating property of determinants (swapping two identical rows leaves the matrix unchanged but must flip the sign of the determinant, forcing , hence ). You can verify this using cofactor expansion directly, though the arithmetic will not simplify automatically — the vanishing emerges only after full cancellation in the signed sum, exactly as illustrated in the counterexample block.