How do you show that the directions of maximum variance also minimise the squared reconstruction error of PCA? How do you derive the error for k components in terms of the eigenvalues of the covariance matrix?

Unsupervised learning, Principal component analysis
Level L3 Intermediate. Length Long. Nature Mat Mathematical.

What's being asked

Whether you can link the two views of PCA through the Pythagoras identity.

Key idea

For an orthonormal U∈Rd×k, ∥x−UU⊤x∥2=∥x∥2−∥U⊤x∥2, so minimising the average error is the same as maximising tr⁡(U⊤SU), where S is the covariance of the centred data.

Steps

  1. Centre the data and write S=1n∑ixixi⊤. We reconstruct x as x^=UU⊤x where the columns of U are orthonormal; z=U⊤x is the best code for a fixed U (least squares).
  2. By Pythagoras, x=UU⊤x+(I−UU⊤)x and the two parts are orthogonal. So ∥x−x^∥2=∥x∥2−∥U⊤x∥2.
  3. Average over the data: E(U)=1n∑i∥xi−x^i∥2=tr⁡(S)−tr⁡(U⊤SU). The first term does not depend on U.
  4. Hence minimising E means maximising tr⁡(U⊤SU), which is the total variance captured by the k directions. This is the maximum variance view.
  5. The maximiser is the top k eigenvectors of S. Sketch: write S=∑jλjvjvj⊤, so tr⁡(U⊤SU)=∑jλjpj with pj=∥U⊤vj∥2∈[0,1] and ∑jpj=k; this is largest when p1=⋯=pk=1 (the Ky Fan theorem). Then tr⁡(U⊤SU)=λ1+⋯+λk.
  6. So the minimum error is Emin⁡=tr⁡(S)−∑j≤kλj=∑j>kλj: the sum of the discarded eigenvalues.
  7. Sanity check: for k=d the error is 0, and for k=0 it is the total variance tr⁡(S).

Common mistakes

How long your answer should be

Half a page; 5–6 minutes.

Last checked on 4 December 2026.

Read this

Previous in Unsupervised learning: Three points have pairwise distances d12=3, d23=4 and d13=7. Use classical multidimensional scaling (MDS) with double centring to find the matrix B and the 1-D embedding. Why is one dimension enough?
Next in Unsupervised learning: Factor analysis models x=μ+Wz+ϵ, with z∼N(0,Iq) and noise ϵ∼N(0,Ψ) where Ψ is diagonal. (a) What covariance does this imply for x? (b) For d=6 observed variables and q=2 factors, how many free parameters does it use compared with a full covariance, taking the rotation ambiguity into account? (c) How does it differ from PCA?