Continuous functions satisfying a condition to be convex Let $f$ be continuous on $\mathbb R$, and satisify
$$f(x)\leq \frac{1}{2h}\int_{-h}^h f(x+t)d t, \forall\ h>0.$$
Show that $f$ is convex.
The original question is "if and only if". However, I could only prove on part. But the other part (this question) is this problem. I want to show that 
$$f((x+y)/2)\leq (f(x)+f(y))/2$$
from $$f(x)\leq \frac{1}{2h}\int_{-h}^h f(x+t)d t, \forall\ h>0.$$ However, I have no idea.
 A: Here is a possible approach.
Lemma. A necessary and sufficient condition that a continuous function $f$ should be convex in an interval $I$ is that, if $\alpha$ is any real number and $K$ is any closed interval contained in $I$, the $x \mapsto f(x)+\alpha x$ should attain its maximum in $K$ at one of the ends of $K$.
This is a direct consequence of the definition of convexity.
Now, if $f$ satisfies your integral condition, then also $x \mapsto f(x)+\alpha x$ satisfies the same condition, no matter what $\alpha$ is. But it is not really hard to check that the integral inequality implies the applicability of the previous Lemma.
(This approach is suggested on the book Inequalities by Hardy, Littlewood and Polya, page 98).
A: Let $\delta>0$ and define 
$$
f_\delta(x)=\frac{1}{\delta^2}\int_{-\delta}^\delta \lvert s\rvert\,f(x+s)\,ds.
$$
Then $f_\delta$ twice continuously differentiable, 
and $f_\delta\to f$ uniformly in compact
sets.
Next, we can readily obtain that
$$
f_\delta(x)\le\frac{1}{2h}\int_{-h}^hf_\delta(x+t)\,dt,
$$
which implies that for all $h>0$:
$$
\int_{-h}^h\big(f_\delta(x+t)-f_\delta(x)\big)\,dt=
\int_0^h\big(\,f_\delta(x+t)-2f_\delta(x)+f_\delta(x-t)\big)\ge 0.
$$
But
$$
\int_0^h\big(\,f_\delta(x+t)-2f_\delta(x)+f_\delta(x-t)\big)=\int_0^h
\Big(\int_0^t \big(\,f'_\delta(x+\tau)-f'_\delta(x-t+\tau)\big)\,d\tau\Big)\,dt \\=
\int_0^h
\Big(\int_0^t \big(\,\int_{-t}^0 f''_\delta(x+\tau+s)\,ds\big)\,d\tau\Big)\,dt
$$
and hence, for all $h>0$:
$$
\int_0^h
\Big(\int_0^t \big(\,\int_{-t}^0 f''_\delta(x+\tau+s)\,ds\big)\,d\tau\Big)\,dt\ge 0,
$$
which implies that
$$
f''_\delta(x)\ge 0,
$$
for all $x$.
Hence $f_\delta$ is convex, and so is $f$, as a locally uniform limit of $f_\delta$, as $\delta\searrow 0$. 
