Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

The Determinant

Populating the interactive namespace from numpy and matplotlib

The Determinant

This chapter is also very light! We will see what is the meaning of the determinant of a matrix. This special number can tell us a lot of things about our matrix!

The Determinant

We saw in 2.8 that a matrix can be seen as a linear transformation of the space. The determinant of a matrix A\boldsymbol{A} is a number corresponding to the multiplicative change you get when you transform your space with this matrix (see a comment by Pete L. Clark in this SE question). A negative determinant means that there is a change in orientation (and not just a rescaling and/or a rotation). As outlined by Nykamp DQ on Math Insight, a change in orientation means for instance in 2D that we take a plane out of these 2 dimensions, do some transformations and get back to the initial 2D space. Here is an example distinguishing between positive and negative determinant:

Comparison of positive and negative determinant The determinant of a matrix can tell you a lot of things about the transformation associated with this matrix

You can see that the second transformation can’t be obtained through rotation and rescaling. Thus the sign can tell you the nature of the transformation associated with the matrix!

In addition, the determinant also gives you the amount of transformation. If you take the n-dimensional unit cube and apply the matrix A\boldsymbol{A} on it, the absolute value of the determinant corresponds to the area of the transformed figure. You might believe me more easily after the following example.

Example 1.

To calculate the area of the shapes, we will use simple squares in 2 dimensions. The unit square area can be calculated with the Pythagorean theorem taking the two unit vectors.

Illustration of the unit square area and the unit vectors in two dimensions The unit square area

The lengths of ii and jj are 1 thus the area of the unit square is 1.

Let’s start by creating both vectors in Python:

<matplotlib.figure.Figure at 0x109d78890>

We will apply

A=[2002]\boldsymbol{A}=\begin{bmatrix} 2 & 0\\\\ 0 & 2 \end{bmatrix}

to ii and jj. You can notice that this matrix is special: it is diagonal. So it will only rescale our space. No rotation here. More precisely, it will rescale each dimension the same way because the diagonal values are identical. Let’s create the matrix A\boldsymbol{A}:

array([[2, 0], [0, 2]])

Now we will apply A\boldsymbol{A} on our two unit vectors ii and jj and plot the resulting new vectors:

<matplotlib.figure.Figure at 0x109d164d0>

As expected, we can see that the square corresponding to ii and jj didn’t rotate but the lengths of ii and jj have doubled. We will now calculate the determinant of A\boldsymbol{A} (you can go to the Wikipedia article for more details about the calculation of the determinant):

Areas of the unit square and its transformation by the matrix The unit square transformed by the matrix
4.0

And yes, the transformation have multiplied the area of the unit square by 4. The lengths of newinew_i and newjnew_j are 2 (thus 2⋅2=42\cdot2=4).

Example 2.

Let’s see now an example of negative determinant.

We will transform the unit square with the matrix:

B=[−2002]\boldsymbol{B}=\begin{bmatrix} -2 & 0\\\\ 0 & 2 \end{bmatrix}

Its determinant is -4:

-4.0
<matplotlib.figure.Figure at 0x109b16c10>

We can see that the matrices with determinant 2 and -2 modified the area of the unit square the same way.

Areas of the unit square and its transformation by the matrix with a negative determinant The unit square transformed by the matrix with a negative determinant

The absolute value of the determinant shows that, as in the first example, the area of the new square is 4 times the area of the unit square. But this time, it was not just a rescaling but also a transformation. It is not obvious with only the unit vectors so let’s transform some random points. We will use the matrix

C=[−1001]\boldsymbol{C}=\begin{bmatrix} -1 & 0\\\\ 0 & 1 \end{bmatrix}

that has a determinant equal to -1 for simplicity:

-1.0

Since the determinant is -1, the area of the space will not be changed. However, since it is negative we will observe a transformation that we can’t obtain through rotation:

<matplotlib.figure.Figure at 0x108e64a90>

You can see that the transformation mirrored the initial shape.

Conclusion

We have seen that the determinant of a matrix is a special value telling us a lot of things on the transformation corresponding to this matrix. Now hang on and go to the last chapter on the Principal Component Analysis (PCA).