Determinants and the Inverse
An analyst adds a new column to the flats table: size in square feet, right next to size in square metres. Training suddenly fails with "singular matrix". Nothing is wrong with the code. The two columns say the same thing, and the determinant is how you see that.
The rule
Determinant zero means information lost, and no inverse brings it back.
A 2 × 2 matrix has determinant . Think of the matrix as a machine that moves every point in the plane. The determinant is how much it scales areas:
- : determinant . Areas keep their size.
- : determinant . The second column is twice the first, so the whole plane is squashed onto a line.
The inverse undoes the machine: , the identity. If the plane was squashed onto a line, many points landed on the same spot, and no machine can tell them apart again. So:
- determinant not zero → an inverse exists;
- determinant zero → no inverse (the matrix is singular).
Because the inverse undoes the scaling, its determinant is one over the original: if then .
In ML, the classic linear-regression formula needs the inverse of . If one feature column is a multiple of another, like square feet and square metres, that matrix is singular. The fix is to drop the duplicate or add regularisation. Libraries solve the equations directly rather than forming the inverse, but the same singularity still breaks them.
The shortcut
For a 2 × 2 inverse: swap the diagonal, negate the off-diagonal, divide by the determinant.
Determinant first
4 × 2 − 2 × 3 = 8 − 6 = 2. Not zero, so an inverse exists.
Always compute the determinant first. If it is zero, stop: there is nothing to divide by.
Drills
Answer fast — trust the rule.
What is the determinant of [[3, 2], [1, 4]]?
Which matrix has no inverse?
What is the inverse of [[2, 1], [1, 1]]?
Why does adding size in square feet next to size in square metres break the inverse of X transposed times X?
If a matrix has determinant 0.5, what is the determinant of its inverse?
Remember
- Determinant zero means information lost, and no inverse brings it back.
- Shortcut for 2 × 2: swap the diagonal, negate the off-diagonal, divide by the determinant.
- Trap: duplicate or proportional features make the matrix singular.
