Need help showing this map below is continuous. If $S$ is a closed and convex subset of $\mathbb{R}^n$, then there is a unique nearest point in $S$ for any $x \in \mathbb{R}^n$, i.e., there exists a unique $y' \in S$ such that $\|x-y'\| = \inf_{y \in S} \|x-y\|$.
Then define $f : \mathbb{R}^n \to S$ by $f(x)=$ nearest point to $x$ in $S$. That is, via the equality $ \inf \|x - y\| = \|x - y'\|$, we take $f(x)=y'$.
How do you prove $f$ is continuous?
 A: I'm not sure this is the simplest solution, but this is what I got.
Remember that $\|x-f(x)\| \leq \|x-y\|$ for all $x\in R^n$, $y\in S$.
Consider a convergent sequence $x_n\to x_0$. We want to prove that $f(x_n) \to f(x_0)$. A convergent sequence is bounded, hence: so is $(f(x_n))_n$, because
$$
\|f(x_n)\| \leq \|x_n\| + \|f(x_n) - x_n\| \leq 
 \|x_n\| + \|x_n - f(x_0)\| \leq 2 \max_n \|x_n\| + \|f(x_0)\|.
$$
Then it has an accumulation point, which lies in $S$, as this set is closed:
$$
\exists y\in S \ \exists (n_k): \ f(x_{n_k}) \xrightarrow{k\to\infty} y.
$$
Consider the distance
$$
\|x_{n_k} - f(x_{n_k})\|.
$$
On the one hand, it tends to $\|x_0 - y\|$, as $k\to\infty$. But on the other hand, it can be shown (see at the end) that the function of distance to $S$, ie. $\|x-f(x)\|$, is continuous. So the limit is also equal
$$
\|x_0 - y\| = \lim_{k\to\infty} \|x_{n_k} - f(x_{n_k})\| = \|x_0 - f(x_0)\|.
$$
This means that $y=f(x_0)$, as the nearest point is unique.
We've chosen any accumulation point, so it follows that $(f(x_n))_n$ has no other accumulation points but $f(x_0)$. Does it mean that this is the limit? Yes, because the sequence is bounded! If this wasn't the limit, then there would be a subsequence staying away from $f(x_0)$; however, the subsequence is still bounded, so there is an accumulation point, but we already know that this has to be $f(x_0)$ - contradiction.
Finally, why is $\|x - f(x)\|$ continuous? Let's denote for brevity
$$
d_S(x) \mathrel{:=} \|x-f(x)\|.
$$
This is a real-valued function and continuity can be proved by preimages of open intervals:
$$
d_S^{-1}((a,b)) = d_S^{-1}((a,\infty)) \cap d_S^{-1}((-\infty,b)).
$$
To check that $d_S^{-1}((a,\infty))$ is open, choose some element $x_0$. If $\|x-x_0\| < d_S(x_0) - a$, then $d_S(x) > a$, because otherwise:
$$
d_S(x_0) \leq \|x_0 - f(x)\| \leq \|x_0 - x\| + \|x-f(x)\| < d_S(x_0) - a + a = d_S(x_0).
$$
Thus, $d_S^{-1}((a,\infty))$ is open. It goes similarly for $d_S^{-1}((-\infty,b))$ (even easier).
