§2.5 Norms — measuring the size of a vector
Machine learning measures vector size with a norm norm A size measure for vectors: f(x)=0 ⟹ x=0, triangle inequality, |α|-homogeneity; the Lᵖ family (‖x‖ₚ). defined in ch. 2 — open in glossary , most often from the family:
Term by term
| each element enters through its absolute value — sign never matters to size | scalar ≥ 0 | |
| the exponent that decides HOW sizes combine: small p treats elements equally, large p lets the biggest dominate | real ≥ 1 | |
| the distance from the origin to x, as measured by this p | scalar ≥ 0 |
Formally a norm is any function with three properties: ; the triangle inequality ; and homogeneity .
‖x‖2 = 1.000
The shaded region is the unit ball ‖x‖ₚ ≤ 1. At p = 1 it has corners ON the axes — the geometric seed of L¹'s preference for exact zeros (§7.1 builds on this).
The family members you will meet constantly:
- (Euclidean) — so common it is written plainly . Its square is just , which is far nicer analytically: each derivative depends only on its own element, while derivatives of the unsquared norm entangle the whole vector.
- — . The squared norm grows very slowly near the origin; when the difference between exactly-zero and small-but-nonzero matters, grows at the same rate everywhere ( of movement costs exactly ).
- "" — counting nonzero entries is not a norm (scaling by doesn’t change the count, violating homogeneity); the term is a common abuse. is the usual substitute.
- (max norm) — .
- Frobenius norm frobenius norm The matrix analogue of L²: ‖A‖_F = √Σ A²_{i,j} = √Tr(AAᵀ). defined in ch. 2 — open in glossary for matrices — , the of a matrix flattened.
Worked example — one vector, three sizes
For : ; ; . Always .
Finally, the dot product in norm language: with the angle between them.
§2.6 Special matrices and vectors
- A diagonal matrix diagonal matrix Nonzero entries only on the main diagonal; diag(v)x = v⊙x — multiply and invert cheaply. defined in ch. 2 — open in glossary is mostly zeros; multiplying is just element-wise scaling () and inverting is element-wise reciprocals (, existing iff every ). Many algorithms get cheaper (and less expressive) when a general matrix is restricted to diagonal. Rectangular diagonal matrices exist too: multiply-then-pad (tall) or multiply-then-truncate (wide).
- A symmetric matrix symmetric matrix A = Aᵀ; arises from order-independent two-argument functions like distances. defined in ch. 2 — open in glossary equals its transpose — typical when entries come from an order-independent function, like distances: .
- A unit vector unit vector A vector with ‖x‖₂ = 1. defined in ch. 2 — open in glossary has . Vectors with are orthogonal (at 90° if nonzero); at most nonzero vectors in can be mutually orthogonal; orthogonal + unit norm = orthonormal.
- An orthogonal matrix orthogonal matrix Square with mutually orthonormal rows AND columns: AᵀA = AAᵀ = I, so A⁻¹ = Aᵀ. defined in ch. 2 — open in glossary has mutually orthonormal rows AND columns: , hence — inversion for the price of a transpose. (Watch the naming trap: the matrix is called orthogonal but its rows are orthonormal; there is no special name for merely-orthogonal rows.)
§2.7 Eigendecomposition
Integers reveal their nature when factored into primes — tells us things no digit string does. Matrices factor too. An eigenvector eigenvector Nonzero v with Av = λv — multiplication by A only rescales it. defined in ch. 2 — open in glossary of is a nonzero direction that multiplication by only rescales, and its scale factor is the eigenvalue eigenvalue The scale factor λ paired with an eigenvector. defined in ch. 2 — open in glossary :
Term by term
| an eigenvector — a direction A does not rotate (any rescaling sv works too, so we use unit v) | n×1, ≠ 0 | |
| its eigenvalue — how much A stretches (|λ|>1), shrinks (|λ|<1), or flips (λ<0) that direction | scalar |
With independent eigenvectors as columns of and eigenvalues in , the eigendecomposition eigendecomposition A = V diag(λ)V⁻¹; real symmetric matrices give A = QΛQᵀ with orthogonal Q — scaling space by λᵢ along eigendirection i. defined in ch. 2 — open in glossary is . Not every matrix has one (some need complex numbers; non-square matrices have none) — but every real symmetric matrix decomposes with real values and an orthogonal eigenbasis:
What this really says
A symmetric matrix is nothing but independent stretches along perpendicular axes: rotate into the eigenbasis (), scale each axis by its (), rotate back (). Every fact below — determinants, definiteness, conditioning in ch. 4 — is read straight off those stretch factors.
A = [[1.68, 0.56], [0.56, 1.02]] (symmetric)
det(A) = λ₁λ₂ = 1.40
class: positive definite
What the decomposition tells you:
- Uniqueness: sort descending; unique iff all eigenvalues distinct (repeated λ’s let any orthogonal basis of their span serve).
- Singularity: is singular ⟺ some eigenvalue is 0 (watch the ellipse flatten in the widget as λ₂ → 0).
- Quadratic optimization: for with , equals whenever is the corresponding eigenvector; max/min over the sphere = max/min eigenvalue.
- Definiteness: all λ > 0 → positive definite positive definite All eigenvalues > 0; guarantees xᵀAx > 0 for x ≠ 0 (semidefinite allows zeros). defined in ch. 2 — open in glossary (); λ ≥ 0 → positive semidefinite (); mirrored for negative (semi)definite.
Worked example — eigen-factor a 2×2
: along , — so . Along , . Set the widget to λ₁=2 → try it: with θ=45° you can reproduce this A up to scale. Positive definite (both λ > 0), det = 8.
§2.8 Singular value decomposition
The SVD singular value decomposition A = UDVᵀ for ANY real matrix: orthogonal U, V and rectangular-diagonal D of singular values. defined in ch. 2 — open in glossary factors every real matrix — square or not — where eigendecomposition may not exist:
Term by term
| orthogonal; columns = left-singular vectors = eigenvectors of AAᵀ | m×m | |
| rectangular diagonal; entries = singular values = √ of eigenvalues of AᵀA | m×n | |
| orthogonal; columns = right-singular vectors = eigenvectors of AᵀA | n×n |
Any linear map = rotate → per-axis scale → rotate (diagram not in the book). The EigenLens above is the special case U = V = Q.
§2.9 The Moore-Penrose pseudoinverse
Non-square matrices have no inverse, but linear equations still want solving. The pseudoinverse moore-penrose pseudoinverse A⁺ = VD⁺Uᵀ: minimal-norm solution for wide A, least-squares closest solution for tall A. defined in ch. 2 — open in glossary is defined as , but computed via the SVD:
Term by term
| reciprocate the nonzero singular values, then transpose the (rectangular) result | n×m | |
| the "best-effort inverse": run the SVD pipeline backwards, skipping the collapsed directions | n×m |
Its behavior depends on ‘s shape:
- Wide (more columns than rows, typically ∞ solutions): is the solution with minimal norm among all of them.
- Tall (more rows than columns, possibly no solution): it gives the making as close as possible to in — least squares, previewing chapter 4’s worked example.
§2.10 The trace operator
The trace trace Tr(A) = Σᵢ A_{i,i}; transpose-invariant and cyclic-permutation-invariant — the workhorse of matrix calculus. defined in ch. 2 — open in glossary sums the diagonal: . It converts summation-notation gymnastics into algebra:
- transpose-invariant:
- cyclic-permutation-invariant: — valid even when the cycled products have different shapes: for , , though one is and the other .
- a scalar is its own trace: .
Worked example — cycling a trace
(1×2), (2×1). (1×1), trace 11. (2×2), trace . Different shapes, same trace — this identity powers the PCA derivation in the next section.
Check yourself — norms to trace
1.Why is counting nonzero entries (the so-called 'L⁰ norm') not actually a norm?
2.In the NormBallLab, what happens to the unit ball's corners as p slides from 2 down to 1, and why will ch. 7 care?
3.In the EigenLens, you set λ₁ = 2, λ₂ = 0. What do you observe?
4.Why does the book emphasize the SVD over eigendecomposition?
5.A is tall (more rows than columns) and Ax = y has no exact solution. What does x = A⁺y give you?