I want to check if the function $f(x)$ is convex, where
$$ f(x)=\bigl|a|x|-x\bigr|^2.$$
There are several possibilities to check if the function is convex:
- The second derivative: Not possible, because it is only subdifferential.
- Geometry: too complicated for this case.
- Convex inequality: $$f(tx+(1-t)y) \leqslant tf(x) + (1-t)f(y).$$
To 3: How to use the inequality? Can somebody help to put the function into the convex inequality?
first of all you don't need the outer abs |.| because of the square. Hence
$$ f(x)=\vert a\vert x\vert-x\vert^2=(a\vert x\vert -x)^2=a^2\vert x\vert^2-2a\vert x\vert x +x^2 $$ Observe that $\vert x\vert^2=x^2$ for all $x\in \mathbb{R}$. Thus, $$ f(x)=a^2 x^2-2a\vert x\vert x +x^2=(a^2+1)x^2-2a\vert x\vert x $$ Now, we can consider $f$ for $x\geq0$ and $x<0$, i.e. $$ f(x)=\begin{cases} (a^2-2a+1)x^2,&\quad x\geq 0\\ (a^2+2a+1)x^2,&\quad x< 0 \end{cases}=\begin{cases} (a-1)^2x^2,&\quad x\geq 0\\ (a+1)^2x^2,&\quad x< 0 \end{cases} $$ In both cases you have a parabola for $a\in \mathbb{R}\setminus \{-1,+1\}$ which are opened up. Hence $f$ is convex. Otherwise one part of $f$ is 0, the other part a parabola open up. So, $f$ is again convex.