# Cofactor Expansion Calculator

By Anna Szczepanek, PhD
Last updated: Aug 03, 2021

Welcome to Omni's cofactor expansion calculator! Here you can quickly and easily learn how to compute the determinant of any matrix by cofactor expansion. Not sure what cofactors are? What does the phrase compute the determinant by cofactor expansion actually mean? Struggling with 4×4 cofactor expansion? Stuck with a homework assignment asking you to find the determinant of a 5×5 matrix with cofactor expansion? Keep calm and scroll on down!

## What is cofactor expansion?

Cofactor expansion is a way of computing the determinant of a matrix. Recall that a determinant is a number related to various important properties of a matrix. In particular, you can invert a matrix if, and only if, its determinant is not equal to zero.

It's vital you remember that cofactor expansion is a recursive formula: it converts the task of computing a determinant of size `n` into computing several determinants of size `n - 1`. More precisely, the cofactor expansion allows you to express the determinant of size `n` as a weighted sum of minors. Recall that a minor is the determinant of some `(n − 1) × (n − 1)` submatrix of the initial matrix.

## How to find determinants by cofactor expansion?

Let `A` be an `n × n` matrix with real (or complex) coefficients `aij`. Fix `i = 1,…,n` . Then:

`det(A) = ai1 * Ci1 + ai2 * Ci2 + ... + ain * Cin`,

where `Cij` is the `(i,j)`-th cofactor of `A`. That is:

`Cij = (-1)i+j * det(Aij)`,

where `Aij` is the `(n-1) × (n-1)` submatrix of `A` obtained by removing the `i`-th row and `j`-th column of `A`.

Plugging in the formula for the cofactor `Cij`, we obtain the following formula for `det(A)`:

```det(A) = (-1)i+1 * ai1 * det(Ai1) + (-1)i+2 * ai2 * det(Ai2) + ... + (-1)i+n * ain * det(Ain). ```

The above formula for `det(A)` is the cofactor expansion of the determinant along row `i`. We see that to compute the determinant of a matrix by cofactor expansion we only need to multiply the coefficients from some row of the matrix by the respective cofactors and then add everything together.

We can also write down an analogous formula for expanding along column `j`:

`det(A) = a1j * C1j + a2j * C2j + ... + anj * Cnj`,

where `j = 1, ..., n` is fixed. Using the formula for `Cij`, we have:

``` det(A) = (-1)1+j * a1j * det(A1j) + (-1)2+j * a2j * det(A2j) + ... + (-1)n+j * anj * det(Anj)```.

## How to use this cofactor expansion calculator?

As you can see, computing the determinant of a matrix by cofactor expansion is not hard in principle, but it may be time-consuming. Fortunately, our cofactor expansion calculator can do all the hard work for you! To use it most efficiently, follow these steps:

1. First, choose the size of your matrix.
2. Then, input the coefficients into the respective fields of the cofactor expansion calculator.
3. Our cofactor expansion calculator will display the answer immediately: it computes the determinant by cofactor expansion and shows you the calculations.
4. Keep in mind that cofactor expansion is a recursive formula. For instance, the determinant of a 5×5 matrix with cofactor expansion is expressed via several 4×4 determinants. To see how to compute them, use the cofactor expansion calculator once again.

## Example: the determinant of a 5×5 matrix with cofactor expansion

Let's consider the following 5×5 matrix and find its determinant by cofactor expansion.

 ⌈ -1 -2 1 0 8 ⌉ | 2 0 0 0 -1 | | 4 -6 0 -1 0 | | 1 2 3 2 1 | ⌊ 0 0 1 -1 1 ⌋

We see there are three zeros in the second row: let's perform cofactor expansion along this row.

```det(A) = a21 * C21 + a22 * C22 + a23 * C23 + a24 * C24 + a25 * C25 ```

We see that, in principle, we have to compute as many as FIVE determinants. Fortunately,

`a22 = a23 = a24 = 0`,

so the formula reduces to:

`det(A) = a21 * C21 + a25 * C25`,

which is:

`det(A) = (-1)2+1 * a21 * det(A21) + (-1)2+5 * a25 * det(A25)`

Simplifying the sign factors and plugging in the coefficients `a21 = 2` and `a25 = -1`, we obtain:

```det(A) = -2 * det(A21) + 1 * det(A25)```,

where `A21` is the following matrix:

 ⌈ -2 1 0 8 ⌉ | -6 0 -1 0 | | 2 3 2 1 | ⌊ 0 1 -1 1 ⌋

and `A25` is the following matrix:

 ⌈ -1 -2 1 0 ⌉ | 4 -6 0 -1 | | 1 2 3 2 | ⌊ 0 0 1 -1 ⌋

It turns out that `det(A21) = -212` and `det(A25) = -84` (see below for some details), so:

`det(A) = -2 * (-212) + 1 * (-84) = 424 - 84 = 340`.

#### 4×4 cofactor expansion

To show you how to solve the problem of 4×4 cofactor expansion, we now compute `det(A25)` using cofactor expansion once again. To avoid confusion, let us denote the 4×4 matrix under consideration by `B`; that is, `B` reads:

 ⌈ -1 -2 1 0 ⌉ | 4 -6 0 -1 | | 1 2 3 2 | ⌊ 0 0 1 -1 ⌋

We choose the expansion along the last (fourth) row, as it contains two zeros (`b41 = b42 = 0`). In consequence,

```det(B) = (-1)4+3 * b43 * det(B43) + (-1)4+4 * b44 * det(B44)```

```det(B) = (-1) * 1 * det(B43) + 1 * (-1) * det(B44)```

`det(B) = -det(B43) - det(B44)`

where `B43` is:

 ⌈ -1 -2 0 ⌉ | 4 -6 -1 | ⌊ 1 2 2 ⌋

and `B44` is :

 ⌈ -1 -2 1 ⌉ | 4 -6 0 | ⌊ 1 2 3 ⌋

It turns out that `det(B43) = 28` and `det(B44) = 56` (use the Sarrus rule or see below for the calculation via cofactor expansion), so

`det(B) = -28 - 56 = -84`.

#### 3×3 cofactor expansion

Finally, we show you how to deal with 3×3 cofactor expansion. We take the second submatrix above and denote it by `M`. That is, `M` is:

 ⌈ -1 -2 1 ⌉ | 4 -6 0 | ⌊ 1 2 3 ⌋

We choose the expansion along the last (third) column as it contains a zero (`m23 = 0`), which simplifies calculations. In consequence,

```det(M) = (-1)1+3 * m13 * det(M13) + (-1)3+3 * m33 * det(M33)```

```det(M) = 1 * 1 * det(M13) + 1 * 3 * det(M33)```

`det(M) = det(M13) + 3 * det(M33)`

where `M13` is:

 ⌈ 4 -6 ⌉ ⌊ 1 2 ⌋

and `M33` is :

 ⌈ -1 -2 ⌉ ⌊ 4 -6 ⌋

We can easily determine that `det(M13) = det(M33) = 14`, so:

`det(M) = 14 + 3 * 14 = 56`.

Now, it's your turn! Try computing the remaining determinants to confirm our results. In case of doubts, don't hesitate to use our cofactor expansion calculator!

## FAQ

### What row or column should I choose in cofactor expansion?

In cofactor expansion, go for the column or row containing the most zeros. This is because the successive coefficients are to be multiplied by the respective cofactors. If the coefficient is zero, you don't need to compute the corresponding cofactor because the product is going to be zero anyway.

### How to compute a cofactor?

To compute the `(i, j)`-th cofactor of a matrix, follow these steps:

1. Remove the `i`-th row and `j`-th column of your matrix. You get a submatrix of size one less than the initial matrix.
2. Compute the determinant of this submatrix.
3. Compute the sign factor `(-1)i+j`.
4. Multiply the determinant from step 2 by the sign factor from step 3.
5. This product is precisely the `(i, j)`-th cofactor you've been looking for! Congratulations!

### How to compute the cofactor expansion 3×3?

To compute the cofactor expansion of a 3×3 matrix, you have to:

1. Choose a row/column of your matrix. Go for the one containing the most zeros.
2. For each coefficient in your row/column, compute the respective 2×2 cofactor.
3. Multiply the coefficient by its cofactor.
4. Add the three numbers obtained in steps 2 & 3.
5. This is your determinant! By the way, have you heard of the rule of Sarrus?

### How to compute the cofactor expansion 4×4?

To compute the cofactor expansion of a 4×4 matrix, follow these steps:

1. Choose a row/column of your matrix. Tip: go for the one containing the most zeros.
2. For each coefficient in your row/column, compute the respective 3×3 cofactor.
3. Multiply the coefficient by its cofactor.
4. Add the four numbers obtained in steps 2 & 3.
5. Congratulate yourself on finding the determinant!

### How to compute the cofactor expansion 5×5?

To compute the cofactor expansion of a 5×5 matrix, you have to:

1. Choose a row/column of your matrix. Go for the one containing the most zeros.
2. For each coefficient in your row/column, compute the respective 4×4 cofactor.
3. Multiply the coefficient by its cofactor.
4. Add the five numbers obtained in steps 2 & 3.
5. Wow, you have just found a 5×5 determinant!
Anna Szczepanek, PhD
Matrix size
3x3
 ⌈ a₁₁ a₁₂ a₁₃ ⌉ A = | a₂₁ a₂₂ a₂₃ ｜ ⌊ a₃₁ a₃₂ a₃₃ ⌋
First row
a₁₁
a₁₂
a₁₃
Second row
a₂₁
a₂₂
a₂₃
Third row
a₃₁
a₃₂
a₃₃
Result
Expand along the
first
row
People also viewed…

### Car heat

The hot car calculator shows you how fast the interior of a car heats up during a summers day.

### One's complement

This one's complement calculator lets you find the one's complement to convert negative decimal values to binary. It also converts a decimal number to binary and its one's complement.

### Pascal's triangle

The Pascal's triangle calculator will compute and show you the exact levels of the triangle you need. 