TITLE: A counterexample to theorem about orthogonal projection
QUESTION [10 upvotes]: Can someone give me an example of noncomplete inner product space $H$, its closed linear subspace of $H_0$ and element $x\in H$ such that there is no orthogonal projection of $x$ on $H_0$. In other words I need to construct a counterexample to theorem about orthogonal projection when inner product space is not complete.

REPLY [8 votes]: Let $H$ be the inner product space consisting of $\ell^2$-sequences with finite support, let $\lambda = 2^{-1/2}$ and put
$$
z = \sum_{n=1}^\infty \;\lambda^n \,e_n \in \ell^2 \smallsetminus H
$$
Then $\langle z, z \rangle = \sum_{n=1}^\infty \lambda^{2n} = \sum_{n=1}^{\infty} 2^{-n} = 1$.
The subspace $H_0 = \{y \in H\,:\,\langle z, y \rangle = 0\}$ is closed in $H$ because $\langle z, \cdot\rangle: H \to \mathbb{R}$ is continuous.
The projection of $x = e_1$ to $H_0$ should be
$$
y = e_1 - \langle z,e_1\rangle\, z = e_1 - \lambda z = \lambda^2 e_1 -  \sum_{n=2}^\infty \lambda^{n+1}e_n
\in \ell^2 \smallsetminus H_0.
$$
For $k \geq 2$ put
$$
z_k = \sum_{n=2}^k \;\lambda^{n} \,e_n + \lambda^{k+1} \frac{1}{1-\lambda} e_{k+1} \in H_0. 
$$
Then $y_k = \lambda^2 e_1-\lambda z_k \in H_0$ because 
$$
\langle y_k, z\rangle =\lambda^2 - \sum_{n=2}^{k}\,\lambda^{2n+1}-\frac{\lambda^{2k+2}}{1+\lambda} = \lambda^2 - \lambda^2 \sum_{n=1}^\infty \lambda^{2n} = 0.
$$
On the other hand, we have $y_k \to y$ in $\ell^2$, so
$$
\|e_1 - y\| \leq d(e_1,H_0) \leq \lim_{k\to\infty} \|e_1-y_k\| = \|e_1-y\|
$$
and we're done because $y \in \overline{H}_0$ in $\ell^2$ is the only point realizing $d(e_1,\overline{H}_0)$ in $\ell^2$, thus there can be no point in $H_0$ minimizing the distance to $e_1$ because $y \notin H_0$.