A vector $v \in \mathbb{R}^n$ is a subgradient of a convex function at $x$ if $$f(y) \geq f(x) + <v, y - x>$$ for all $y \in dom(f).$
The set of all sub gradients is known as the sub differential denoted by $\partial f (x)$
Here is the example which I am stuck with
Let $f(x) = max \{0, (x^2 - 1)/2 \}$, then $\partial f(1) = [0,1]$ and $\partial f(-1) = [-1, 0]$
I am aware that the functions inside the max function is convex, so there is better way to do this. But the method I am using, from first principles, is not leading me to the right answer.
Note
$$f(y) = \max \{ 0, (y^2 - 1)/2 \} \geq f(1) + v(y - 1) = 0 + v(y - 1)$$
Case I. Letting $0 > (y^2 - 1)/2 \iff y \in (-1, 1)$.
Case II. Letting $0 < (y^2 - 1)/2 \iff y \in (-\infty,-1) \cup (1, \infty)$
Employing case I yields the inequality
$$0 \geq v(y - 1)$$. As $y \in (-1,1)$, RHS is true for every $v \in [0, \infty)$.
Employing case II yields the inequality
$$(y^2 - 1)/2\geq v(y - 1) \implies y + 1 \geq 2v$$. As $y \in (-\infty,-1) \cup (1, \infty)$, There appears to be no unique answer for $v$ depending on the value of $y$. But we may actually throw out this case since $y \notin dom(f)$.
There's a slight error when you conclude that $y + 1 \geq 2v$ for all $y \in (-\infty,-1) \cup (1,\infty)$. That inequality is only valid for $y \in (1,\infty)$.
If $y \in (\infty, -1)$, then $y -1$ is negative. So when you divide through by $y-1$, you have divided by a negative number, and the direction of the inequality must change.
Being careful about this point, we conclude that \begin{equation} y + 1 \geq 2v \quad \text{for all } y \in (1,\infty) \tag{1} \end{equation} and \begin{equation} y + 1 \leq 2v \quad \text{for all } y \in (-\infty,-1). \tag{2} \end{equation} Condition (1) is equivalent to $v \leq 1$, and condition (2) is equivalent to $v \geq 0$. So (1) and (2) are satisfied when $v \in [0,1]$.
For this problem, the answer can be obtained easily just by visualizing the graph of $f$, as in this graph.