Why is $\langle x-P(x),m\rangle=0$? Let $H$ be a Hilbert space, and let $M\le H$ be a subspace of it.

Let $P:H\rightarrow M$ be the orthogonal projection $H$ onto $M$.

We'll take $x\in H$, and $m \in M$.

By the definition I know $d(x,M)=d(x,P(x))$. (where $d$ is the induced metric).

Is it true that $\langle x-P(x),m\rangle=0$? And why?
It is true. It follows the condition of optimality for optimization problem.

Proof:

Consider  $F(y) = \left&lt;x-y,x-y\right&gt;$. The problem
$$
F(y)\to\min,\ y\in M
$$
has a unique solution, $P(x)$. Since $F$ is a convex function and $M$ is a convex set, then the following holds:
$$
\left&lt;\nabla F(P(x)), v -  P(x)\right&gt; \geqslant 0\text{ for all }v\in M.
$$
Obviously, $\nabla F(y) = 2(y-x)$. Then for any $m\in M$ we can select $v = P(x)+m$ ($v\in M$ because $M$ is subsapce), then
$$
\left&lt;P(x)-x,m \right&gt; \geqslant 0.
$$ 
Selecting now $v = P(x)-m$, we obtain
$$
\left&lt;P(x)-x,m \right&gt; \leqslant 0.
$$
Hence, $\left&lt;P(x)-x,m \right&gt; =0$ for any $m\in M$.
It is true. It follows the condition of optimality for optimization problem.

Proof:

Consider  $F(y) = \left&lt;x-y,x-y\right&gt;$. The problem
$$
F(y)\to\min,\ y\in M
$$
has a unique solution, $P(x)$. Since $F$ is a convex function and $M$ is a convex set, then the following holds:
$$
\left&lt;\nabla F(P(x)), v -  P(x)\right&gt; \geqslant 0\text{ for all }v\in M.
$$
Obviously, $\nabla F(y) = 2(y-x)$. Then for any $m\in M$ we can select $v = P(x)+m$ ($v\in M$ because $M$ is subsapce), then
$$
\left&lt;P(x)-x,m \right&gt; \geqslant 0.
$$ 
Selecting now $v = P(x)-m$, we obtain
$$
\left&lt;P(x)-x,m \right&gt; \leqslant 0.
$$
Hence, $\left&lt;P(x)-x,m \right&gt; =0$ for any $m\in M$.