# Nakafa Learning Content

> For AI agents: use [llms.txt](https://nakafa.com/llms.txt) for the site index. Markdown versions are available by appending `.md` to content URLs or sending `Accept: text/markdown`.

URL: https://nakafa.com/en/subjects/ai-ds/linear-methods/laplace-expansion
Source: https://raw.githubusercontent.com/nakafaai/nakafa.com/refs/heads/main/packages/contents/material/lesson/ai-ds/linear-methods/laplace-expansion/en.mdx

Learn Laplace expansion theorem: systematic determinant calculation using minors and cofactors, with row/column flexibility and Sarrus rule examples.

---

## What is the Laplace Expansion Theorem?

The Laplace Expansion Theorem provides a way to calculate the determinant of a matrix by breaking it down into determinants of smaller matrices. This method is very useful because it allows us to calculate determinants of large matrices systematically.

This theorem provides flexibility in choosing which row or column to use for expansion, so we can choose the most advantageous one for calculation.

## Theorem Statement

For matrix $$A \in \mathbb{R}^{n \times n}$$, the determinant can be calculated in two ways:

Visible text: For matrix , the determinant can be calculated in two ways:

### Column-Based Expansion

Besides expansion based on column $$j$$, the determinant can be calculated using the formula:

Visible text: Besides expansion based on column , the determinant can be calculated using the formula:

Component: MathContainer
Children:

```math
\det A = \sum_{i=1}^{n} (-1)^{i+j} \cdot a_{ij} \cdot \det A_{ij}
```

for any chosen column $$j \in \{1, 2, \ldots, n\}$$.

Visible text: for any chosen column .

### Row-Based Expansion

The determinant can also be calculated based on row $$i$$:

Visible text: The determinant can also be calculated based on row :

Component: MathContainer
Children:

```math
\det A = \sum_{j=1}^{n} (-1)^{i+j} \cdot a_{ij} \cdot \det A_{ij}
```

for any chosen row $$i \in \{1, 2, \ldots, n\}$$.

Visible text: for any chosen row .

## Expansion Examples

### Two-by-Two Matrix

For a matrix of size $$n = 2$$:

Visible text: For a matrix of size :

```math
A = \begin{pmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{pmatrix}
```

Expansion based on the first row:

Component: MathContainer
Children:

```math
\det A = a_{11} \cdot \det(a_{22}) - a_{12} \cdot \det(a_{21})
```

```math
= a_{11} \cdot a_{22} - a_{12} \cdot a_{21}
```

### Three-by-Three Matrix

For a matrix of size $$n = 3$$:

Visible text: For a matrix of size :

```math
A = \begin{pmatrix} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \\ a_{31} & a_{32} & a_{33} \end{pmatrix}
```

Expansion based on the first row:

Component: MathContainer
Children:

```math
\det A = a_{11} \cdot \det \begin{pmatrix} a_{22} & a_{23} \\ a_{32} & a_{33} \end{pmatrix}
```

```math
- a_{12} \cdot \det \begin{pmatrix} a_{21} & a_{23} \\ a_{31} & a_{33} \end{pmatrix}
```

```math
+ a_{13} \cdot \det \begin{pmatrix} a_{21} & a_{22} \\ a_{31} & a_{32} \end{pmatrix}
```

After calculating the $$2 \times 2$$ determinants:

Visible text: After calculating the determinants:

Component: MathContainer
Children:

```math
= a_{11} \cdot (a_{22} \cdot a_{33} - a_{23} \cdot a_{32})
```

```math
- a_{12} \cdot (a_{21} \cdot a_{33} - a_{23} \cdot a_{31})
```

```math
+ a_{13} \cdot (a_{21} \cdot a_{32} - a_{22} \cdot a_{31})
```

If we expand it fully:

Component: MathContainer
Children:

```math
= a_{11} \cdot a_{22} \cdot a_{33} - a_{11} \cdot a_{23} \cdot a_{32}
```

```math
- a_{12} \cdot a_{21} \cdot a_{33} + a_{12} \cdot a_{23} \cdot a_{31}
```

```math
+ a_{13} \cdot a_{21} \cdot a_{32} - a_{13} \cdot a_{22} \cdot a_{31}
```

## Sarrus Rule

The result of the $$3 \times 3$$ matrix expansion above corresponds to **Sarrus Rule**. This rule provides a visual way to calculate $$3 \times 3$$ determinants through diagonal patterns.

Visible text: The result of the matrix expansion above corresponds to **Sarrus Rule**. This rule provides a visual way to calculate determinants through diagonal patterns.

Sarrus formula for $$3 \times 3$$ matrices:

Visible text: Sarrus formula for matrices:

Component: MathContainer
Children:

```math
\det A = a_{11}a_{22}a_{33} + a_{12}a_{23}a_{31} + a_{13}a_{21}a_{32}
```

```math
- a_{13}a_{22}a_{31} - a_{11}a_{23}a_{32} - a_{12}a_{21}a_{33}
```

Sarrus rule uses diagonal patterns to determine which terms are added and which are subtracted.

## Computational Complexity

The complexity of determinant calculation using Laplace expansion is very high. For an $$n \times n$$ matrix, the number of multiplication operations required is:

Visible text: The complexity of determinant calculation using Laplace expansion is very high. For an matrix, the number of multiplication operations required is:

Component: MathContainer
Children:

```math
n \cdot (n-1) \cdot (n-2) \cdot \ldots \cdot 2 \cdot 1 \cdot (n-1)
```

```math
= n! \cdot (n-1)
```

This shows that the algorithm complexity is factorial, which is very inefficient for large matrices.

## Utilizing Zero Elements

When a matrix has many zero elements, we can choose the expansion such that subdeterminants with zero elements do not need to be calculated. This can significantly reduce the computational burden.

### Optimization Example

Suppose we have a matrix:

```math
A = \begin{pmatrix} 0 & 3 & 3 \\ 2 & 2 & 0 \\ 1 & 0 & 1 \end{pmatrix}
```

Expansion based on the first row:

Component: MathContainer
Children:

```math
\det A = 0 \cdot \det(\ldots) - 3 \cdot \det \begin{pmatrix} 2 & 0 \\ 1 & 1 \end{pmatrix}
```

```math
+ 3 \cdot \det \begin{pmatrix} 2 & 2 \\ 1 & 0 \end{pmatrix}
```

Since the first element is zero, the calculation becomes:

Component: MathContainer
Children:

```math
= -3 \cdot (2 \cdot 1 - 0 \cdot 1) + 3 \cdot (2 \cdot 0 - 2 \cdot 1)
```

```math
= -3 \cdot 2 + 3 \cdot (-2)
```

```math
= -6 - 6 = -12
```

By choosing rows or columns that have many zeros, we can save calculations.

## Determinant of Transpose Matrix

One important property related to the Laplace theorem is:

```math
\det A^T = \det A
```

This means the determinant of a matrix equals the determinant of its transpose.

### Consequences for Rows and Columns

Due to this transpose property, all determinant properties that apply to rows of matrix $$A$$ also apply to columns of matrix $$A$$.

Visible text: Due to this transpose property, all determinant properties that apply to rows of matrix also apply to columns of matrix .

For example:

- If two rows are identical then the determinant is zero, likewise if two columns are identical
- Swapping two rows changes the sign of the determinant, so does swapping two columns
- Elementary row operations and elementary column operations have the same effect on the determinant

## Larger Matrices

For matrices of size $$n = 4$$ and beyond, the principle of Laplace expansion still applies. However, the computational complexity becomes very high, so in practice other more efficient methods such as Gaussian elimination are often used.

Visible text: For matrices of size and beyond, the principle of Laplace expansion still applies. However, the computational complexity becomes very high, so in practice other more efficient methods such as Gaussian elimination are often used.

The Laplace Expansion Theorem provides a solid theoretical foundation for understanding determinant structure, although in practical applications it may be replaced by more efficient algorithms.