2.2 Deriving the Pythagorean Decomposition of Data, Shadow, and Error
In visual diagrams of Principal Component Analysis, we draw a right-angled square where the residual line meets the candidate axis u. But how do we prove algebraically in d-dimensional space (Rd, where we cannot draw pictures) that the residual vector ri=xi−(uTxi)u is strictly perpendicular to the projection vector x^i=(uTxi)u, and that the cross-term vanishes in the squared norm expansion?
1. Algebraic Proof: The Residual Vector Is Orthogonal to the Axis
Let xi∈Rd be any vector and u∈Rd be any unit vector (uTu=1). Define the scalar projection zi=uTxi, the shadow vector x^i=ziu, and the residual error vector ri=xi−ziu.
Two vectors are orthogonal if and only if their dot product is zero. Let us take the dot product of u with ri:
uTri=uT(xi−ziu)=uTxi−zi(uTu)=zi−zi(1)=0
Because uTri=0, the residual ri is also orthogonal to the shadow vector x^i=ziu: x^iTri=zi(uTri)=0. This confirms a 90∘ angle in any dimension d!
2. Expanding the Squared Error Norm via Dot Products
Even if you did not notice the right triangle geometrically, you can derive the Pythagorean decomposition directly by expanding the squared reconstruction error ei2=∥xi−ziu∥2:
Why the −2zi2+zi2 Cancellation Works: The middle cross-term −2zi2 is twice as large as the final quadratic term +zi2 and has the opposite sign. Their sum −2zi2+zi2=−zi2 flips the sign of the projected variance, directly yielding ∥xi∥2=zi2+ei2!
3. Generalizing to a k-Dimensional Principal Subspace
What if we project onto a k-dimensional plane spanned by k mutually orthonormal vectors u1,u2,…,uk (where uaTub=0 for a=b and uaTua=1)? The shadow is x^i=∑a=1k(uaTxi)ua, and the exact same expansion gives:
ei2=∥xi∥2−a=1∑k(uaTxi)2
Each additional orthogonal axis ua simply subtracts its own independent squared projection (uaTxi)2 from the remaining error!
4. Worked 3D Numerical Verification
Let xi=236∈R3 (so ∥xi∥2=4+9+36=49), and let u=2/31/32/3 (unit vector since 94+1+4=1).
Scalar Projection:zi=uTxi=32(2)+1(3)+2(6)=34+3+12=319, so zi2=9361.
Shadow & Residual Vectors:x^i=3192/31/32/3=91381938, and ri=xi−x^i=9118−3827−1954−38=91−20816.
Verify Pythagoras:ei2=∥ri∥2=81(−20)2+82+162=81400+64+256=81720=980. Adding base and error squared: zi2+ei2=9361+980=9441=49=∥xi∥2!
5. Active Recall Check and Key Takeaways
Quick Check: Test Your Understanding
Question: Suppose a point x∈R4 has Euclidean norm ∥x∥=10. Its scalar projections onto two orthogonal unit vectors u1 and u2 are z1=8 and z2=−5. What is its squared reconstruction error e2 when projected onto the 2D plane spanned by u1 and u2?
Answer: Using the multi-axis Pythagorean decomposition, e2=∥x∥2−(z12+z22)=102−(82+(−5)2)=100−(64+25)=100−89=11.
Orthogonality Guarantee:uT(xi−(uTxi)u)=0 holds in any dimension Rd whenever uTu=1.
Cross-Term Collapse: Expanding ∥xi−ziu∥2 yields ∥xi∥2−zi2, turning a vector norm minimization into a scalar projection maximization.