Chapter 2: The Pythagorean Miracle — How Minimizing Reconstruction Error Forces You to Maximize Variance

When textbooks introduce Principal Component Analysis, they present two seemingly unrelated definitions: Karl Pearson's (1901) formulation asks for the subspace that minimizes orthogonal reconstruction error, whereas Harold Hotelling's (1933) formulation asks for the subspace that maximizes the variance of the projected points.

Why does minimizing error automatically maximize variance? The bridge between these two worlds requires no calculus or matrix determinants—only the Pythagorean theorem applied to the right triangle formed by each data point, its shadow on the projection line, and its perpendicular residual.

In this Article

1. The Two Historical Faces of PCA: Pearson (1901) vs. Hotelling (1933)

Suppose you have nn centered observations x1,…,xn∈Rd\mathbf{x}_1, \dots, \mathbf{x}_n \in \mathbb{R}^d and a candidate unit vector u\mathbf{u} (∥u∥=1\|\mathbf{u}\|=1). Consider two goals:

  • Goal A (Compression / Minimal Distortion): Make the perpendicular error vectors ri=xi−(uTxi)u\mathbf{r}_i = \mathbf{x}_i - (\mathbf{u}^T\mathbf{x}_i)\mathbf{u} as short as possible on average:

    min⁡∥u∥=11n∑i=1n∥xi−(uTxi)u∥2\min_{\|\mathbf{u}\|=1} \frac{1}{n}\sum_{i=1}^n \|\mathbf{x}_i - (\mathbf{u}^T\mathbf{x}_i)\mathbf{u}\|^2

  • Goal B (Information Preservation / Maximal Spread): Make the projected 1D scores zi=uTxiz_i = \mathbf{u}^T\mathbf{x}_i as spread out from their zero mean as possible:

    max⁡∥u∥=11n∑i=1n(uTxi)2\max_{\|\mathbf{u}\|=1} \frac{1}{n}\sum_{i=1}^n (\mathbf{u}^T\mathbf{x}_i)^2

2. The Right Triangle Inside Every Orthogonal Projection

For any single point xi\mathbf{x}_i, look at the triangle with vertices at the origin 0\mathbf{0}, the projected shadow x^i=(uTxi)u\hat{\mathbf{x}}_i = (\mathbf{u}^T\mathbf{x}_i)\mathbf{u}, and the original point xi\mathbf{x}_i:

                             * x_i (Data Point)
                            /|
                           / |
     Hypotenuse ||x_i||   /  |  Opposite Side: Error e_i = ||x_i - x_hat_i||
     (FIXED by the data! /   |  (Shrinks as u aligns with the cloud)
      Never changes as  /    |
      we rotate u!)    /   _ |
                      /   | ||  <-- 90-degree Right Angle
            Origin (0)=======(o)---------> Candidate Unit Axis u
                      Base: Shadow Length |z_i| = |u^T x_i|
                      (Grows as u aligns with the cloud)

Because the residual vector ri=xi−x^i\mathbf{r}_i = \mathbf{x}_i - \hat{\mathbf{x}}_i is perpendicular to the axis u\mathbf{u}, the Pythagorean theorem holds for every single point ii:

∥xi∥2⏟Hypotenuse2=(uTxi)2⏟Base (Shadow)2+∥xi−(uTxi)u∥2⏟Height (Error)2\underbrace{\|\mathbf{x}_i\|^2}_{\text{Hypotenuse}^2} = \underbrace{(\mathbf{u}^T\mathbf{x}_i)^2}_{\text{Base (Shadow)}^2} + \underbrace{\|\mathbf{x}_i - (\mathbf{u}^T\mathbf{x}_i)\mathbf{u}\|^2}_{\text{Height (Error)}^2}

3. Summing Over the Dataset: The Conservation Law of Total Scatter

Now average this Pythagorean equation across all nn points in the centered dataset:

The Fundamental Conservation Law of PCA:

1n∑i=1n∥xi∥2⏟Total Data Energy Etotal (CONSTANT as u rotates!)=1n∑i=1n(uTxi)2⏟Projected Variance V(u) (Captured on the line)+1n∑i=1nei2⏟Mean Squared Error MSE(u) (Lost perpendicular to the line)\underbrace{\frac{1}{n}\sum_{i=1}^n \|\mathbf{x}_i\|^2}_{\substack{\text{Total Data Energy } E_{\text{total}} \ \text{(CONSTANT as }\mathbf{u}\text{ rotates!)}}} = \underbrace{\frac{1}{n}\sum_{i=1}^n (\mathbf{u}^T\mathbf{x}_i)^2}_{\substack{\text{Projected Variance } V(\mathbf{u}) \ \text{(Captured on the line)}}} + \underbrace{\frac{1}{n}\sum_{i=1}^n e_i^2}_{\substack{\text{Mean Squared Error } \text{MSE}(\mathbf{u}) \ \text{(Lost perpendicular to the line)}}}

Look at the left-hand side: Etotal=1n∑i=1n∥xi∥2E_{\text{total}} = \frac{1}{n}\sum_{i=1}^n \|\mathbf{x}_i\|^2 does not contain u\mathbf{u} at all! As you spin the line u\mathbf{u} around the origin, the data points stay frozen in space, so their distances from the origin never change.

Because V(u)+MSE(u)=Etotal=constantV(\mathbf{u}) + \text{MSE}(\mathbf{u}) = E_{\text{total}} = \text{constant}, we can write:

MSE(u)=Etotal−V(u)\text{MSE}(\mathbf{u}) = E_{\text{total}} - V(\mathbf{u})

Minimizing MSE(u)\text{MSE}(\mathbf{u}) is therefore algebraically identical to maximizing V(u)V(\mathbf{u})! Making the perpendicular errors as small as possible forces the projected shadows on the line to spread out as widely as possible.

4. Step-by-Step Numerical Proof Across Multiple Angles

Take our 4-point centered dataset from Chapter 1: x1=[21],x2=[12],x3=[−1−2],x4=[−2−1]\mathbf{x}_1 = \begin{bmatrix} 2 \\ 1 \end{bmatrix}, \mathbf{x}_2 = \begin{bmatrix} 1 \\ 2 \end{bmatrix}, \mathbf{x}_3 = \begin{bmatrix} -1 \\ -2 \end{bmatrix}, \mathbf{x}_4 = \begin{bmatrix} -2 \\ -1 \end{bmatrix}. Each point has ∥xi∥2=22+12=5\|\mathbf{x}_i\|^2 = 2^2 + 1^2 = 5, so Etotal=5.0E_{\text{total}} = 5.0.

Candidate Axis AngleUnit Vector u\mathbf{u}Projected Variance V(u)V(\mathbf{u})Reconstruction Error MSE(u)\text{MSE}(\mathbf{u})Sum V(u)+MSE(u)V(\mathbf{u}) + \text{MSE}(\mathbf{u})
0∘0^\circ (Horizontal x1x_1)[10]T\begin{bmatrix} 1 & 0 \end{bmatrix}^T4+1+1+44=2.50\frac{4+1+1+4}{4} = 2.501+4+4+14=2.50\frac{1+4+4+1}{4} = 2.502.50+2.50=5.002.50 + 2.50 = 5.00
45∘45^\circ (Optimal PC1)[1/21/2]T\begin{bmatrix} 1/\sqrt{2} & 1/\sqrt{2} \end{bmatrix}^T4.5+4.5+4.5+4.54=4.50\frac{4.5+4.5+4.5+4.5}{4} = 4.500.5+0.5+0.5+0.54=0.50\frac{0.5+0.5+0.5+0.5}{4} = 0.504.50+0.50=5.004.50 + 0.50 = 5.00
−45∘-45^\circ (Worst Axis PC2)[−1/21/2]T\begin{bmatrix} -1/\sqrt{2} & 1/\sqrt{2} \end{bmatrix}^T0.5+0.5+0.5+0.54=0.50\frac{0.5+0.5+0.5+0.5}{4} = 0.504.5+4.5+4.5+4.54=4.50\frac{4.5+4.5+4.5+4.5}{4} = 4.500.50+4.50=5.000.50 + 4.50 = 5.00

5. The Rotating Flashlight Analogy and Its Limits

Imagine holding a rigid wooden rod of length L=5L = 5 feet hinged at the origin in a dark room. If you shine a light straight down onto the floor, the shadow on the floor has length Lcos⁡θL\cos\theta and the vertical height off the floor is Lsin⁡θL\sin\theta. Tilting the rod closer to the floor lengthens the shadow while shrinking the height, yet (shadow)2+(height)2(\text{shadow})^2 + (\text{height})^2 is forever locked at L2=25L^2 = 25.

Where the analogy breaks down: In PCA, the data points themselves do not tilt; the projection screen u\mathbf{u} rotates around a fixed constellation of nn points simultaneously, so the identity holds as an ensemble average across all nn right triangles at once.

6. Critical Misconceptions and Edge Cases

Common Misconception — "Variance = Mean Squared Shadow Only Works If Data Is Centered": Recall that the sample variance of numbers z1,…,znz_1, \dots, z_n is 1n∑(zi−zˉ)2\frac{1}{n}\sum (z_i - \bar{z})^2. Why did we write V(u)=1n∑zi2V(\mathbf{u}) = \frac{1}{n}\sum z_i^2 without subtracting zˉ\bar{z}? Because the data is centered (1n∑xi=0\frac{1}{n}\sum \mathbf{x}_i = \mathbf{0}), which guarantees that the mean of the projections is zero for every direction u\mathbf{u}: zˉ=uT(1n∑xi)=uT0=0\bar{z} = \mathbf{u}^T\left(\frac{1}{n}\sum \mathbf{x}_i\right) = \mathbf{u}^T\mathbf{0} = 0!

7. Active Recall Check and Key Takeaways

Quick Check: Test Your Understanding

Question: A centered 3D dataset has feature variances Var(x1)=10\text{Var}(x_1) = 10, Var(x2)=6\text{Var}(x_2) = 6, and Var(x3)=4\text{Var}(x_3) = 4. If the first principal component PC1 captures a projected variance of λ1=15\lambda_1 = 15, what is the exact mean squared reconstruction error when compressing the 3D points onto the 1D line PC1?

Answer: First, the total data energy is the sum of the feature variances: Etotal=10+6+4=20E_{\text{total}} = 10 + 6 + 4 = 20. By the Pythagorean conservation law, MSE(u1)=Etotal−V(u1)=20−15=5\text{MSE}(\mathbf{u}_1) = E_{\text{total}} - V(\mathbf{u}_1) = 20 - 15 = 5. No individual point residuals need to be computed!

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
pca
pythagorean-theorem
variance-maximization
reconstruction-error
linear-algebra
optimization