# Cofactor Expansion Calculator

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 `a`

.
Fix _{ij}`i = 1,…,n`

. Then:

`det(A) = a`

,_{i1} * C_{i1} + a_{i2} * C_{i2} + ... + a_{in} * C_{in}

where `C`

is the _{ij}`(i,j)`

-th **cofactor** of `A`

. That is:

`C`

,_{ij} = (-1)^{i+j} * det(A_{ij})

where `A`

is the _{ij}`(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 `C`

, we obtain the following formula for _{ij}`det(A)`

:

`det(A) = (-1)`

^{i+1} * a_{i1} * det(A_{i1}) + (-1)^{i+2} * a_{i2} * det(A_{i2}) + ... + (-1)^{i+n} * a_{in} * det(A_{in}).

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) = a`

,_{1j} * C_{1j} + a_{2j} * C_{2j} + ... + a_{nj} * C_{nj}

where `j = 1, ..., n`

is fixed. Using the formula for `C`

, we have:_{ij}

```
det(A) = (-1)
```^{1+j} * a_{1j} * det(A_{1j}) + (-1)^{2+j} * a_{2j} * det(A_{2j}) + ... + (-1)^{n+j} * a_{nj} * det(A_{nj})

.## 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:

- First, choose the
**size of your matrix**. - Then, input the
**coefficients**into the respective fields of the cofactor expansion calculator. - Our cofactor expansion calculator will display the answer immediately: it
**computes the determinant**by cofactor expansion and**shows you the calculations**. - 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) =
a
```

_{21} * C_{21} + a_{22} * C_{22} + a_{23} * C_{23} + a_{24} * C_{24} + a_{25} * C_{25}

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

`a`

,_{22} = a_{23} = a_{24} = 0

so the formula reduces to:

`det(A) = a`

,_{21} * C_{21} + a_{25} * C_{25}

which is:

`det(A) = (-1)`

^{2+1} * a_{21} * det(A_{21}) + (-1)^{2+5} * a_{25} * det(A_{25})

Simplifying the sign factors and plugging in the coefficients `a`

and _{21} = 2`a`

, we obtain:_{25} = -1

```
det(A) =
-2 * det(A
```

,_{21}) + 1 * det(A_{25})

where `A`

is the following matrix:_{21}

⌈ | -2 | 1 | 0 | 8 | ⌉ |

| | -6 | 0 | -1 | 0 | | |

| | 2 | 3 | 2 | 1 | | |

⌊ | 0 | 1 | -1 | 1 | ⌋ |

and `A`

is the following matrix:_{25}

⌈ | -1 | -2 | 1 | 0 | ⌉ |

| | 4 | -6 | 0 | -1 | | |

| | 1 | 2 | 3 | 2 | | |

⌊ | 0 | 0 | 1 | -1 | ⌋ |

It turns out that `det(A`

and _{21}) = -212`det(A`

(see below for some details), so:_{25}) = -84

`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(A`

using cofactor expansion once again. To avoid confusion, let us denote the 4×4 matrix under consideration by _{25})`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 (`b`

). In consequence,_{41} = b_{42} = 0

```
det(B) =
(-1)
```

^{4+3} * b_{43} * det(B_{43}) + (-1)^{4+4} * b_{44} * det(B_{44})

```
det(B) =
(-1) * 1 * det(B
```

_{43}) + 1 * (-1) * det(B_{44})

`det(B) = -det(B`

_{43}) - det(B_{44})

where `B`

is:_{43}

⌈ | -1 | -2 | 0 | ⌉ |

| | 4 | -6 | -1 | | |

⌊ | 1 | 2 | 2 | ⌋ |

and `B`

is :_{44}

⌈ | -1 | -2 | 1 | ⌉ |

| | 4 | -6 | 0 | | |

⌊ | 1 | 2 | 3 | ⌋ |

It turns out that `det(B`

and _{43}) = 28`det(B`

(use the Sarrus rule or see below for the calculation via cofactor expansion), so_{44}) = 56

`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 (`m`

), which simplifies calculations. In consequence,_{23} = 0

```
det(M) =
(-1)
```

^{1+3} * m_{13} * det(M_{13}) + (-1)^{3+3} * m_{33} * det(M_{33})

```
det(M) =
1 * 1 * det(M
```

_{13}) + 1 * 3 * det(M_{33})

`det(M) = det(M`

_{13}) + 3 * det(M_{33})

where `M`

is:_{13}

⌈ | 4 | -6 | ⌉ |

⌊ | 1 | 2 | ⌋ |

and `M`

is :_{33}

⌈ | -1 | -2 | ⌉ |

⌊ | 4 | -6 | ⌋ |

We can easily determine that `det(M`

, so:_{13}) = det(M_{33}) = 14

`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:

- Remove the
`i`

-th row and`j`

-th column of your matrix. You get a**submatrix**of size one less than the initial matrix. - Compute the
**determinant**of this submatrix. - Compute the
**sign factor**`(-1)`

.^{i+j} **Multiply**the determinant from step 2 by the sign factor from step 3.- 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:

**Choose a row/column**of your matrix. Go for the one containing the most zeros.- For each
**coefficient**in your row/column, compute the respective**2×2 cofactor**. **Multiply**the coefficient by its cofactor.**Add the three numbers**obtained in steps 2 & 3.- 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:

**Choose a row/column**of your matrix. Tip: go for the one containing the most zeros.- For each
**coefficient**in your row/column, compute the respective**3×3 cofactor**. **Multiply**the coefficient by its cofactor.**Add the four numbers**obtained in steps 2 & 3.- 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:

**Choose a row/column**of your matrix. Go for the one containing the most zeros.- For each coefficient in your row/column, compute the respective
**4×4 cofactor**. **Multiply**the coefficient by its cofactor.**Add the five numbers**obtained in steps 2 & 3.**Wow**, you have just found a**5×5 determinant**!

⌈ | a₁₁ | a₁₂ | a₁₃ | ⌉ | ||

A | = | | | a₂₁ | a₂₂ | a₂₃ | ｜ |

⌊ | a₃₁ | a₃₂ | a₃₃ | ⌋ |