Can we infer that $\text{Im}(P)=S$ if $\Vert P(x)-x\Vert =\min\big\{\Vert y-x\Vert :y\in S\big\}$ for all $x\in H$? [closed]

Let $(H,\langle \cdot ,\cdot \rangle )$ be a Hilbert space over $\mathbb{C}$ and $S\subseteq H$ a closed subspace. Suppose that $P:H\to H$ is a self-adjoint linear transformation satisfying $P^2=P$.

My question is: can we infer that $\text{Im}(P)=S$ if $\Vert P(x)-x\Vert =\color{red}{\min}\big\{\Vert y-x\Vert :y\in S\big\}$ for all $x\in H$?

Unfortunately I wasn't able to prove it or find a counterexample.

Thank you for your attention!


The closest point to a closed subspace defines a self adjoint projection $N$, so we have $\|Px-x\| = \|Nx-x\|$ for all $x$. In particular $Px=x$ iff $Nx=x$.

Hence if $x \in S$ we have $Nx=x$ and so $Px=x$ and so $x \in {\cal R} P$.

If $x \in {\cal R}P$ then $Px = x$ and so $Nx=x$ and so $x \in S$.