<s>[INST] Midpoint-Convex and Continuous Implies Convex Given that $$f\left(\frac{x+y}{2}\right)\leqslant \frac{f(x)+f(y)}{2}~,$$
how can I show that $f$ is convex.
Thanks.  

Edit: I'm sorry for all the confusion. $f$ is assumed to be continuous on an interval $(a,b)$.
 [/INST] 
I would like to properly show by induction that if $ m\in\{0,1,2,\ldots,2^{n}-1\} $ then
$$
f\left(\frac{m}{2^n}x+\Big(1-\frac{m}{2^n}\Big)y\right)\le \frac{m}{2^n}f(x)
+\Big(1-\frac{m}{2^n}\Big)f(y). 
$$
and then the result will follows by contuinity since $$ m=\lfloor2^nt\rfloor \in\{0,1,2,\ldots,2^{n}\} ~~~and~~\frac{\lfloor2^nt\rfloor}{2^n}\to t$$


The initial state $n = 1$ is trivial by hypothesis.
Now we assume that for every $k<n$,  whenever $m\in\{0,1,2,\ldots,2^{k-1}-1\}$,we have
$$
f\left(\frac{m}{2^k}x+\Big(1-\frac{m}{2^k}\Big)y\right)\le \frac{m}{2^k}f(x)
+\Big(1-\frac{m}{2^k}\Big)f(y). \tag{I}\label{I}
$$
we want to prove \eqref{I} for $k=n$.
Let $m \in\{0,1,2,\ldots,2^{n}-1\}$ then the division  by 2 yields $m =2p +r$ with $r\in \{0,1\}$
\begin{align}X&:=\left(\frac{m}{2^n}x+\Big(1-\frac{m}{2^n}\Big)y\right)= \left(\frac{2p +r}{2^n}x+\Big(1-\frac{2p +r}{2^n}\Big)y\right) 
\\&= \left(\frac{p }{2^n}x+\frac{p +r}{2^n}x+\Big(1-\frac{p }{2^n}y-\frac{p +r}{2^n}y\Big)y\right)
\\&= \frac12 \left(\frac{p }{2^{n-1}}x+\frac{p +r}{2^{n-1}}x+\Big(2-\frac{p }{2^{n-1}}y-\frac{p +r}{2^{n-1}}y\Big)y\right)
\\&=\frac12\left(\frac{p }{2^{n-1}}x+ \Big(1-\frac{p }{2^{n-1}}y\Big)\right)+\frac12\left(\frac{p+r }{2^{n-1}}x+ \Big(1-\frac{p +r}{2^{n-1}}y\Big)\right) \\&:=
\color{red}{\frac{1}{2}\left(X_1+X_2\right)}\end{align}
On the other hand, since $r\in \{0,1\}$ and $m\in\{0,1,2,\ldots,2^{n}-1\}$ it is easy to check using parity that $p,p+1 \in \{0,1,2,\ldots,2^{n-1}-1\}$
that is $p+r \in \{0,1,2,\ldots,2^{n-1}-1\}$
By hypothesis of induction we obtain
\begin{align}f(X) &= f\left(\frac{1}{2}\left(X_1+X_2\right)\right)\le \frac12f(X_1) +\frac12f(X_2) \\&=
\frac12f\left(\frac{p }{2^{n-1}}x+ \Big(1-\frac{p }{2^{n-1}}y\Big)\right)+\frac12f\left(\frac{p+r }{2^{n-1}}x+ \Big(1-\frac{p +r}{2^{n-1}}y\Big)\right)
\\&\le\frac12\left(\frac{p }{2^{n-1}}f(x)+ \Big(1-\frac{p }{2^{n-1}}f(y)\Big)\right)+\frac12\left(\frac{p+r }{2^{n-1}}f(x)+ \Big(1-\frac{p +r}{2^{n-1}}f(y)\Big)\right) \\&= \frac{2p+r}{2^n}f(x)
+\Big(1-\frac{2p+r}{2^n}\Big)f(y)\\&= \frac{m}{2^n}f(x)
+\Big(1-\frac{m}{2^n}\Big)f(y).\end{align}
</s>