Chapter 7: Determinants

Previous: LA 06 Orthogonality and Least Squares | LA 00 Course Map | Next: LA 08 Eigenvalues and Eigenvectors

The big idea

The determinant of a square matrix is one number that says how much the matrix scales area (or volume). Its sign says whether the matrix flips space over like a mirror. It is zero exactly when the matrix flattens space, and so exactly when the matrix has no inverse.

In this chapter you will learn to
  1. Explain what a determinant measures, using pictures.
  2. Compute determinants of and matrices, and of any size by elimination.
  3. Use the properties of determinants to compute quickly and to reason.
  4. Use the determinant to test invertibility.
  5. Recognize where determinants appear: change of variables, cross products, Gaussians.
Before you start

You need matrices as maps and the inverse (LA 03 Matrices as Linear Maps), and elimination (LA 04 Solving Linear Systems).


7.1 What a determinant measures

Start with a picture

Take the unit square, with corners , , , . Its area is 1.

Apply a matrix . From chapter 3, lands on the first column of and on the second. Because keeps lines straight and parallel lines parallel, the square becomes a parallelogram with the two columns as its sides.

Definition (geometric): determinant

The determinant is the signed area of the parallelogram that the unit square becomes. In 3-D, it is the signed volume of the box (parallelepiped) that the unit cube becomes.

Since every region can be cut into tiny squares, and every tiny square is scaled the same way, multiplies the area of every region by .

Reading the number

What happens to space
areas tripled
areas halved
areas kept (but shapes may change, as with a shear)
areas kept, and the plane is flipped like a mirror image
everything squashed onto a line or a point: area zero

What the sign means

Walk from to : that is a counterclockwise turn. After the map, walk from column 1 to column 2. If that is still counterclockwise, orientation is kept and . If it became clockwise, the map flipped space over and .

A reflection in a mirror flips orientation (your left hand becomes a right hand). A rotation never does.

Why zero matters most

The invertibility test

Why. If , the matrix flattens space into something lower-dimensional. Many different points land on the same spot, so no map can send them back: information was lost. If , nothing is flattened and the map can be undone.

This adds another line to the list of equivalent conditions from chapter 4: a square matrix is invertible exactly when its determinant is nonzero, exactly when its columns are independent, exactly when it has full rank.


7.2 Computing determinants

“Down-right diagonal minus up-right diagonal.”

Worked example 7.1. . Areas are multiplied by 5.

Worked example 7.2. . The columns and are parallel; the parallelogram is flat.

Worked example 7.3. Rotation by : . Rotations keep area and orientation.

Worked example 7.4. Reflection across the -axis: . Area kept, orientation flipped.

Why is the area

Here is an argument using the fact that shears do not change area (sliding the top of a parallelogram sideways keeps its base and height).

Start with columns and , and suppose .

  1. Subtract times column 1 from column 2. This is a shear, so the area is unchanged. Column 2 becomes .
  2. Now subtract a multiple of the new column 2 from column 1 to clear its second entry. Another shear. Column 1 becomes .
  3. The shape is now a rectangle with sides and . Its signed area is .

7.3 Computing determinants

Cofactor expansion

How to read it. Go along the top row. For each entry:

  1. cross out its row and column,
  2. take the determinant of what is left (the minor),
  3. multiply by the entry,
  4. attach the sign from the checkerboard pattern:

Add the three results.

Worked example 7.5.

  • Entry 1: minor . Sign . Contribution .
  • Entry 2: minor . Sign . Contribution .
  • Entry 3: minor . Sign . Contribution .

Total: .

Expand along the easiest row or column

You may expand along any row or column, as long as you use the checkerboard signs for that row or column. Choose the one with the most zeros, since zero entries contribute nothing.

Worked example 7.6.

Column 2 has two zeros. Expand down it: only the entry 4 (row 3, column 2) contributes, with sign :

Triangular matrices

The fastest case

The determinant of a triangular matrix (all zeros above, or all zeros below, the diagonal) is the product of its diagonal entries.

Why: expand down the first column. Only the top entry is nonzero, leaving a smaller triangular matrix. Repeat.


7.4 Properties

These are the rules that make determinants useful. Each one has a geometric reason.

PropertyFormulaWhy it makes sense
identitydoing nothing keeps volume
productscale by one factor, then the other
inverseundoing a scaling
transposerows and columns play equal roles
scalar for each of the edges is scaled by
row swapchanges the signorientation flips
row replacement(add a multiple of one row to another) no changeit is a shear
row scalingmultiplying one row by multiplies by one edge scaled
repeated rowthe box is flat

The product rule in action

Worked example 7.7. If and (both ):

  • (not )
No rule for sums

in general. Example: for , but .

Orthogonal matrices

If , then , so and .

  • Rotations have .
  • Reflections have .

A rotation matrix computed in robotics code must have determinant exactly . If you get , a sign or axis convention is wrong somewhere: you have built a mirror image.


7.5 Determinants by elimination

Cofactor expansion of an matrix needs about multiplications. For that is about : hopeless. Elimination is far faster.

Method.

  1. Row reduce to triangular form using only row replacements and swaps.
  2. Each swap flips the sign. Replacements change nothing.
  3. Multiply the diagonal entries (the pivots).

Worked example 7.8. From chapter 4, elimination on

used only replacements and gave pivots . So .

Worked example 7.9.

One swap; pivots . So .

This also shows the invertibility test from another angle: exactly when all pivots are nonzero.


7.6 Where determinants appear

Change of variables in integrals

When you change variables in a double integral, a tiny rectangle is mapped to a tiny parallelogram. Its area is scaled by the absolute determinant of the Jacobian matrix (the matrix of partial derivatives). For polar coordinates , :

That is why . The same factor appears when transforming probability densities (PS 05 Continuous Random Variables).

Cross product in 3-D

The cross product is perpendicular to both, and its length is the area of the parallelogram they span. It can be written as a determinant:

The triple product is the volume of the box with those three edges. Torque () and angular velocity use cross products throughout robotics.

Gaussians

The density of a multivariate Gaussian has in its normalizing constant. is the squared volume of the uncertainty ellipsoid (PS 07 The Multivariate Gaussian).

Robot singularities

For a square Jacobian , marks a singularity: the arm cannot move its hand in some direction. For a 2-link planar arm, , which is zero when the elbow is straight or fully folded (02 Geometry and Kinematics).


7.7 A common trap: “small determinant” is not “nearly singular”

It is tempting to think a tiny determinant means a matrix is almost singular. It does not. Take in 100 dimensions:

Yet is perfectly well behaved: its inverse is , and solving is trivial and accurate. The determinant is tiny only because it multiplies a mild shrinking over 100 dimensions.

To measure how close a matrix is to singular, use the condition number (chapter 12), which compares the largest and smallest stretching factors.


Summary

IdeaFact
meaningsigned area/volume scaling factor
cofactor expansion with signs
triangularproduct of the diagonal
any sizeelimination: product of pivots
product
invertible
rotation / reflection /

Three facts to remember:

  1. Determinant = volume scaling factor, with a sign for flipping.
  2. space is flattened no inverse.
  3. Determinants multiply: . They do not add.

Exercises

Part A: warm-up

A1. Compute . What does the matrix do to the area of a region of area 2?

A2. Compute .

A3. Compute .

A4. and are with , . Find , , , .

Part B: core

B1. Find all with . (You are finding the eigenvalues of chapter 8.)

B2. Compute by elimination: .

B3. Without computing, explain why .

B4. Find the area of the triangle with vertices , , . (Hint: use two edge vectors and halve a determinant.)

B5. Compute the cross product and check it is perpendicular to both.

B6. For the 2-link arm with , . At which elbow angles is the arm singular? At which is the determinant largest?

Part C: explain and prove

C1. Use the product rule to prove that if is invertible, .

C2. Prove that similar matrices () have the same determinant.

C3. Show that if a square matrix has a row of zeros, its determinant is zero, in two ways: by cofactor expansion, and geometrically.

C4. Prove that for an matrix, using the row-scaling property.

C5. Explain why a matrix with real entries and cannot be a rotation.

Part D: practise with code

D1. Check your answers to A2, B2 and example 7.5 with np.linalg.det.

D2. Make the matrices 0.1 * np.eye(n) for n = 10, 50, 100, 400. Print det and np.linalg.cond. What happens to each, and what does that show about using the determinant to detect near-singularity?

D3. Draw the unit square and its image under . Use the “shoelace” polygon area formula to measure the image’s area numerically, and compare with the determinant.

D4. For large n, time np.linalg.det on a random n x n matrix for n = 100, 200, 400, 800. How does the time grow? Compare with how grows.


Where this is used

Next: LA 08 Eigenvalues and Eigenvectors: the directions a matrix only stretches.