We define the function $f:\mathbb R \rightarrow \mathbb R$ as the following: $$f\left(x\right)=\max\left(x^2,|x|\right)$$ Find the subdifferential $\partial f\left(x\right)$ for all $x\in \mathbb R$.
If we let $S$ be a subset of $\mathbb R^n$. A vector $\xi\in\mathbb R^n$ is called a subgradient for the function $f:S\rightarrow\mathbb R$ at $x_0\in S$ if $$f\left(x\right)\geq f\left(x_0\right)+\xi^t\left(x-x_0\right)$$ for every $x\in S$. The set of all subgradients of $f$ at $x_0$ is called the subdifferential.
I know that the derivitive doesn't exist at $x_1=-1$, $x_2=0$ and $x_3=1$.
By knowing this we would be able to solve the problem.
For $x_2=0$, we have that: $$|x| \geq |0|+\xi\left(x-0\right)\Leftrightarrow \xi\in \left[-1, 1\right]$$
For $x_1=-1$: $$x^2 \geq \left(-1\right)^2+2x\left(x-\left(-1\right)\right)$$ $$x^2 \geq 1+2x^2+2x$$ $$0 \geq 1+x^2+2x$$ $$0 \geq \left(1+x\right)^2$$ Since $u^n \leq 0$, if $n$ is even, then $u=0$, which gives us the following: $$0 = 1+x \Leftrightarrow x=-1$$ Which is the same for $x_3=1$, so we get that $x=1$. So the subdifferential is given as: $$\xi=\begin{cases} -1, & x = -1 \\ \left[-1,1\right], & x=0 \\ 1, & x=1 \end{cases} $$ I am not sure if this is the right way of doing it. I will appreciate it if I can get some help.
Thanks in advance