Chapter 5: The Grand Unification — How Variance Maximization Births the Eigenvalue Equation

We have arrived at the intellectual climax of the course. In Chapters 1 and 2, we started with a purely practical goal—compressing data with the smallest possible orthogonal reconstruction error—and proved via the Pythagorean theorem that it is equivalent to maximizing projected variance uTCu\mathbf{u}^T C \mathbf{u} over all unit vectors uTu=1\mathbf{u}^T \mathbf{u} = 1. In Chapters 3 and 4, we explored eigenvectors Cu=λuC\mathbf{u} = \lambda\mathbf{u} as axes of pure geometric stretch.

Now we ask the question that unites both paths: Why does maximizing variance uTCu\mathbf{u}^T C \mathbf{u} subject to uTu=1\mathbf{u}^T \mathbf{u} = 1 produce the exact eigenvalue equation Cu=λuC\mathbf{u} = \lambda\mathbf{u}? Even more remarkably, why does the Lagrange multiplier λ\lambda introduced solely to enforce the unit-length constraint turn out to equal the exact variance along u\mathbf{u}?

In this Article

1. Formulating the Constrained Optimization Problem

Why can we not simply maximize f(u)=uTCuf(\mathbf{u}) = \mathbf{u}^T C \mathbf{u} without constraints? Because uTCu\mathbf{u}^T C \mathbf{u} is quadratic in the length of u\mathbf{u}: if you replace u\mathbf{u} with 10u10\mathbf{u}, the value of (10u)TC(10u)=100(uTCu)(10\mathbf{u})^T C (10\mathbf{u}) = 100(\mathbf{u}^T C \mathbf{u}) explodes by 100×100\times without rotating the line at all! To optimize direction rather than vector length, we must lock u\mathbf{u} onto the unit hypersphere g(u)=uTu=1g(\mathbf{u}) = \mathbf{u}^T \mathbf{u} = 1:

max⁡u∈Rd  uTCusubject touTu=1\max_{\mathbf{u} \in \mathbb{R}^d} \; \mathbf{u}^T C \mathbf{u} \quad \text{subject to} \quad \mathbf{u}^T \mathbf{u} = 1

2. Geometric Proof: Kissing Contours and Parallel Gradients

Imagine walking around the unit circle g(u)=uTu=1g(\mathbf{u}) = \mathbf{u}^T \mathbf{u} = 1 while reading the height of the variance function f(u)=uTCuf(\mathbf{u}) = \mathbf{u}^T C \mathbf{u}. If the level curve of f(u)f(\mathbf{u}) crosses the unit circle at an angle, you can slide along the circle in the uphill direction to reach a higher variance.

                     u2 ^
                        |        . - ~ ~ - .   <-- Variance contour u^T C u = lambda_1
                        |    . '      *      ' .
                   +----+--'---------/(*)-------'--+
                  /     |/          /   \           \   Grad f = 2 C u  and  Grad g = 2 u
                 |      0          0     \           |  point in the EXACT SAME direction!
                  \    /|                 \         /   Therefore: C u = lambda u !
                   +--/-+------------------+-------+
                        |    Unit Circle u^T u = 1

At the exact point of maximum variance, the elliptical contour of f(u)=uTCuf(\mathbf{u}) = \mathbf{u}^T C \mathbf{u} must kiss (be tangent to) the unit circle g(u)=uTu=1g(\mathbf{u}) = \mathbf{u}^T \mathbf{u} = 1. Because two tangent curves share the same normal line, their gradient vectors must be parallel:

∇f(u)=λ∇g(u)  ⟹  2Cu=λ(2u)  ⟹  Cu=λu\nabla f(\mathbf{u}) = \lambda \nabla g(\mathbf{u}) \implies 2 C \mathbf{u} = \lambda (2 \mathbf{u}) \implies C\mathbf{u} = \lambda\mathbf{u}

3. Calculus Proof: Differentiating the Lagrangian L(u, λ)

To write this algebraically, we form the Lagrangian function L(u,λ)\mathcal{L}(\mathbf{u}, \lambda) by subtracting λ(uTu−1)\lambda(\mathbf{u}^T\mathbf{u} - 1) from our objective:

L(u,λ)=uTCu−λ(uTu−1)\mathcal{L}(\mathbf{u}, \lambda) = \mathbf{u}^T C \mathbf{u} - \lambda(\mathbf{u}^T \mathbf{u} - 1)

Using the matrix calculus identities ∇u(uTCu)=2Cu\nabla_{\mathbf{u}}(\mathbf{u}^T C \mathbf{u}) = 2C\mathbf{u} (for symmetric CC) and ∇u(uTu)=2u\nabla_{\mathbf{u}}(\mathbf{u}^T \mathbf{u}) = 2\mathbf{u}, we set the gradient with respect to u\mathbf{u} to zero:

∇uL=2Cu−2λu=0  ⟺  Cu=λu\nabla_{\mathbf{u}} \mathcal{L} = 2C\mathbf{u} - 2\lambda\mathbf{u} = \mathbf{0} \iff C\mathbf{u} = \lambda\mathbf{u}

Every stationary point of directional variance on the unit sphere is an eigenvector of the covariance matrix CC!

4. The Payoff: Proving uᵀCu = λ and Ranking Principal Components

A symmetric d×dd \times d matrix CC has dd orthonormal eigenvectors u1,…,ud\mathbf{u}_1, \dots, \mathbf{u}_d with eigenvalues λ1≥λ2≥⋯≥λd≥0\lambda_1 \ge \lambda_2 \ge \dots \ge \lambda_d \ge 0. Which eigenvector maximizes uTCu\mathbf{u}^T C \mathbf{u}? Left-multiply Cu=λuC\mathbf{u} = \lambda\mathbf{u} by uT\mathbf{u}^T and use uTu=1\mathbf{u}^T\mathbf{u} = 1:

σu2=uTCu=uT(λu)=λ(uTu)=λ(1)=λ\sigma_{\mathbf{u}}^2 = \mathbf{u}^T C \mathbf{u} = \mathbf{u}^T (\lambda \mathbf{u}) = \lambda (\mathbf{u}^T \mathbf{u}) = \lambda(1) = \lambda

The eigenvalue λ\lambda IS the projected variance! Therefore:

  • The eigenvector u1\mathbf{u}_1 with the largest eigenvalue λ1\lambda_1 is the global maximum of variance (and global minimum of orthogonal reconstruction error)—this is Principal Component 1 (PC1).
  • The eigenvector ud\mathbf{u}_d with the smallest eigenvalue λd\lambda_d is the direction of minimum variance.

5. Deflation: Why the 2nd Principal Component Is the 2nd Eigenvector

To find the second principal component u2\mathbf{u}_2, we maximize uTCu\mathbf{u}^T C \mathbf{u} subject to both uTu=1\mathbf{u}^T\mathbf{u} = 1 and orthogonality to the first component, uTu1=0\mathbf{u}^T \mathbf{u}_1 = 0. Forming the two-constraint Lagrangian L=uTCu−λ(uTu−1)−μ(uTu1)\mathcal{L} = \mathbf{u}^T C \mathbf{u} - \lambda(\mathbf{u}^T\mathbf{u} - 1) - \mu(\mathbf{u}^T \mathbf{u}_1) and differentiating yields 2Cu−2λu−μu1=02C\mathbf{u} - 2\lambda\mathbf{u} - \mu\mathbf{u}_1 = \mathbf{0}. Taking the dot product with u1\mathbf{u}_1 shows μ=0\mu = 0, leaving Cu=λuC\mathbf{u} = \lambda\mathbf{u} among directions orthogonal to u1\mathbf{u}_1—whose best solution is (λ2,u2)(\lambda_2, \mathbf{u}_2)!

6. Complete Worked Numerical Example

Suppose a centered 2D dataset has total scatter 1n∑i=1n∥xi∥2=8\frac{1}{n}\sum_{i=1}^n \|\mathbf{x}_i\|^2 = 8 and covariance matrix C=[5223]C = \begin{bmatrix} 5 & 2 \\ 2 & 3 \end{bmatrix}.

  1. Solve det⁡(C−λI)=0\det(C - \lambda I) = 0: λ2−8λ+(15−4)=λ2−8λ+11=0\lambda^2 - 8\lambda + (15 - 4) = \lambda^2 - 8\lambda + 11 = 0, giving λ1=4+5≈6.236\lambda_1 = 4 + \sqrt{5} \approx 6.236 and λ2=4−5≈1.764\lambda_2 = 4 - \sqrt{5} \approx 1.764.
  2. Maximum Variance & Minimum Error along PC1 (u1\mathbf{u}_1):
    • Projected variance along u1\mathbf{u}_1: σu12=λ1≈6.236\sigma_{\mathbf{u}_1}^2 = \lambda_1 \approx 6.236.
    • Mean squared reconstruction error when compressing to PC1 (by Chapter 2 Pythagorean theorem): J(u1)=tr(C)−λ1=8−6.236=λ2≈1.764J(\mathbf{u}_1) = \text{tr}(C) - \lambda_1 = 8 - 6.236 = \lambda_2 \approx 1.764!

Notice that remarkable duality: when you keep the top kk principal components, the captured variance is ∑j=1kλj\sum_{j=1}^k \lambda_j and the discarded reconstruction error is the sum of the discarded eigenvalues ∑j=k+1dλj\sum_{j=k+1}^d \lambda_j!

7. Active Recall Check and Key Takeaways

Quick Check: Test Your Understanding

Question: A 4D dataset has covariance eigenvalues λ1=12,λ2=5,λ3=2,λ4=1\lambda_1 = 12, \lambda_2 = 5, \lambda_3 = 2, \lambda_4 = 1. If we project the dataset onto the 2D plane spanned by PC1 and PC2, what is the captured variance and what is the mean squared orthogonal reconstruction error?

Answer: The captured variance is λ1+λ2=12+5=17\lambda_1 + \lambda_2 = 12 + 5 = 17, and by the Pythagorean theorem the mean squared orthogonal reconstruction error is the sum of the discarded eigenvalues: λ3+λ4=2+1=3\lambda_3 + \lambda_4 = 2 + 1 = 3.

Take a Quiz Based on This Article

Test your understanding with AI-generated questions tailored to this content

Adaptive Learning with SynLearn

Explore this article through guided practice that adapts to your answers

✓Step-by-step concepts & lessons
✓Active recall & adaptive feedback
✓Personalized spaced repetition
lagrange-multipliers
constrained-optimization
eigenvalues
eigenvectors
pca
rayleigh-quotient