Chapter 7: Determinants
Previous: LA 06 Orthogonality and Least Squares | LA 00 Course Map | Next: LA 08 Eigenvalues and Eigenvectors
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.
- Explain what a determinant measures, using pictures.
- Compute determinants of and matrices, and of any size by elimination.
- Use the properties of determinants to compute quickly and to reason.
- Use the determinant to test invertibility.
- Recognize where determinants appear: change of variables, cross products, Gaussians.
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.
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
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 .
- Subtract times column 1 from column 2. This is a shear, so the area is unchanged. Column 2 becomes .
- Now subtract a multiple of the new column 2 from column 1 to clear its second entry. Another shear. Column 1 becomes .
- The shape is now a rectangle with sides and . Its signed area is .
- Compute . Does the map flip orientation?
- For which is not invertible?
- What is of the shear ?
Answers. 1. . Yes, it flips (and keeps area). 2. , so . 3. : shears keep area.
7.3 Computing determinants
Cofactor expansion
How to read it. Go along the top row. For each entry:
- cross out its row and column,
- take the determinant of what is left (the minor),
- multiply by the entry,
- 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 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.
- Compute by expanding along the first row.
- Compute .
Answers. 1. . 2. Lower triangular: .
7.4 Properties
These are the rules that make determinants useful. Each one has a geometric reason.
| Property | Formula | Why it makes sense |
|---|---|---|
| identity | doing nothing keeps volume | |
| product | scale by one factor, then the other | |
| inverse | undoing a scaling | |
| transpose | rows and columns play equal roles | |
| scalar | for | each of the edges is scaled by |
| row swap | changes the sign | orientation flips |
| row replacement | (add a multiple of one row to another) no change | it is a shear |
| row scaling | multiplying one row by multiplies by | one edge scaled |
| repeated row | the box is flat |
The product rule in action
Worked example 7.7. If and (both ):
- (not )
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.
- Row reduce to triangular form using only row replacements and swaps.
- Each swap flips the sign. Replacements change nothing.
- 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
| Idea | Fact |
|---|---|
| meaning | signed area/volume scaling factor |
| cofactor expansion with signs | |
| triangular | product of the diagonal |
| any size | elimination: product of pivots |
| product | |
| invertible | |
| rotation / reflection | / |
Three facts to remember:
- Determinant = volume scaling factor, with a sign for flipping.
- space is flattened no inverse.
- 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 , , , .
A1. . The area becomes 20.
A2. First row: .
A3. Upper triangular: .
A4. ; ; ; .
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?
B1. , so , giving or .
B2. Swap (sign flips): . , . Swap (flips again): pivots . Two swaps, so . Check by cofactors on the original: ✓.
B3. Row 3 equals row 1 plus row 2. The rows are dependent, so the box they span is flat.
B4. Edges and . . Triangle area .
B5. . Dot products: and ✓.
B6. Singular at (straight) and (folded back). Largest at .
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.
C1. .
C2. .
C3. Expanding along the zero row, every term contains a zero factor. Geometrically, one edge of the box is the zero vector, so the box is flat.
C4. multiplies each of the rows by . Each row scaling multiplies the determinant by , giving in total.
C5. Rotations are orthogonal with . A negative determinant means orientation is reversed, which requires a reflection.
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.
D2. The determinant underflows to for large , but the condition number stays exactly 1: perfectly well conditioned.
D4. Time grows roughly like (doubling multiplies time by about 8), because NumPy uses LU elimination, not cofactors.
Where this is used
- Singularities of robot arms (02 Geometry and Kinematics).
- Normalizing flows and density transformations, which track (PS 05 Continuous Random Variables).
- Uncertainty volume of Gaussians (PS 07 The Multivariate Gaussian).
- The characteristic equation of the next chapter, .
Next: LA 08 Eigenvalues and Eigenvectors: the directions a matrix only stretches.