How to prove the real value function $f$ is convex on $[a,d]$ if $f$ is convex on both $[a,c]$ and $[b,d]$? ($aHow to prove the real value function $f$ is convex on $[a,d]$ if $f$ is convex on both $[a,c]$ and $[b,d]$? ($a<b<c<d$).

I try to show that: for arbitrary $x\in(a,b), z\in(c,d)$, and for all $y\in (x,z)$ the inequality 
$\dfrac{f(y)-f(x)}{y-x}\leqslant \dfrac{f(z)-f(y)}{z-y}$
holds. Then $f$ is convex on $[a,d]$. 
But it seems to need some inequality tricks, I can't finish it. 
 A: Using the definition $f(\alpha x + (1- \alpha) y) \le \alpha f(x) + (1 - \alpha) f(y)$ might be not the simplest approach. Recall, the SOC for convexity, that is, if $f''(x) > 0$ for $x \in I$ then inside this interval $I$ function $f(\cdot)$ is convex. 
Hence, $f''(x) > 0,  ~\forall x \in [a, c]$ and $f''(x) > 0,  ~\forall x \in [b, d] \implies f''(x) > 0, ~\forall x \in [a, d],$ as required. 
A: The points $B= (b,f(b))$ and $C= (c, f(c))$ are the crucial reference points on the graph of $f$. 
Let $\ell$ be the line connecting $B$ and $C$. Then the two convexity conditions imply that the graph of $f$ restricted to $[a,b]$ is above $\ell$, and the graph of $f$ restricted to $[c,d]$ is above $\ell$. 
But then for any numbers $x\in [a,b], y\in [c,d]$, the points $X=(x, f(x))$ and $Y=(y, f(y))$ are also above $\ell$. Let $P$ be any point on the line segment $XY$. Then the first coordinate of $P$ is in $[a,c]$ or in $[b,d]$: assume that it is in $[a,c]$, the other case is similar. 
Then $P$ is above $\ell$, as it is above $XC$. 
A: This is a fact that is geometrically evident but a pain to prove.
Note that the overlap is essential, if $f(x) = -|x|$, then on the intervals
$[-1,0]$ and $[0,1]$ the function
$f$ is linear hence convex, but clearly $f$ is not convex on $[-1,1]$.
Define
$R(x,y) = {f(x)-f(y) \over x-y}$ for $x \neq y$. Note that $R$ is symmetric.
Then $f$ is convex iff $x \mapsto R(x,y)$ is monotonically non decreasing for each $y$. (cf. the derivative characterisation of convexity.)
We need to show that for all $t \in [0,1]$ that $f((t-1)x+ty) \le (t-1)f(x)+t f(y)$.
Suppose $x<y$. If $y \in [a,c]$ or $x \in [b,d]$ there is nothing to show, so
suppose $x \in [a,b), y\in (c,d]$.
Choose $m,m'$ such that $b<m'<m<c$. Then
$R(m,x) \le R(m,m') \le R(y,m') \le R(y,m)$. This is where the overlap is used.
Note that
\begin{eqnarray}
R(y,x) &=& {1 \over y-x} [R(m,x)(m-x) + R(y,m)(y-m)] \\
&\ge& {1 \over y-x} [R(m,x)(m-x) + R(m,x)(y-m)] \\
&\ge& R(m,x)
\end{eqnarray}
A similar analysis shows that $R(y,x) \le R(y,m)$.
Let $t^* = {m-x \over y-x}$. First suppose $t \le t^*$ and let $\lambda={t \over t^*}$.
Note that $x+\lambda(m-x) = x+t (y-x)$.
Then
\begin{eqnarray}
f(x+t(y-x)) &=& f(x+ \lambda(m-x)) \\
&\le& f(x)+ \lambda (f(m)-f(x)) \\
&=& f(x)+ t ( {y-x \over m-x} ) ( f(m)-f(x)) \\
&=& f(x) + t (y-x) R(m,x) \\
&\le& f(x) + t (y-x) R(y,x) \\
&=& f(x) + t (f(y)-f(x))
\end{eqnarray}
Now suppose $t \ge t^*$ and let $\mu = {t-t^* \over 1-t^*}$. Note that
$y+(1-\mu) (m-y) = x+t(y-x)$.  Then
\begin{eqnarray}
f(x+t(y-x)) &=& fy+(1-\mu) (m-y)) \\
&\le& f(y)+ (1-\mu)(f(m)-f(y)) \\
&=& f(y)+ (1-t)( {y-x \over y-m} ) (f(m)-f(y)) \\
&=& f(y) + (1-t)(y-x) (-R(y,m)) \\
&\le& f(y) + (1-t)(y-x) (-R(y,x)) \\
&=& f(y) + (1-t) (f(x)-f(y)) \\
&=& f(x) + t (f(y)-f(x))
\end{eqnarray}
A: Here I am writing $\overline{RS}$ to refer to the line segment that passes through $(R, f(R))$ and $(S, f(S))$.  And writing $\overline{RS}(x)$ to refer to the height of the line at $x$ . Saying $\overline{RS} \ge \overline{UV}$ means $\overline{RS}(x) \ge \overline{UV}(x)$ within the relevant domain.
We have to esablish $\overline{MN}$ lies above $f$ for all $M$ and $N$.  The cases not covered directly by the convexity assumptions are $M \in [A..B)$ and $N \in (C .. D]$.
For the sake of contradiction, assume $\overline{MN} < \overline{BN}$ (except at point $N$). $M<B$ then implies $f(M) < f(B)$.  

Since $C > B$, by convexity assumption within $[B .. D]$, $f(C) \le \overline{BN}(C)$. 

But this places $f(B) \ge \overline{MC}(B)$, contradicting convexity within $[A .. C]$.  So $\overline{MN} \ge \overline{BN}$.
By the same argument $\overline{MN} \ge \overline{MC}$.  So $\overline{MN}(x) \ge f(x)$.
