Solution (source code)

= Solution

Write $r=x-u^*$. If $u^*$ is a <best approximation> in the finite-dimensional <linear subspace>, then for every $v$ in it and every real $t$,
$$
0\le\|r-tv\|^2-\|r\|^2=-2t\operatorname{Re}(r,v)+t^2\|v\|^2.
$$
A nonzero real linear <coefficient> would make this negative for sufficiently small $t$ of the appropriate sign. Hence $\operatorname{Re}(r,v)=0$. In a complex <inner product space>, apply the argument to $iv$ too; the imaginary part also vanishes. Thus $(x-u^*,v)=0$ for every $v$ in the subspace.

Conversely, if that orthogonality holds, every other candidate has the form $u^*+v$, and the <Pythagorean theorem> in the <inner product> norm gives
$$
\|x-u^*-v\|^2=\|x-u^*\|^2+\|v\|^2\ge\|x-u^*\|^2.
$$
Equality requires $v=0$. Therefore
$$
\boxed{u^*\text{ is the unique best approximant}\ \Longleftrightarrow\ x-u^*\perp\mathcal U_n.}
$$
The next part constructs this <orthogonal projection> explicitly. No completeness of the whole <inner product space> is required for projection onto a finite-dimensional subspace.