= Solution
Let $v=\sum_{k=1}^n\langle x,e_k\rangle e_k$, using the convention that the <inner product> is linear in its first argument. Orthonormality gives
$$
\langle x-v,e_j\rangle=\langle x,e_j\rangle-\sum_k\langle x,e_k\rangle\langle e_k,e_j\rangle=0
$$
for every $j$. Hence $x-v$ is orthogonal to $U_n$. For any $u\in U_n$, the Pythagorean identity gives $\|x-u\|^2=\|x-v\|^2+\|v-u\|^2$, so $v$ is the unique best approximation. Therefore
$$
\boxed{P_nx=\sum_{k=1}^n\langle x,e_k\rangle e_k.}
$$
Back to article page