We want to find a low-dimensional affine set into which we can project some high-dimensional data.
For $a \in \R ^n$ and $U \in \R ^{n \times k}$, the set $W(a, U) = \Set{a + Uz}{z \in \R ^n}$ is an affine set. Denote the projection of $x \in \R ^n$ onto $W(a, U)$ by $\proj_{W(a, U)}(x)$.
\begin{problem}
Given $x^{(1)}, \dots , x^{(m)} \in \R ^n$, and
a dimension $k$, find $a \in \R ^n$ and $U \in
\R ^{n \times k}$ with $U^\top U = I$ to
minimize
\[
\textstyle
\sum_{i = 1}^{m} \norm{x^{(i)} - \proj_{W(a, U)}(x^{(i)})}^2,
\]
Express $\proj_{W(a, U)}(x)$ as $UU^\top x + (I
- UU^\top )a$ (see
\sheetref{projections_on_affine_sets}{Projections on
Affine Sets}).
We want to find $a \in \R ^n$ and $U \in
\R ^{n \times k}$ to minimize
\[
\sum_{i = 1}^{n} \norm{x^{(i)} - UU^\top x^{(i)} -
(I-UU^\top )a}^2.
\] \[
\scriptsize
A = \bmat{
I - UU^\top \\
\vdots \\
I - UU^\top \\
},\text{ } B = \bmat{
I - UU^\top & \cdots & 0\\
& \ddots & \\
0 & \cdots & I - UU^\top \\
}, \text{ and }
\tilde{x} = \bmat{
x^{(1)} \\
\vdots \\
x^{(m)}
}.
\] \[
\norm{Aa - B \tilde{x}}^2
\] \[
A^\top Aa^\star = A^\top B\tilde{x}
\] \[
\textstyle
A^\top A = \sum_{i = 1}^{m} I - UU^\top = m(I - UU^\top )
\] \[
\textstyle
A^\top B = \bmat{I - UU^\top & \cdots & I - UU^\top }.
\] \[
\textstyle
m(I - UU^\top )a^\star = \sum_{i = 1}^{m} (I -
UU^\top )x^{(i)}.
\] \[
\textstyle
(I - UU^\top )a^\star = (I- UU^\top )(1/m)\sum_{i = 1}^{m} (I
- UU^\top )x^{(i)}.
\]
Now we want to find $U \in \R ^{n \times k}$
to minimize
\[
\textstyle
\sum_{i = 1}^{m} \norm{(I-UU^\top )(x^{(i)} - \bar{x})}^2.
\] \[
\textstyle
\begin{aligned}
\norm{(I - UU^\top )(x^{(i)} - \bar{x})}^2 & = (x-\bar{x})(I -
UU^\top )^\top (I - UU^\top )(x^{(i)} - \bar{x}) \\
& = (x^{(i)} - \bar{x})^\top (I - UU^\top )(x ^{(i)} -
\bar{x}) \\
& = \norm{x^{(i)} - \bar{x}}^2 - \norm{U^\top (x^{(i)} -
\bar{x})}^2.
\end{aligned}
\] \[
\bar{X} = \bmat{x^{(1)} - \bar{x} & \cdots & x^{(m)} -
\bar{x}}.
\] \[
\norm{U^\top \bar{X}}_F = \tr \bar{X}^\top UU^\top \bar{X} =
\tr(U^\top \bar{X}\bar{X}^\top U).
\] \[
\tr(U^\top \bar{X}\bar{X}^\top U).
\]