TITLE: Square of a convex non-negative function is still convex
QUESTION [7 upvotes]: Let $f: \mathbb R \rightarrow \mathbb [0, \infty)$ be a convex function. If $f$ is twice-differentiable, then
$$ (f^2)'' = (2ff')' = 2(f')^2 + 2f f'', $$
which is $\geq 0 $ since $f, f'' \geq 0.$
But how can I prove that $f^2$ is convex without smoothness assumptions?

Recall the definition of convexity: $\forall t \in (0,1), \forall x,y \in \mathbb R,$
$$ f((1-t)x+ty) \leq (1-t) f(x) + t f(y). $$
Squaring both sides I get
$$ f^2((1-t)x+ty) \leq (1-t)^2 f^2(x) + t^2 f^2(y) + 2t(1-t)f(x)f(y).$$
Now, from the fact that $t \in (0,1)$ and the inequality $2t(1-t) \leq t^2 + (1-t)^2 \leq 1 $ I get
$$ f^2((1-t)x+ty) \leq (1-t)f^2(x) + tf^2(y) + f(x)f(y). $$
But that's a $f(x)f(y)$ too much...

REPLY [8 votes]: While the first answer is insightful, I thought the original approach had to work in a simple way. So here it is: 
$$ f((1-t)x+ty) \leq (1-t) \, f(x) + t \, f(y). $$
Squaring both sides 
$$ f^2((1-t)x+ty) \leq (1-t)^2 f^2(x) + t^2 f^2(y) + 2t(1-t)f(x)f(y).$$
Now subtract and add the desired terms on the right side of the inequality:
$$ f^2((1-t)x+ty) \leq (1-t)^2 f^2(x) + t^2 f^2(y) + 2t(1-t)f(x)f(y)\\
\qquad \qquad\qquad \quad   - (1-t)\, f^2(x) - t\, f^2(y)\  + (1-t)\, f^2(x) + t \, f^2(y)$$
Combining the five first terms of the right-hand side one gets
$$ f^2((1-t)x+ty) \leq - t(1-t)\, \bigl(f(x)-f(y)\bigr)^2
   + (1-t) \, f^2(x) + t\,  f^2(y)$$
The first term on the right is manifestly non-positive so we get the desired result:
 $$ f^2((1-t)x+ty) \leq  (1-t)\,  f^2(x) + t\,  f^2(y)\,. $$