Prove that every convex function is continuous 
A function $f : (a,b) \to \Bbb R$ is said to be convex if
$$f(\lambda x+(1-\lambda)y)\le \lambda f(x)+(1-\lambda)f(y)$$
whenever $a < x, y < b$ and $0 < \lambda <1$. Prove that every convex function is continuous.


Usually it uses the fact:
If $a < s < t < u < b$ then $$\frac{f(t)-f(s)}{t-s}\le \frac{f(u)-f(s)}{u-s}\le\frac{f(u)-f(t)}{u-t}.$$
I wonder whether any other version of this proof exists or not?
 A: I think there's a neat proof, but maybe I made a mistake.
Fix an $x\in(a,b)$ and take a $y$ such that $a<y<x$. We suppose that $f$ is discontinuous at $x$. If so, there is an $\epsilon>0$ such that we can choose a sequence $(\lambda_n)$ that satisfies
$$0<\lambda_1<\lambda_2<\cdots<1;$$
$$\lambda_n\to 1;$$
$$f(\lambda_nx+(1-\lambda_n)y)\geq f(x)+\epsilon;$$
given that all the $\lambda_n$ are taken sufficiently near $1$ (ie, you're choosing points sufficently near $x$ and associating the correspondent $\lambda$). It's also valid that
$$f(\lambda_nx+(1-\lambda_n)y)\leq \lambda_nf(x)+(1-\lambda_n)f(y).$$
Now, multiplying the first inequality by $-1$ and adding it to the seconde one we get:
$$0\leq (\lambda_n-1)f(x)+(1-\lambda_n)f(y)-\epsilon.$$
Making $n\to\infty$:
$$ 0\leq-\epsilon \Rightarrow\epsilon=0; $$
a contradiction.
$\mathstrut$
A: I like GEdgar's pictorial explanation.
The key idea is:   for $f(x)$ in $(a,b)$, we try to prove $f(x)$ is bounded above and below.
It's easy to show $f(x)$ is bounded above by definition of convex.
To show $f(x)$ is bounded below, we can see GEdgar's 2nd and 3rd picture. 
Once we proved $f(x)$ is bounded, $|f(x)|\leq M$,
$$a < s < t < u < b$$ 
let $$s < x < u \quad;\quad 0<\varepsilon<u-x$$
then we can show 
$$f(x+\varepsilon)-f(x)\leq \dfrac{f(u)-f(s)}{(u-s)}\varepsilon \leq  \dfrac{M\varepsilon}{(u-s)}$$
as $\varepsilon \rightarrow 0$ $$|f(x+\varepsilon)-f(x)| \rightarrow  0$$ then $f(x+)=f(x)$
the same way we can show $f(x-)=f(x)$,
so $f(x)$ is continuous
A: This is an exercise in Rudin's Principles of Mathematical Analysis (Chapter 4 Problem 23 in the 3rd edition). The inequalities you quoted in "Usually it uses the fact ..." is a part of an exercise in the problem 23.
Indeed one can use the inequalities
$$\frac{f(t)-f(x)}{t-s}\le \frac{f(u)-f(x)}{u-s}\le\frac{f(u)-f(t)}{u-t}$$
to show that both of the following limits exist:
$$
R_x=\lim_{h\to 0^+}\frac{f(x+h)-f(x)}{h},\quad L_x=\lim_{h\to 0^+}\frac{f(x)-f(x-h)}{h}
$$
and thus $\lim_{h\to 0}\big(f(x+h)-f(x)\big)=0$. 

Alternatively, let $x,y,z\in (a,b)$ with $a<z<x<y<b$. Suppose $x_n\in(z,y)$ and $x_n\to x$ as $n\to\infty$. Define
$$
L=\{n\mid z<x_n\le x\},\quad
R=\{n\mid x\le x_n<y\}.
$$
Then 
$$
\textrm{for } n\in R,\ x_n=\lambda_n x+(1-\lambda_n)y,\quad \lambda_n=\frac{x_n-y}{x-y};\tag{1}
$$
$$
\textrm{for } n\in L,\ x_n=(1-\mu_n) z+\mu_n x,\quad 
\mu_n=\frac{x_n-z}{x-z}.\tag{2}
$$
It follows by convexity that
$$
\textrm{for } n\in R,\ f(x_n)\leq \lambda_nf(x)+(1-\lambda_n)f(y);\\
\textrm{for } n\in L,\ f(x_n)\leq \mu_n f(x)+(1-\mu_n)f(z) .   \tag{4}
$$
which yields †
$$
\limsup_{n\to\infty} f(x_n)\leq f(x).\tag{5}
$$
Similarly, one can get 
$$
f(x)\le \liminf_{n\to\infty} f(x_n) \tag{6}
$$
by observing that 
$$
\textrm{for } n\in R,\ x=(1-\tilde\lambda_n)z+\tilde\lambda_n x_n;\tag{7}
$$
$$
\textrm{for } n\in L,\ x=\tilde\mu_n x_n+(1-\tilde\mu_n)y.\tag{8}
$$
Combining (5) and (6), we have
$$
\lim_{n\to \infty}f(x_n)=f(x),
$$
and hence $f$ is continuous at $x\in (a,b)$. 

† There are three cases:


*

*$R$ is finite;

*$L$ is finite;

*Both $R$ and $L$ are infinite. 

A: You can do a proof by contradiction. 
Assume $f\in\mathbb{R}^\mathbb{R}$ is convex, but not continuous at some $x_0\in(a,b)$. This means that:
$$ \exists_{\epsilon>0}\forall_{\delta>0}\exists_{x\in(x_0-\delta,x_0+\delta)} : |f(x)-f(x_0)|\ge\epsilon$$
This formula implies that once we fix $\delta$, $f$'s graph has infinitely many points in one of the areas: I, II, III or IV, with $x_0$ as an accumulation point of their $x$ coordinates:

We split our proof into 2 cases:
$(1)$ The area is either I or II. In this case we select some point on the function's graph from that area: $(x_1,f(x_1))$, and draw a line segment from that point to $(x_0,f(x_0))$. We then select another point on the graph from the same area: $(x_2,f(x_2))$, whose $x$ coordinate is closer to $x_0$  than the intersection of our line segment and $y=f(x_0)+\epsilon$ . This contradicts the convexity of $f$, as can be seen in the following image:

$(2)$ The area is either III or IV. Assume, without loss of generality, that the area is III. In this case we select some point on the function's graph to the right of $x_0$, say: $(x_1,f(x_1))$. We then draw a ray, which starts at $(x_1,f(x_1))$, and goes through $(x_0,f(x_0))$. We use $x'$ to denote the $x$ coordinate of the intersection of our ray and $y=f(x_0)-\epsilon$. If they do not intersect, we set: $x'=-\infty$. Next, we select another point: $(x_2, f(x_2))$ on $f$'s graph, in area III, with $x'<x_2<x_0$. Finally, we draw a segment between $(x_2, f(x_2))$ and $(x_1, f(x_1))$. This again contradicts convexity, as can be seen in the following image:

A: Here is a sort of dumb but hopefully straightforward approach.
Let $ f : I \rightarrow \mathbb{R} $ be a convex function on open interval $ I $.

Idea: For every triple $ p_1 < p_2 < p_3 $ in $ I $ we get one inequality :
$ p_2 = p_1 + t(p_3 - p_1) $ for some $ t \in (0,1) $. From this $ t = \dfrac{p_2 - p_1}{p_3 - p_1} $, and so $ p_2 = (1-t)p_1 + tp_3 = \dfrac{p_3 - p_2}{p_3 - p_1} p_1 + \dfrac{p_2 - p_1}{p_3 - p_1} p_3. $
Now convexity gives $ f(p_2) \leq \dfrac{p_3 - p_2}{p_3 - p_1} f(p_1) + \dfrac{p_2 - p_1}{p_3 - p_1} f(p_3). $

Let $ p \in I $. Fix $ a <  p < b $ in $ I $.

Right continuity at p :
Let $ p < x < b $. We want inequalities involving $ f(x) $.
From this triple, $ f(x) \leq \frac{b-x}{b-p} f(p) + \frac{x-p}{b-p} f(b) $.
From the triple $ a < p < x $, we have $ f(p) \leq \frac{x-p}{x-a} f(a) + \frac{p-a}{x-a} f(x) $, and bringing $ f(x) $ to one side it is $ \frac{x-a}{p-a} f(p) - \frac{x-p}{p-a} f(a) \leq f(x) $.
Combined,
$$ \frac{x-a}{p-a} f(p) - \frac{x-p}{p-a} f(a) \leq f(x) \leq \frac{b-x}{b-p} f(p) + \frac{x-p}{b-p} f(b) $$
Writing $ x $ as $ p + \delta $, this becomes
$$ f(p) + \frac{\delta}{p-a} (f(p) - f(a)) \leq f(p+\delta) \leq f(p) + \dfrac{\delta}{b-p} (f(b) - f(p)) $$
So $ f(p+\delta) - f(p) $ is in a closed interval $ \left[ \delta \frac{f(p)-f(a)}{p-a}, \delta \frac{f(b)-f(p)}{b-p} \right] $, making $ |f(p+\delta)-f(p)| \leq \delta M $ where $ M = \max \left\{ \left| \frac{f(p)-f(a)}{p-a} \right| ,  \left| \frac{f(b)-f(p)}{b-p} \right| \right\} $.
Left continuity at p : Similar.
A: I would be careful to rephrase the query as:
Is there an alternative proof of the fact that a real-valued convex function defined on an open interval of the reals is continuous?
Since in general convex functions are not continuous nor are they necessarily continuous when defined on open sets in topological vector spaces.
An alternative might be to identify the point of discontinuity as x. Then there exists a point arbitrarily close to x, denoted x', whose value f(x') is bounded away by a constant from f(x). Depending on how you want your proof structured, you may think it sufficient to note that this implies the epigraph of the function is not closed and therefore the function is not lower semicontinuous. But every convex function on the reals is lower semicontinuous on the relative interior of its effective domain, which equals the domain of definition in this case.
A more general proof of this property is given in "Convexity and Optimization in Banach Spaces." The authors prove the proposition that every proper convex function defined on a finite-dimensional separated topological linear space is continuous on the interior of its effective domain. You can likely see the relevant proof using Amazon's or Google Book's look inside feature.
A: The pictorial version.  (But it is the same as your inequality version, actually.)
Suppose you want to prove continuity at $a$.  Choose points $b,c$ on either side.  (This fails at an endpoint, in fact the result itself fails at an endpoint.)

By convexity, the $c$ point is above the $a,b$ line, as shown:

Again, the $b$ point is above the $a,c$ line, as shown:

The graph lies inside the red region, 

so obviously we have continuity at $a$.
A: I presume you mean "proper convexity' as in $(1)$ above not $(2)$
Not just mere, " "midpoint convex/jensen convexity"/ "convexity in the sense of Jensen","  as in $(2)$, below. 
Although (its hardly mere I suppose) because the $(1)$ as defined in the question and $(2)$ below are, not, but are nonetheless "almost equivalent".
(2) $$F(\frac{x+y}{2}) \leq \frac{F(x)}{2} +\frac{F(y)}{2}$$
That is because under relatively mild conditions measurability, regularity conditions/boundedness conditions, midpoint convex function (in the sense of Jensen) are convex in the tradition .
Apparently a real valued midpoint convex function $(2)$ already satisfies the definition of convexity as above $(1)$, except for the restriction that $\sigma$ applies only to all rational numbers in the the unit interval  (not just $2$, or dy-adics). That is before continuity is applied. 
That is $(1.a)$ below according to pt. 7.11 of chapter "Continuous Convex Functions" in http://link.springer.com/chapter/10.1007%2F978-3-7643-8749-5_7
$$(1.a)\forall \, \sigma \in \mathbb{Q}\cap[0,1];\,  \forall (x,y)\, \in\, \text{dom}(F):\, F(\,\sigma x + [1-\sigma] y\,)\, \leq\, \sigma F(x)\,+\,[1-\sigma]F(y).$$ 
Its presumably a bit confusing the use the words 'in the sense of Jensen' for midpoint convexity.
This is because I believe that Jensen did, or helped develop the inequalities that any  'function'  must satisfy, in order to be 'properly convex',as defined above in the question $(1)$.
Because Jensen  well as the weaker notion of midpoint convexity $(2)$ which apparently is equivalent to $(1.a)$, at least if the domain is real valued, and  which is named after Jensen (midpt convexity is often called jensen- convexity).
A: The best alternative proof (in my humble opinion) is a function is convex if and only if its epigraph is a convex set.  If a function is NOT continuous then the epigraph can't be convex (obviously... draw a picture); but then by the above, the function can't be convex.  This proof used the contrapositive.
A: Here is the picture of my proof
Let, By contrary, $c$ be a point on the domain. Choose a $d$ then there exists a sequence $\{a_n\}_n$ that converges to c and $f(a_n) \notin (f(c)-d,f(c)+d)$.
So from the sequence $\{a_n\}_n$ we can always select a one sided monotonic sequence $\{c_n\}_n$ which is the subsequence of the original seq. as one side of $c$ must have infinitely many points of $\{a_n\}_n$, WLOG let it is the left sided sequence & $f(c_1)<f(c)-d$ 
Now, take $M_1=(c_1,c)$ any point $x$ in $M_1$ must be $<f(c)-d$ as  $\exists m$ s.t. $c_m\leq x\leq c_{m+1}$ hence $x$ must belong lower area of line joining of $f(c_m)$ & $f(c_{m+1})$ (By convexity of $f$) so for all $x$ in $M_1$ $f(x)<f(c)-d$.
Now, join the point $(c_1,f(c_1))$ & $(c,f(c))$ (let the line be $l_1$). It will cut at B at the $y=f(x)+d$. Let x-cordinate of B is $c^{'}$.
Now, note $B=(c^{'},f(c^{'})$ lie upper area of $l_1$ otherwise contradicting the point $A=(c,f(c))$ (By convexity of $f$).
Now from B we can always draw a line such that A lie upper area of this line intersecting at B' at $y=f(c)-d$ line. So let x-cordinate of B' is $c^{''}$. 
Now lastly join $(c^{''},f(c^{''}))$ & $(c^{'},f(c^{'}))$ contradicting the point A.
A: Here, I just like to continue @Jonathan Honório's proof with the comment by @Ben Ciotti.
Let $x\in(a,b)$ and take $y\in(a,x)$. Suppose in the case that
\begin{align}
f(\lambda_n x+(1-\lambda_n)y)\le f(x)-\epsilon
\end{align}
for some fixed $\epsilon>0$ and for some sequence $(\lambda_n)$ that satisfies
\begin{align}
0<\lambda_1<\lambda_2<\cdots<1;\quad \lambda_n\to 1.
\end{align}
Take $u\in(x,b)$, and denote $x_n:=\lambda_nx+(1-\lambda_n)y$, and define the sequence $(\theta_n)$ with
\begin{align}
x=\theta_nx_n+(1-\theta_n)u.
\end{align}
Clearly, the definition of $x_n$ implies $0<\theta_n<1$. Since $x_n\to x$, we obtain $\theta_n\to 1$. Now, the convexity of $f$ and the assumption gives
\begin{align}
f(x)\le\theta_nf(x_n)+(1-\theta_n)f(u)\le\theta_n(f(x)-\epsilon)+(1-\theta_n)f(u).
\end{align}
Subtracting $f(x)$ on both sides gives
\begin{align}
0\le(\theta_n-1)f(x)-\theta_n\epsilon+(1-\theta_n)f(u)
\end{align}
As $\theta_n\to 1$, we obtain $0\le-\epsilon$, which is a contradiction.
