How to prove this criterion of a continuous function to be convex? Show that a continuous $f:(a,b)\to \mathbb{R}$ is convex iff for any $\alpha\in \mathbb{R}$ and a closed interval $I\subset (a,b)$, the function $f(x)+\alpha x$ attains its maximum at one of the ends of $I$. This problem comes from the book by Hardy, Polya and Littlewood
It is well-known that $f$ is convex if and only if for any $x_0$, there exists $\beta$ such that $f(x)\geq f(x_0)+\beta(x-x_0)$. I think this may be the point. But I have no idea to apply it.  
 A: It is practical to recall equivalent definitions of convexity. A function $f:(a,b)\to\mathbb{R}$ is said to be convex if
Version (1). For any $c,d\in(a,b)$ with $c<d$, the graph of $f(x)$ on the interval $[c,d]$ lies below the line through $(c,f(c))$ and $(d,f(d))$.
Version (2). The function $\Delta:(a,b)\times(a,b)\to\mathbb{R}$ defined by
$$ \Delta(c,d)=\frac{f(d)-f(c)}{d-c}\text{ provided that $c\neq d$} $$
is increasing with respect to both its parameters.
Version (3). For any $x,y,z\in(a,b)$ with $x<y<z$ we have $\det\left(\begin{smallmatrix}1 & 1 & 1 \\ x & y & z \\ f(x) & f(y) & f(z)\end{smallmatrix}\right)\geq 0$.
To prove $(1)\Leftrightarrow(2)\Leftrightarrow (3)$ is not too difficult and

If $f$ is convex on $(a,b)$ and $I=[c,d]\subset(a,b)$, for any
  $\alpha\in\mathbb{R}$ the maximum of $f(x)-\alpha x$ over $I$ is
  attained at one of the endpoints of $I$.

follows from the following principle: the convexity of $f$ implies the convexity of $f(x)-\alpha x$ (Version (3), Gaussian elimination), so it is enough to show that the maximum of a non-constant convex function on $[c,d]$ cannot be attained at an interior point. On the other hand if $e\in(c,d)$ is a point of maximum, for some $\varepsilon>0$ we have that $\Delta(e,e-\varepsilon)\geq 0$ while $\Delta(e,e+\varepsilon)\leq 0$, contradicting the fact that $\Delta$ is increasing with respect to the second parameter (Version (2)).
For the converse implication: given $[c,d]\subset(a,b)$, we may pick $\alpha$ as $\frac{f(d)-f(c)}{d-c}$. In such a way $f(x)-\alpha x$ attains the same values at $c$ and $d$ and the graph of $f(x)$ over $[c,d]$ lies below the horizonal line through $(c,f(c)-\alpha c)$. This implies that the graph of $f(x)$ over $[c,d]$ lies below the line through $(c,f(c))$ and $(d,f(d))$. Since $[c,d]$ is arbitrary, this ensures the convexity of $f$ - Version (1).
