Convex function parameter I need to find the parameter $a$ such that $$f(x)= x^2-a|3x-1|+4$$ is convex on $[0,1]$. I saw that the function is continuous on $\mathbb{R}$ and then I calculated the first derivate and put the condition that the derivative should also be continuous so that the second one exists. From this condition I find that $a$ should be  $0$ but in the book the answer is $(-\infty,0]$
 A: $1)$ for $x\in(0,1/3)$ then
$$f(x)= x^2+a(3x-1)+4\to f'(x)=2x+3a$$
$2)$ for $x\in(1/3,1)$ then
$$f(x)= x^2-a(3x-1)+4\to f'(x)=2x-3a$$
the intersection beetween $(1)$ and $(2)$ happens at $x_i=1/3$
look that
$$\lim_{x\to 1/3^{-}} f'(x)=\frac{2}{3}+3a$$
$$\lim_{x\to 1/3^{+}} f'(x)=\frac{2}{3}-3a$$
one condition for guarentee convexity is $f'(x)$ increasing around the intersection $1/3$, not necessarily continuous. Here we are taking advantage that $f$ is a quadratic function, per parts.
So,
$$\lim_{x\to 1/3^{-}} f'(x)\le \lim_{x\to 1/3^{+}} f'(x)$$
$$\frac{2}{3}+3a\le \frac{2}{3}-3a\to a\le 0$$
A: When $a=0$, the function can be written as $f(x) = x^2 + 4$ is a straightforward convex parabola. This is the result you correctly found, but there is more.
Given the absolute value, you can write the function as
$$f(x) = \left\{ \begin{array}{ll}
x^2 - 3ax + a + 4 & \mbox{if } x \ge 1/3 \\
x^2 + 3ax - a + 4 & \mbox{if } x < 1/3 \\
\end{array}
\right.$$
Therefore, if $a \ne 0$, the function has a kink at $x=1/3$. 
Note that $f^\prime (x) = 2x \pm 3a$ is everywhere increasing for $x\ne 1/3$. Moreover, the left-hand and right-hand derivative at $x=1/3$ are, respectively,  $f^\prime_-(1/3) = 2/3 + a$ and $f^\prime_+(1/3) = 2/3 - a$. Then convexity follows if $f^\prime_-(1/3) \le f^\prime_+(1/3)$ or $2/3 + a \le 2/3 - a$ from which you get $a \le 0$.
