$f$ convex and concave, then $f=ax+b$ Let $f$ be a real function defined on some interval $I$. 
Assuming that $f$ both convex and concave on $I$, i.e, for any $x,y\in I$ one has
$$f(\lambda x+(1-\lambda)y)=\lambda f(x)+(1-\lambda)f(y),\, \, \lambda\in (0,1) .$$
I would like to show that $f$ is of the form 
$f=ax+b$ for some $a,b$. 
I was able to prove it when $f$ is differentiable, using the relation 
$$f'(x)=f'(y).$$
Anyway, I was not able to provide a general proof (without assuming that $f$ is differentiable, and without assuming that $0\in I$). 
Any answer will be will be appreciated.
Edit: It is little bit different from tte other question
How to prove convex+concave=affine?. Here $f$ is defined on some interval, so $o$ not necessary in the domain. Please remove the duplicate message if this possible 

Let $x<y$ be in $I$. Then for $z=\lambda x + (1-\lambda)y\in [x,y]$,
$$f(z)=f(\lambda x + (1-\lambda)y)=\lambda f(x)+(1-\lambda)f(y)=\frac{f(y)-f(x)}{y-x}(z-x)+f(x)$$
Hence, $f(z)=az+b$ for some $a,b$ on every closed interval in $I$. Every interval can be expressed as the limit of a non-decreasing sequence of closed intervals $(I_n)_{n\in\mathbb{N}}$, and since $f\rvert I_n$ must coincide with $f\rvert I_{n+1}$ on $I_n$, we find that $f$ extends to a linear function $az+b$ on all of $I$.
