# Projection theorem for compact differentiable manifold

By Hilbert projection theorem, if $x\in\mathbb{R}^n$ and $D$ is a closed subset of $\mathbb{R}^n$ then the optimization problem $$\underset{y}{\min} \|x-y\| \ s.t. \ y \in D \quad\quad (P1)$$ has an unique solution, namely, the $\bar{x} \in \mathbb{R}^n$ such that $x-\bar{x}$ is orthogonal to $D$.

Consider now that $D$ is a compact differentiable manifold. Since $f(y):=\|x-y\|$ is a continuous function on the compact $D$, the optimization problem (P1) has a global minimum $\bar{x}$.

It must be the case that $x-\bar{x}$ is normal to the tangent space of $D$ at $\bar{x}$?

-

If $x\notin D$ then yes. To see this consider smooth curves $\gamma(t)\subset D$ passing through $\bar x$ in $t=0$ and look at $$h(t)= f(\gamma(t))^2$$ This function clearly attains it's minimum at $t=0$, so it's derivative is zero at $t=0$.
It's rather easy to see that this derivative is given by $$h^\prime(0) = 2\langle x-\bar x, \gamma^\prime\rangle = 0$$ and since this is true for each such $\gamma$ the scalar product vanishes for each tangent vector to $D$ in $\bar x$.
(Looking at the squared norm just simplifies the computation of the derivative, you could work with $f$, too).