Determinant of a Matrix

Learn about determinants and the different properties of a matrix that can be deduced from them.

Determinant

The determinant of a matrix helps represent a matrix in the form of a number. This number gives a lot of important information about the matrix, including its singularity. Unlike rank, which can be calculated for a matrix of any dimension and is always positive, a determinant can only be calculated for square matrices and can have any scalar value. Determinants are written in two different ways:

det(A)orAdet(A) \qquad or \qquad |A|

The Python function to calculate the determinant of a square matrix is available in the numpy library.

Press + to interact
import numpy as np
mat = np.array([[29, 44],
[30, 50]])
print(mat)
det = np.linalg.det(mat)
print(f"""The determinant of the matrix is {det}""")

The essence of a determinant is that it defines the scaling factor by which a linear transformation changes the volume of any object.

Transformation functions output a transformed version of the input. If a transformation fulfills the rules of linearity, it’s called a linear transformation. An example of a linear transformation is 90°90\degree counterclockwise rotation and is defined by this matrix,

[0110]\begin{bmatrix} 0 & 1 \\ -1 & 0 \end{bmatrix}

, is shown on the right.

Consider another linear transformation:

[3202]\begin{bmatrix} 3 & 2 \\ 0 & 2 \end{bmatrix}

The animation on the right shows the application of this transformation on a square of area AA. The transformation converts the square into a parallelogram of area 6A6A. We can confirm that this factor equals the determinant of the transformation matrix, as follows:

det([3202])=6det \left( \begin{bmatrix} 3 & 2 \\ 0 & 2 \end{bmatrix} \right) = 6

Formulas for determinant

For a 2×22 \times 2 matrix, the determinant is simply the difference of its diagonal products.

A=[abcd]det(A)=adbcA=\begin{bmatrix} a & b \\ c & d\end{bmatrix} \qquad det(A)=ad-bc

For larger matrices, calculating the determinant isn’t that simple. There are three different methods to calculate the determinant of an n×nn \times n matrix.

  • Determinant by pivots
  • Determinant by permutations
  • Determinant by cofactors and minors

We’ll focus only on the first one because it’s the fastest one and is used in computer programs like the Python function shown above.

Note: The other two methods have their own significance. They provide formulas for multiple other concepts that we have studied previously, like Cramer’s rule for for A1A^{-1} and A1bA^{-1}b. That said, the large number of computations required to calculate these formulas makes them slow and of little interest to us as data scientists.

Properties of determinants

Below is a fairly extensive list explaining the properties of the determinant of a matrix. To build a better understanding, we’ll check each property against our generic 2×22 \times 2 matrix. This doesn’t restrict these properties to only 2×22 \times 2 matrices. They’re valid for any n×nn \times n matrix.

Determinant and singularity

If det(A)=0det(A)=0, the matrix is singular. For invertible matrices, det(A)0det(A) \neq 0.

Let’s have a look at the determinant formula for computing the inverse of a 2×22 \times 2 matrix:

A1=1adbc[dbca]A^{-1}={1 \over ad-bc}\begin{bmatrix} d & -b \\ -c & a\end{bmatrix} ...