Is this function (hinge loss times squared error) convex?

1k Views Asked by At

I am wondering if function of this form is convex: $h(x)=\max(1,1-ax)(x-a)^2$. Basically, if $x$ has the same sign as $a$, it is regular quadratic function, otherwise it is of 3rd order. I plotted for both $a>0$ and $a<0$, it seems convex by eyeball. Would you help me confirm that this function is indeed convex and global minimum is guaranteed? Thanks a lot!

1

There are 1 best solutions below

2
On

Since $(x-a)^2 \geq 0$ you can rewrite $h$ to $h(x) = \max\{(x-a)^2, (1-ax)(x-a)^2\}$. Since the second function is only larger than the first one if $ax \leq 0$, you can replace its value for $ax\geq 0$ without changing $h$. Define

$$g(x) = \begin{cases}(1-ax)(x-a)^2 & \text{if } ax \leq 0 \\ a^2 - (a^3+2a)x & \text{else.} \end{cases}$$ Since the first branch is convex, and the second branch is just the tangent of the first branch at $x=0$, the function $g$ is convex. Now $h(x) = \max\{(x-a)^2, g(x)\}$, i.e., the maximum of two convex functions, and therefore convex.