I am stuck on this problem:
Problem: Let $f:[0,1]\rightarrow\mathbb{R}$. Suppose that there exists $\epsilon>0$ such that for all $x,y\in[0,1]$ we have $|f(x)-f(y)|\leq \epsilon$. Let $g$ be the linear function with $g(0)=f(0)$ and $g(1)=f(1)$, i.e. $$g(x)=(f(1)-f(0))x+f(0).$$ Prove that for all $x\in [0,1]$ we have $|f(x)-g(x)|\leq \epsilon$.
So far, I have been able to get a $2\epsilon$ upper bound by \begin{align*} |f(x)-g(x)|&\leq |f(x)-(f(1)-f(0))x-f(0)| \\ & \leq |f(x)-f(0)|+|f(1)-f(0)|\cdot|x| \\& \leq \epsilon+\epsilon\cdot 1 =2\epsilon. \end{align*} But I am not sure how to get the $\epsilon$ bound. I tried other forms of the triangle inequality, but often I get a $|g(x)-g(0)|$ term which is not generally small.
Let $m=\inf \{f(x): 0\leq x\leq 1\}$ and $M=\sup \{f(x): 0\leq x\leq 1\}$. Then $M-m \leq \epsilon$. Since $g(0)$ and $g(1) \in [m,M]$ and $g$ is linear it follows that $g(x) \in [m,M]$ for all $x$. Now the distance between any two points of $[m,M]$ is at most $M-m \leq \epsilon$. Hence $|f(x)-g(x)| \leq \epsilon$.