MathalyseResearch

Learn AI · Chapter 2 · Linear Algebra

The Determinant

See the determinant as the factor by which a matrix scales area and volume, connect it to the product of the eigenvalues, and recognize what a determinant of 0 or 1 does to space.

Book §2.11, pages 47About 30 minutes
Section 1

The scaling factor of space

How to use this page

Click the colored symbols. Drag the arrow tips, and guess before each Predict first answer.

Picture a grid printed on a rubber sheet. A square matrix stretches, squeezes or flips it, carrying each point to .

The determinant is one real number. Its size is the area scaling; its sign says whether the sheet was turned over.

, , matrix, point, squeeze factor , determinant, area , , second matrix, eigenvalues
Predict first

You stretch the first arrow to twice its length and leave the second alone. By what factor does the area change?

Area scaling and orientation

Drag the two arrow tips. Orange is the first column, gold the second. The gray square is the original, the teal one is its image.

A preset sets a state for you to read. It does not solve a challenge: only your own edits count.

original unit squareimage of the squarefirst columnsecond column
Set the four entries with sliders
Challenge +8 XP

Squash the parallelogram: drag or type until the size of is within 0.02 of 0.5, with the first tip beyond x = 1.5.

Challenge +8 XP

Turn the picture over: make the determinant less than −1.

For a 2 by 2 matrix there is a short formula, added here and not printed in the book:

The columns of are where the arrows (1, 0) and (0, 1) land. The unit square becomes the parallelogram they span, and is its area, with a sign.

One doubled column doubles the area. A rotation keeps it.

Predict first

The Shear preset tilts the square but keeps its base and height. A region of area 5 is sheared by the same matrix. What is its area now?

The Mirror button gives a negative determinant, and the picture turns backwards, yet the area stays positive. So the size of the number is the scaling, and the sign records the flip.

Going deeper: one factor for every region (a consequence, added here)

The same factor applies to every region, because the matrix acts alike everywhere. For any region of the plane, with its area or volume:

Think of a copier enlarging a photograph: every shape in it grows by the same factor.

Section 2

The product of the eigenvalues

The book gives a second route: the determinant equals the product of all the eigenvalues.

Recall Section 2.7. An eigenvector of is a direction only stretched, by the eigenvalue . Areas grow by the product of the eigenvalues.

Predict first

The Saddle preset below has eigenvalues 3 and −1. What determinant do you expect?

A negative eigenvalue flips its direction, so one negative eigenvalue makes the determinant negative. Eigenvalues may be complex. A rotation-and-scale matrix has the pair , and the pair multiplies to the real number , its area scaling.

Eigenvalues and the determinant

The unit circle becomes an ellipse. Drag the circle tips (orange and gold) to reshape it. Dashed lines are eigenvector directions, when they exist.

A preset sets a state for you to read. It does not solve a challenge: only your own edits count.

unit circleimage ellipseeigenvector lineseigenvector scaled by
Set the four entries with sliders
Challenge +8 XP

Edit the entries by hand until the eigenvalues turn complex: no dashed eigenvector line is left on the picture.

Saddle: one eigenvalue is negative, so the determinant is negative and the ellipse is mirrored.

Shear: both eigenvalues are 1, only one eigenvector direction exists, and the determinant is still 1. Rotation: no real eigenvector, complex eigenvalues, determinant 1. Collapse: a zero eigenvalue gives determinant 0.

Going deeper: why the product (added here, not in the book)

If , with diagonal and holding the eigenvalues, determinants multiply (Section 4). The factors and cancel, and a diagonal determinant is the product of its diagonal entries:

By hand: the matrix with rows (2, 1) and (1, 2) has eigenvalues 3 and 1. The formula gives , and the product is .

Section 3

Determinant 0 and determinant 1

The book singles out two values: determinant 0 loses volume, and determinant 1 preserves it.

Build the first case slowly. keeps one direction fixed and multiplies the perpendicular one by . Start at , then slide down.

Losing a dimension

image of the squarea segment lost in the squeezed directionoriginal square
Challenge +8 XP

Collapse the plane onto a line that points at 120°: set the kept direction to 120° and the scale to 0.

At the whole plane lands on one line. The orange segment shrinks to a dot: its two ends are sent to the same place. That is what “squeezed completely along one dimension” means. The determinant is , so it is 0, and since two points share an image no matrix can undo the map: a matrix with determinant 0 has no inverse.

Predict first

The scale is now −1. What does the determinant do?

For the squeezed direction reverses. The kept direction can be any angle, so the collapse does not need the axes to line up.

Determinant 1 is the mirror story. Volume is neither created nor destroyed, but shapes may change. Pick a way to keep the area:

Three ways to keep the area

In every tab the determinant stays at 1. That does not mean the matrix leaves everything alone; it says only that total area is kept.

Three dimensions: volume

In three dimensions the three columns of a 3 by 3 matrix span a slanted box, a parallelepiped, and the absolute value of the determinant is its volume. Drag the picture sideways to turn the box. Slide Flatten and the third edge sinks into the plane of the first two.

A box that loses its volume

first columnsecond columnthird columnunit cube
Challenge +8 XP

Flatten the box completely: bring Flatten to 1 so the determinant drops to 0.

Flatten changes the determinant linearly, since only the third column moves. At full flatten the third column equals the sum of the first two: the columns are linearly dependent. A zero determinant and dependent columns always go together.

Going deeper: the 3 by 3 formula (added here)

Expanding along the first row gives:

Section 4

Combining transformations

This section is added to the lesson. One more fact makes the determinant usable: determinants multiply.

The product applies first and then . Scale areas by 2, then by 3, and the combination scales them by 6.

Predict first

Matrix scales areas by 0.5 and matrix scales them by 4. By how much does the product scale areas?

The determinant of a product

Drag the violet tips on the picture to reshape . Use the sliders for either matrix.

Matrix (applied first)
Matrix (applied second)

unit squareafter after and then

The readout computes the determinant of the product two ways, from the entries of and as the product of the two determinants, and measures the final area by the shoelace formula on the drawn corners. All three agree.

Challenge +8 XP

Make lose a dimension (its determinant within 0.01 of 0) while keeps one. Watch what happens to the product.

Once a dimension is lost, no later matrix can bring it back.

Going deeper: why this matters in machine learning (background added here)

A random point pushed through a linear map changes density by the determinant of that map: the same probability is spread over a larger area, so the density falls by that factor. That is why the normalizing constant of a Gaussian contains the determinant of its covariance matrix. Later chapters of the book treat it properly.

  • The determinant maps a square matrix to a real number. Its absolute value is the factor by which the matrix scales area in the plane or volume in space, and a negative sign records a flip.
  • It equals the product of all eigenvalues, with complex ones counted in conjugate pairs. For 2 by 2 it is .
  • Determinant 0 means space is flattened along at least one dimension: volume is lost, two different points share an image, and no inverse exists.
  • Determinant 1 means volume is preserved, although shapes may change (rotations and shears).
  • Determinants multiply under composition: .
Final quiz

Check yourself

Questions that mix the whole module. Each one is scored, and the score feeds your mastery of this module.

Source: Ian Goodfellow, Yoshua Bengio and Aaron Courville, Deep Learning, MIT Press, 2016, Section 2.11 (pages 47), free to read at deeplearningbook.org. Where the book prints equation numbers, the numbers here follow the book. The order of ideas follows the book. The explanations and all demos were written for this page.