Example of a function such that $\varphi\left(\frac{x+y}{2}\right)\leq \frac{\varphi(x)+\varphi(y)}{2}$ but $\varphi$ is not convex
I'm not sure there is a constructive example, but here is a construction using the Axiom of Choice:
$\mathbb{R}$ is a vector space over $\mathbb{Q}$. Choose (using AC) a basis $\{r_i\}_{i\in I}$ for $\mathbb{R}$, and consider the linear transformation $h$ that swaps the coefficients for two particular basis vectors $r_1$ and $r_2$. Then $h$, being a linear transformation, preserves addition and multiplication by $1/2$ (since $1/2 \in \mathbb Q$), but is everywhere discontinuous. In fact the range of $h$ on any open interval is dense in $\mathbb R$. (Prove this!)
Now consider $\phi(x) = h(x)^2$. Since $x^2$ is convex and $h$ preserves addition and halving, $\phi$ must satisfy the inequality. On the other hand, $\phi$ cannot be convex since the image of any open interval is dense in $\mathbb R_+$.
Any midpoint-convex function on $\mathbb R$ that is not convex must not be Lebesgue measurable. According to a result of Solovay, there are models of Zermelo-Fraenkel set theory without Axiom of Choice in which there are no non-measurable functions ${\mathbb R} \to {\mathbb R}$. Thus there is no way to explicitly construct your counterexample.
It is worth mentioning that the functions with the above property are often called midpoint convex or Jensen convex. It can be shown that every midpoint convex function is rational convex.
Every non-continuous solution of Cauchy equation gives a an example of midpoint convex function which is not convex. (Note that the proof of existence of such solutions uses Axiom of Choice. Most frequently, it is proved using Hamel basis.) It is basically the same example as Henning gave, but without composing the solution with $x\mapsto x^2$.
See e.g. William F. Donoghue: Distributions and Fourier transforms, p.11. (This books was among the first google books results when searching for "midpoint convex" "not convex" function.)
Interestingly, while googling (in order to add some useful links) I stumbled upon blogs of some math.stackexchange users:
- ShreevatsaR: Convex, continuous, Jensen’s
- Beni Bogosel: Jensen convexity
A natural question is what can be said without Axiom of Choice. Although I do not know the answer to this, I'll at least add link to a mathoveflow question Are there any non-linear solutions of Cauchy’s equation $(f(x+y)=f(x)+f(y))$ without assuming the Axiom of Choice?, where it is explained that at least some form of AC is needed to obtain a non-continuous solution of Cauchy functional equation.
EDIT: I see that in the meantime the question of necessity of AC was answered by Robert Israel.