Determinant of a Matrix
Learn about determinants and the different properties of a matrix that can be deduced from them.
We'll cover the following...
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:
The Python function to calculate the determinant of a square matrix is available in the numpy
library.
import numpy as npmat = 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 counterclockwise rotation and is defined by this matrix,
, is shown on the right.
Consider another linear transformation:
The animation on the right shows the application of this transformation on a square of area . The transformation converts the square into a parallelogram of area . We can confirm that this factor equals the determinant of the transformation matrix, as follows:
Formulas for determinant
For a matrix, the determinant is simply the difference of its diagonal products.
For larger matrices, calculating the determinant isn’t that simple. There are three different methods to calculate the determinant of an 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 and . 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 matrix. This doesn’t restrict these properties to only matrices. They’re valid for any matrix.
Determinant and singularity
If , the matrix is singular. For invertible matrices, .
Let’s have a look at the determinant formula for computing the inverse of a matrix:
...