Tuesday 7 May 2019

Visualizing linear algebra: Determinant

Figure 1: The determinant of the unit matrix is 1
This is Part 3 in a series on linear algebra [1].

Consider the 1x1 unit square in Figure 1 whose sides are circumscribed by i-hat and j-hat. When a linear transformation is applied to the vector space, the unit square is transformed into a parallelogram. The factor by which the transformation scales the area is called the determinant of that transformation.

Figure 2: The determinant of any matrix is ad - bc
The equation for calculating the determinant is

det([a b]) = ad - bc
    [c d]

The determinant is a measure of the area of a parallelogram. However in the cases where i-hat switches to the left of j-hat, the determinant will be negative. This can be understood geometrically as the flipping of the area, like turning over a piece of paper (i.e., inverting the matrix).

Some transformations will result in i-hat and j-hat ending up on the same line, in which case the area and thus the determinant will be 0.

Figure 2 shows how the equation is derived. Breaking it down:

det([a b]) = (a + b)(c + d) - ac - bd - 2bcad - bc
    [c d]

The calculation takes the area of the rectangle circumscribing the parallelogram and then just subtracts the areas of the smaller squares and triangles surrounding the parallelogram.

When either b or c are equal to 0, the area will just be ad. This corresponds to when either i-hat or j-hat remain on their original axes. That is, when the final shape is either a rectangle (in the case of both b and c being 0) or a shear along just one dimension.

Figure 3:The determinant of this flipped area is -3
Working through some examples, the matrix in Figure 3 is

[1  2]
[1 -1]

The determinant is

ad - bc = 1*-1 - 2*1 = -3

Note that i-hat ends up to the left of j-hat which means the orientation of space has been inverted resulting in a negative determinant.

Figure 4: The determinant of a line is 0
The matrix in Figure 4 is

[4 2]
[2 1]

The determinant is

ad - bc = 4*1 - 2*2 = 0

Note that i-hat ends up on the same line as j-hat (i.e., the matrix columns are linearly dependent) which means the determinant must be 0. A matrix with a determinant of 0 is also termed a degenerate or non-invertible matrix.

Figure 5: A parallelepiped
The determinant can also be calculated for square matrices that are three dimensional or higher. In the case of a 3x3 matrix, the determinant is a measure of the volume of a parallelepiped and the equation is

det([a b c])
    [d e f]  = a det([e f]) 
    [g h i]          [g h]
             - b det([d f])
                     [h i]
             + c det([d e])
                     [g i]

The determinant will be negative when the 3D space is inverted which can be determined visually using the right-hand-rule. A determinant of 0 would mean that the space is transformed to a lower dimensional space with zero volume and so would be either a plane, a line, or a point. In this special case, the columns of the matrix are linearly dependent.

--

[1] The figures and examples of the posts in this series are based on the Essence of Linear Algebra series by 3Blue1Brown.

No comments:

Post a Comment