Let $C$ be a closed convex set in $\mathbb{R}^n$. Let $z$ be a point in $\mathbb{R}^n$.
Definition: Euclidean projection of $z$ onto $C$ is defined as $$ \pi_C(z)=\arg\min_{x\in C} \|z-x\|_2 $$
Euclidean projection is not continuously differentiable so we cannot take the derivative of it at an arbitrary point. However, I am told that the following function is not as tricky as Euclidean projection:
$$ f(z) = \|z-\pi_C(z)\|^2 $$ and it is differentiable.
My questions:
1- How would you show $f(z)$ is differentiable?
2- What is the gradient of $f(z)$?