Let $f(x) = (1/2) x^2, x \in [-\sqrt{2}, \sqrt{2}]$ and $f(x) = +\infty$ elsewhere
I would like to compute the subgradient of this function at the boundary $\pm\sqrt2$. However, I am not sure how to proceed.
Here is my attempt:
$\partial f(x) = \{g \in \mathbb{R}| (1/2) y^2 \geq (1/2) x^2 + g(y - x), \forall y \in [-\sqrt{2}, \sqrt{2}]\}$
Therefore, $\partial f(\sqrt{2} ) = \{g \in \mathbb{R} | (1/2) y^2 \geq 1 + g(y - \sqrt{2}), \forall y \in [-\sqrt{2}, \sqrt{2}]\}$
Solving for $g$ requires me to solve that quadratic, which looks a bit complicated. So I test some values of $y$.
Let $y = \sqrt{2}$, then $1 \geq 1 + g(\sqrt{2}-\sqrt{2})$ or $g \in [-\infty, \infty]$.
Let $y = -\sqrt{2}$, then $1 \geq 1 + g(-\sqrt{2}-\sqrt{2})$ or $g \geq 0$.
Does this mean that the subgradient of this function at $\sqrt{2}$ is $g \in [0, \infty]$? It does not make sense when looking at the graph.
Update: there was some typos.
The derivative of $f$ from the left at $x=\sqrt{2}$ is just the derivative of $h(x)=x^2/2$ at that point, that is, $f'_-(\sqrt{2})=\sqrt{2}$. The derivative from the right is $+\infty$, given that the function jumps to infinity. Therefore, your subdifferential is the set $\partial f(\sqrt{2})=[\sqrt{2},+\infty)$. Your function is even, so $\partial f(-\sqrt{2})=[-\infty,-\sqrt{2})$.