Minimum over a convex set Suppose $Z$ is a closed convex set and $x\not\in Z$. We need to show that there exists $z'\in Z$ such that $||z'-x||\leq||z-x||~~\forall z\in Z$. 
I know that the distance function is continuous hence has a minimum on any compact subset of $Z$ but how do I guarantee that for the convex set?
 A: In general, there is a known result, see Proposition A.8(b) in Bertsekas book, that says that, given a coercive and continuous function $f:\mathbb{R}^{n} \rightarrow \mathbb{R}$, i.e., satisfying $$\lim_{\| {\boldsymbol x\|}\rightarrow \infty } f(\boldsymbol x)  =\infty, $$ for all closed set $Z \subset \mathbb{R}^{n}$, the optimization problem
\begin{equation*}
\begin{array}{c c}
 \text{minimize}_{\boldsymbol x \in \mathbb{R}^n}  &  f(\boldsymbol x)  \\
 \text{subject to } & \boldsymbol x\in Z,
\end{array} 
\end{equation*} have at least a global minimizier $\boldsymbol x^{*} \in Z$. Since, for any $\boldsymbol x$, the function $g_{\boldsymbol x }: \mathbb{R}^{n}\rightarrow \mathbb{R}$ given by $g_{\boldsymbol x }(z)=\|z-x\|$, for all $\boldsymbol z \in \mathbb{R}^{n}$, is coercive, the optimization problem \begin{equation*}
\begin{array}{c c}
 \text{minimize}_{\boldsymbol x \in \mathbb{R}^n}  &  g_{\boldsymbol x }(z)  \\
 \text{subject to } & \boldsymbol z\in Z,
\end{array} 
\end{equation*} must have a solution, by this result, which is your desired result.
It's import to note that it's needed  that $Z$ to be closed and convex, otherwise the problem does not necessarily have a solution. For example, for the open and bounded ball $B(\boldsymbol 0 , 1 ) = \{\boldsymbol x \in \mathbb{R}^{n}: \|\boldsymbol x \| < 1\}$, given an $\boldsymbol z$ with $\|\boldsymbol z\|>1$ your minimum distance is never achieved.
