Weakly convex functions are convex

Let us consider a continuous function $f \colon \mathbb{R} \to \mathbb{R}$. Let us call $f$ weakly convex if
$$
\int_{-\infty}^{+\infty}f(x)[\varphi(x+h)+\varphi(x-h)-2\varphi(x)]dx\geq 0 \tag{1}
$$
for all $h \in \mathbb{R}$ and all $\varphi \in C_0^\infty(\mathbb{R})$ with $\varphi \geq 0$.
I was told that $f$ is weakly convex if, and only if, $f$ is convex; although I can imagine that (1) is essentially the statement $f” \geq 0$ in a weak sense, I cannot find a complete proof.
Is this well-known? Is there any reference?

Solutions Collecting From Web of "Weakly convex functions are convex"

If you take a family of symmetric mollifiers $\rho_\sigma$ compactly supported in $B_\sigma(0)$, and let $f_\sigma = \rho_\sigma \ast f$ denote the convolution of $f$ with $\rho_\sigma$, then for any $\varphi\in C_c^\infty(\mathbb R)$ you have that $\int f_\sigma \varphi = \int f \varphi_\sigma$. In particular
$$\int f_\sigma(x) [\varphi(x+h)+ \varphi(x-h) – 2\varphi(x) ]= \int f(x) [\varphi_\sigma(x+h)+ \varphi_\sigma(x-h) – 2\varphi_\sigma(x) ] \ge 0$$
for $\varphi \ge 0$.
Hence after substitution and multiplication by $h^{-2}$ for $h\ne 0$, we get
$$\int \frac{f_\sigma(x+h)+f_\sigma(x-h) – 2f_\sigma(x) }{h^2} \varphi(x) \ge 0$$
Letting $h\to 0$, it follows from this that $f_\sigma” \ge 0$. So $f_\sigma$ is convex for all $\sigma > 0$. On the other hand, since $f$ is continuous, $f_\sigma \to f$ pointwise. So $f$ is convex, itself.

On the other hand, if $f$ is convex, then $f(x+h) – f(x) \ge f(x) – f(x-h)$, so $f(x+h) + f(x-h) -2 f(x) \ge 0$. From this the integral inequality follows.

By a change of variables (translation-invariance of Lebesgue measure) the given inequality can be equivalently rewritten as
$$
\int [f(x+h)+f(x-h)-2f(x)]\varphi(x)\,dx \geq 0 \qquad \text{for all }0 \leq \varphi \in C^{\infty}_0(\mathbb{R})\text{ and all }h \gt 0.
$$
If $f$ were not midpoint convex then there would be $x \in \mathbb{R}$ and $h \gt 0$ such that $f(x+h) + f(x-h) – 2f(x) \lt 0$. By continuity of $f$ this must hold in some small neighborhood $U$ of $x$, so taking any nonzero $\varphi \geq 0$ supported in $U$ would yield a contradiction to the assumed inequality.

Thus, $f$ is midpoint convex and hence convex because $f$ is continuous.


Edit: The converse direction should be clear: it follows from $f(x+h) + f(x-h) – 2f(x) \geq 0$ for convex $f$ and all $h \gt 0$ so that the integrand in the first paragraph is non-negative.

Finally, the argument above works without essential change for continuous $f \colon \mathbb{R}^n \to \mathbb{R}$.