TITLE: 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
QUESTION [32 upvotes]: Rudin's Real and Complex Analysis Chapter 3 Exercise 4 is:
Assume that $\varphi$ is a continuous real function on $(a,b)$ s.t. $$\varphi\left(\frac{x+y}{2}\right)\leq \frac{\varphi(x)+\varphi(y)}{2}$$ for all $x,y\in(a,b)$. Prove that $\varphi$ is convex. 
The conclusion does not follow if continuity is omitted from the hypotheses.
My question is, is there some way to explicitly construct a counterexample such that  $\varphi\left(\frac{x+y}{2}\right)\leq \frac{\varphi(x)+\varphi(y)}{2}$ for all $x,y\in(a,b)$, but $\varphi$ is not convex?

REPLY [24 votes]: 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.