Prove continuous $f$ is convex if and only if $\frac{f(x_2) - f(x_1)}{x_2 - x_1} \leq \frac{f(x_3) - f(x_1)}{x_3 - x_1}$ for $x_1 < x_2 < x_3$ Prove continuous $f$ is convex if and only if  for $x_1 < x_2 < x_3$
$$S_{1, 2} = \dfrac{f(x_2) - f(x_1)}{x_2 - x_1} \leq \dfrac{f(x_3) - f(x_1)}{x_3 - x_1} = S_{1, 3}$$
I get the intuitive idea of the statement and tried serveral ways to prove the direction "left to right".
First attempt:
By mean value theorem there must exist $\xi_1$ and $\xi_2$ such that $f'(\xi_1) = S_{1,2}$ and $f'(\xi_2) = S_{1, 3}$. And because of increasing monotony of a convex function's first order, I only have to prove that $\xi_1 \leq \xi_2$.
Second attempt:
Define a function
$$g(n): \mathbb{R}_+ \to \mathbb{R}, x \to \dfrac{f(x + n) - f(x)}{n}$$
I tried various ways to prove that the function $g$ is monotone increasing.
 A: Let $\lambda = \frac{x_2 - x_1}{x_3 - x_1} \in (0, 1)$ by assumption $x_1 < x_2 < x_3$, and so $x_2 = \lambda x_3 + (1-\lambda)x_1$. It follows from convexity that $f(x_2) \le \lambda f(x_3) + (1-\lambda)f(x_1)$, and thus
\begin{align*}
 f(x_2) - f(x_1)  \le \lambda(f(x_3) - f(x_1)) = \frac{x_2 - x_1}{x_3 - x_1}(f(x_3) - f(x_1))
 \end{align*}
Dividing both sides by $x_2 - x_1$ yields $S_{1,2} \le S_{1,3}$.
A: For $x_1 < x_2 < x_3$ these inequalities are equivalent:
$$
\begin{align}
\frac{f(x_2) - f(x_1)}{x_2 - x_1} &\leq \frac{f(x_3) - f(x_1)}{x_3 - x_1} \\
\iff (x_3 - x_1) (f(x_2) - f(x_1)) &\le (x_2 - x_1) (f(x_3) - f(x_1)) \\
\iff (x_3 - x_1) f(x_2) &\le (x_3 - x_2) f(x_1) + (x_2 - x_1) f(x_3) \\
\iff f(x_2)&\le \frac{x_3-x_2}{x_3-x_1} f(x_1) + \frac{x_2-x_1}{x_3-x_1}f(x_3).
\end{align}
$$
The last one is exactly the convexity condition. With the substitution $x_2 = (1-\lambda) x_1 + \lambda x_3$, $0 \le \lambda \le 1$, it becomes
$$
 f((1-\lambda) x_1 + \lambda x_3) \le (1-\lambda) f(x_1) + \lambda f(x_3) \, ,
$$
which might look more familiar.
The continuity of $f$ is not used in this calculation, it is also not needed that $f$ is differentiable.
