Eigenvector Computation and Low-Rank Approximations
Pages 1002 and 1004 both ended at the same instruction: take the top eigenvectors of . §10.4 is about carrying that out, and it opens two doors:
To get the eigenvalues (and the corresponding eigenvectors) of , we can follow two approaches: we perform an eigendecomposition and compute the eigenvalues and eigenvectors of directly. We use a singular value decomposition.
They give the same answer in exact arithmetic. In floating point they do not, and the difference is measurable.
What you’ll learn
Section titled “What you’ll learn”- Equations 10.47–10.49: the SVD of and the eigendecomposition of , and — measured to , with the eigenvectors agreeing to degrees.
- Why the SVD route is not merely an alternative. Forming squares the condition number, measured exactly: . At the eigendecomposition returns negative eigenvalues of and a worst relative error of ; the SVD holds .
- Equations 10.50–10.51, the Eckart-Young theorem: exactly, measured to .
- §10.4.2’s Abel-Ruffini note, and what it actually rules out: not eigenvalues, only closed-form roots of the characteristic polynomial past degree .
- Equation 10.52, power iteration, with its convergence rate measured against the prediction: predicted, observed by step .
- And what happens when the top of the spectrum is nearly tied: steps at a ratio of against at .
- When “wasteful to compute the full decomposition” becomes real: tens of times faster at for the top , with eigenvalues agreeing to better than .
Intuition: you built a matrix you did not need
Section titled “Intuition: you built a matrix you did not need”is a summary of , and forming it is a lossy step. Not lossy in what it represents — the eigenvectors are intact — but in how precisely small quantities survive.
Squaring a number spreads its logarithm. If ‘s singular values span , then
‘s eigenvalues span , which is all the room a float64 has. Anything past that is
gone, and what is past it is precisely the small end — the end Equation 10.44 sums to get .
The SVD reaches the same eigenvectors without ever forming the product. It is not a different method; it is the same method that skips a step which only ever loses information.
flowchart LR X["X, D x N"] -->|"form X X' / N"| S["S, D x D
kappa squared"] S -->|"eigh"| E1["lambda_d, b_d"] X -->|"svd, no product formed"| SV["U, Sigma, V'"] SV -->|"lambda_d = sigma_d^2 / N"| E2["the same lambda_d, b_d"] E1 -.->|"agree to 1.4e-13 here"| E2 SV --> EY["Eckart-Young:
truncate at M
Equation 10.51"]
§10.4 The two routes
Section titled “§10.4 The two routes”The SVD is with and orthogonal, so
The columns of are the eigenvectors of , and
| gap | ||||
|---|---|---|---|---|
Largest gap over all : . Worst angle between and over the top : degrees.
Why this is not a matter of taste
Section titled “Why this is not a matter of taste”. Measured on the digit-”8” data:
| value | |
|---|---|
| , from the nonzero singular values | |
| , from the nonzero eigenvalues | |
| their ratio |
At that is harmless. Pushed on a synthetic matrix whose singular values span a chosen range:
worst relative error, eigh | worst relative error, SVD | negative eigenvalues from eigh | ||
|---|---|---|---|---|
| of |
§10.4.1 Eckart-Young
Section titled “§10.4.1 Eckart-Young”The best rank- approximation in the spectral norm,
is obtained “by truncating the SVD at the top- singular value”:
| gap | best of random rank- | |||
|---|---|---|---|---|
The Frobenius-norm version, which is the one PCA actually optimises:
Squaring the last column and dividing by recovers page 1004’s — — because . Eckart-Young and Equation 10.44 are the same theorem in two notations.
§10.4.2 Practical aspects
Section titled “§10.4.2 Practical aspects”Two claims here, and they are about different things.
Abel-Ruffini. Eigenvalues are roots of the characteristic polynomial, and for degree or more there is “no algebraic solution” — no formula in radicals. “Therefore, in practice, we solve for eigenvalues or singular values using iterative methods.”
Only vectors are wanted. “It would be wasteful to compute the full decomposition, and then
discard all eigenvectors with eigenvalues that are beyond the first few.” Measured, full eigh against
a Lanczos solve for the top :
| size of | full eigh | eigsh, | speed-up | top- eigenvalues agree to |
|---|---|---|---|---|
| ms | ms | |||
| ms | ms |
One run on one machine — the timings move between runs (a repeat gave and ), but the shape does not: a full decomposition is cubic in , and five vectors were asked for.
At the chapter’s own this is already worth having; at the of §10.5’s images it is the difference between feasible and not.
Equation 10.52, and how fast it actually is
Section titled “Equation 10.52, and how fast it actually is”“This sequence of vectors converges to the eigenvector associated with the largest eigenvalue” — and the rate is not stated, but it is per step. On the digit-”8” covariance, where that ratio is :
| angle to , degrees | ratio to the previous step | |
|---|---|---|
| — | ||
The observed ratio climbs to the predicted as the contributions from onwards die out faster and only the component is left. The angle reaches exactly at step .
| steps to reach degrees | |
|---|---|
“The original Google PageRank algorithm uses such an algorithm for ranking web pages based on their hyperlinks.” The same table explains why PageRank’s damping factor exists: it is chosen partly to keep the second eigenvalue away from the first.
-
Why is the SVD of X preferable to the eigendecomposition of S when the small eigenvalues matter?
Measured on a 200-by-200 matrix: at condition number 1e8 the eigendecomposition route already has 6.9 percent worst relative error, and at 1e10 it has 5.3e+03 and returns 18 negative eigenvalues — an impossible answer for a covariance matrix. The SVD route holds 3.2e-07. J_M sums exactly the small end.
pch.quizShowAnswer
B — Forming X X-transpose squares the condition number, so the relative error on small eigenvalues grows like kappa squared instead of kappa — Measured on a 200-by-200 matrix: at condition number 1e8 the eigendecomposition route already has 6.9 percent worst relative error, and at 1e10 it has 5.3e+03 and returns 18 negative eigenvalues — an impossible answer for a covariance matrix. The SVD route holds 3.2e-07. J_M sums exactly the small end.
-
What does the Eckart-Young theorem say the spectral-norm error of the truncated SVD is?
Measured to 7e-14 at M = 1, 2, 5 and 10. In the Frobenius norm the error is the square root of the sum of the squared discarded singular values, which divided by N is exactly page 1004's J_M — 320.294771 squared over 174 is 589.590460. Eckart-Young and Equation 10.44 are one theorem in two notations.
pch.quizShowAnswer
B — Exactly sigma_(M+1), the largest singular value you dropped — Measured to 7e-14 at M = 1, 2, 5 and 10. In the Frobenius norm the error is the square root of the sum of the squared discarded singular values, which divided by N is exactly page 1004's J_M — 320.294771 squared over 174 is 589.590460. Eckart-Young and Equation 10.44 are one theorem in two notations.
-
What does the Abel-Ruffini theorem actually rule out?
It explains why eigenvalue algorithms are iterative rather than a formula. It says nothing about accuracy or difficulty — np.linalg.eigh handles a 64-by-64 matrix in under a millisecond. And nobody computes eigenvalues by rooting the characteristic polynomial anyway; that route is catastrophically ill-conditioned.
pch.quizShowAnswer
B — A closed-form expression in radicals for the roots of a general polynomial of degree five or more — nothing about computing them numerically — It explains why eigenvalue algorithms are iterative rather than a formula. It says nothing about accuracy or difficulty — np.linalg.eigh handles a 64-by-64 matrix in under a millisecond. And nobody computes eigenvalues by rooting the characteristic polynomial anyway; that route is catastrophically ill-conditioned.
-
Power iteration converges at what rate?
On the digit-8 covariance the ratio is 0.578708 and the measured step-to-step ratio reaches 0.578541 by iteration 25, with no fitting. The cost of a near-tie is steep: 1,769 steps at a ratio of 0.99 against 27 at 0.5. That is also why PageRank's damping factor is chosen as it is.
pch.quizShowAnswer
B — Geometrically, at the ratio of the second eigenvalue to the first — On the digit-8 covariance the ratio is 0.578708 and the measured step-to-step ratio reaches 0.578541 by iteration 25, with no fitting. The cost of a near-tie is steep: 1,769 steps at a ratio of 0.99 against 27 at 0.5. That is also why PageRank's damping factor is chosen as it is.
Exercises
Section titled “Exercises”Exercise 1 – One decomposition, two names
Section titled “Exercise 1 – One decomposition, two names”Exercise 2 – What squaring the condition number costs
Section titled “Exercise 2 – What squaring the condition number costs”Exercise 3 – Eckart-Young, and its Frobenius twin
Section titled “Exercise 3 – Eckart-Young, and its Frobenius twin”Exercise 4 – Power iteration, and the rate it converges at
Section titled “Exercise 4 – Power iteration, and the rate it converges at”Exercise 5 – The cost of computing what you throw away
Section titled “Exercise 5 – The cost of computing what you throw away”Recall card
Section titled “Recall card”- Section 10.4 offers two routes to the same basis: the eigendecomposition of S, or the singular value decomposition of X.
- Equation 10.49 connects them: each eigenvalue is the corresponding squared singular value divided by N, measured to 1.4e-13, with eigenvectors agreeing to two millionths of a degree.
- Forming X X-transpose squares the condition number — measured exactly on the digit data, where the ratio of the two condition numbers is itself the condition number.
- That costs relative accuracy at the bottom of the spectrum, which is exactly what Equation 10.44 sums. At condition number 1e8 the eigendecomposition route has 6.9 percent worst relative error; at 1e10 it has 5.3e+03.
- And it returns 18 negative eigenvalues out of 200 for a positive semi-definite matrix, an impossible answer that flows straight into any variance-explained figure.
- The large eigenvalues are fine either way, so if you only want the top few components, either route is safe.
- Eckart-Young says the truncated SVD is the best rank-M approximation, and its spectral-norm error is exactly the next singular value — measured to 7e-14.
- Its Frobenius error squared, divided by N, is page 1004’s reconstruction error. Eckart-Young and Equation 10.44 are one theorem in two notations.
- Abel-Ruffini rules out a closed-form formula in radicals past degree four, and nothing else. Eigenvalues are still computed to full precision, iteratively, and never by rooting the characteristic polynomial.
- Power iteration converges geometrically at the ratio of the second eigenvalue to the first — predicted 0.578708, measured 0.578541 by step 25, with nothing fitted.
- A near-tie at the top is what makes it slow: 1,769 steps at a ratio of 0.99 against 27 at 0.5. That is also why PageRank has a damping factor.
- Asking for only the top five eigenpairs is tens of times faster at D equal to 2000, and agrees to better than 1e-10.
Next: PCA in High Dimensions — §10.5, where and the covariance matrix is the wrong object to decompose entirely.
pch.coffeeTagline
pch.coffeeCtapch.feedbackHeading
pch.feedbackSubheading