I have to show that the function $f : \mathbb{R} \rightarrow \mathbb{R}$ defined by $f(x) = \max(x^2, |x|)$ is convex but I am not sure how to. I guess that the function can be written as
$$ f(x) = \begin{cases} x^2 & \ \text{if} \ -\infty < x < 0 \ \text{or} \ 1 < x \\ x & \ \text{if} \ 0 \leq x \leq 1 \\ \end{cases} $$
but I am then not sure how to show the definition that for $\lambda \in [0,1]$ and for $x,y \in \mathbb{R}$ that $f$ is convex if $$ f(\lambda x + (1 -\lambda)y) \leq \lambda f(x) + (1 - \lambda) f(y) $$
Do I have to seperate the two cases?
Thanks.