§2.11 The determinant
The determinant determinant det(A) = product of eigenvalues; |det| measures how much A expands or contracts volume. defined in ch. 2 — open in glossary maps a square matrix to a scalar — and it is simply the product of all the eigenvalues. Its absolute value measures how much multiplication by expands or contracts volume:
- : space is contracted completely along at least one dimension — all volume is lost (the matrix is singular);
- : the transformation preserves volume.
You have already seen this: in the EigenLens of the previous section, det = λ₁λ₂ is exactly the area of the image ellipse relative to the unit circle — set λ₂ = 0 there and watch the volume vanish.
Worked example
from last section has , , so : the unit square maps to a parallelogram of area 8. Check by the 2×2 formula: ✓.
§2.12 Example: PCA from linear algebra alone
The chapter’s payoff: deriving a real machine learning algorithm — principal components analysis principal components analysis Lossy linear compression: encode c = Dᵀx, decode Dc; optimal D = top-l eigenvectors of XᵀX. defined in ch. 2 — open in glossary — using only what these pages built.
The setup. We have points and want lossy compression: store them with less memory, losing as little precision as possible. Encode each point as a lower-dimensional code () with an encoder and decoder — the same encoder/decoder shape as chapter 1’s autoencoder autoencoder An encoder plus decoder trained to preserve information while giving the representation useful properties. defined in ch. 1 — open in glossary , but purely linear. PCA is defined by its decoder choice: matrix multiplication,
Term by term
| the compact code for one point | l×1, l < n | |
| the decoding matrix — its l columns are the directions the code can mix; constrained to ORTHONORMAL columns (DᵀD = I) to make the math clean and the solution unique | n×l | |
| the reconstruction back in the original space | n×1 |
(Orthonormal columns kill two problems at once: without unit norm, any scaling of could be undone by shrinking — infinitely many equivalent solutions; and orthogonality will make the encoder trivial. Note still isn’t technically “an orthogonal matrix” unless .)
Step 1 — the optimal code for a fixed decoder
Minimize the distance between a point and its reconstruction:
step 1/9: Measure reconstruction error with the L² norm (eq 2.54).
So the encoder is and the whole PCA reconstruction is
What this really says
With an orthonormal , encoding is just reading off coordinates along the chosen directions, and reconstruction is projection onto their span. All that remains is choosing the directions — and that is where the data comes in.
Step 2 — the optimal directions
is shared by all points, so now the whole dataset matters. Stack the points into the design matrix design matrix X ∈ ℝ^{m×n} stacking one example per row: X_{i,:} = (x⁽ⁱ⁾)ᵀ. defined in ch. 2 — open in glossary , , and (for , where is a single unit vector ):
step 1/9: Minimize the error over ALL points and dimensions at once (eq 2.68) — D is shared, so points can no longer be treated in isolation.
See the arg-min with your hands
total squared error: 42.4
variance captured: 77.2%
Rotate d and watch the arg-min from the derivation: error is minimized exactly when d is the eigenvector of XᵀX with the largest eigenvalue.
Linear algebra is the first of the fundamental mathematical disciplines this book rests on. The other one, ubiquitous in machine learning, is probability theory — chapter 3.
Check yourself — determinant and PCA
1.det(A) = 0 tells you what, geometrically?
2.Why does PCA constrain D to have orthonormal columns?
3.In the c* derivation, why is switching from ‖·‖₂ to ‖·‖₂² 'legal'?
4.In the PCALab, you rotate d away from the snapped position. Predict the readouts.
5.For codes of dimension l > 1, what is the optimal D?