Why is $f$ or $-f$ convex in this case? In some notes I found this statement:
Let $f$ be continuous on $\mathbb{R}$ and for each $x\in \mathbb{R}$ there is a line that goes through $(x, f(x))$ and the graph of $f$ is only at the one side of the line. Then either $f$ or $-f$ is convex.
Why does this hold? It is not clear for me why the function has to be convex then.
Could you explain that to me?
$$$$
EDIT:
Let $a<b$.
If $(b, f(b))$ is above the line that passes through $(a, f(a))$ and $(a, f(a))$ is above the line that passes through $(b, f(b))$, then the slope of the line through $(b, f(b))$ must be larger than the slope of the line through $(a, f(a))$.
The line through $(a, f(a))$ is the graph of $g(x)=m_1(x-a)+f(a)$ and since $(b, f(b))$ is above that line, we have $f(b)>m_1(b-a)+f(a)$.
Similarily, the line through $(b, f(b))$ is the graph of $h(x)=m_2(x-b)+f(b)$ and since $(a, f(a))$ is above that line, we have $f(a)>m_2(a-b)+f(b)$.
Is everything correct so far? How could we continue?
 A: Consider a line $l_i$ through $(x_i,f(x_i)),\ x_0<x_1$ s.t. the line $l_i$ is given by $y_i
 (x)=m_i(x-x_i) +f(x_i)$ and the graph of $f$ is in oneside wrt each line $l_i$
If $f$ is linear, then we are done. Now we assume that $f$ is not a linear.

Step 1 : $f(x)\leq y_i(x)$ for all $i$ and all $x$ (concave case)

or $f(x)\geq y_i(x)$ for all $i$ and all $x$ (convex case)
Proof : We will prove by a contradiction. Assume that $f
 (x)\leq y_0(x)$ for all $x$ and $f(x)\geq y_1(x)$ for all $x$.
If two lines are not parallel, then they intersects. When we consider the graph around intersection point, we have a contradiction.
Hence two lines are parallel. In the long run, such lines at any point $(x,f(x))$ are parallel. Hence we completes the proof.
Step 2 : Now we assume that for any $a$, there is $m_a$ s.t. $f(x)\leq m_a(x-a) +f(a) $ for all $x$.
Now we will prove that $f$ is concave i.e. $f(t-s) + f(t+s) \leq 2 f(t)\ \ast$ for $s>0$.
At $t$, there is $m_t$ so that $$f(t-s)\leq m_t(t-s -t) +f(t) $$
$$ f(t+s)\leq m_t(t+s-t) +f(t) $$
which implies $\ast$.
