Show that the inequality $|f(x)-f(y)| \leq M||x-y||+\epsilon$. Suppose $K \subset \mathbb{R}^n$ is a compact set and $f:K \rightarrow \mathbb{R}$ is continuous. Let $\epsilon >0$ be given. Prove that there exists a positive number $M$ such that for all $x$ and $y$ in $K$ one has the inequality:
$|f(x)-f(y)| \leq M||x-y||+\epsilon$. Then given a counter-example to show that the inequality is not general true if one take $\epsilon =0$.
My attempt: Since $K$ is a compact set and $f:K \rightarrow R$ is a continuous function. This implies $f$ is a uniformly continuous function.
Let $\epsilon =1>0$, there is a $\delta>0$ such that if $x,y \in K$ and $||x-y||<\delta$. Then $|f(x)-f(y)| \leq 1$.
Now, choose $n$, such that $n\delta \leq ||x-y|| \leq (n+1) \delta$. Then,
$|f(x)-f(y)|\leq |f(x)-f(x+\delta)| +|f(x+\delta)-f(x+2\delta)| +|f(x+2\delta)-f(x+3\delta)|+......+|f(x+n\delta)-f(y)|\leq n+1.$
This implies $|f(x)-f(y)|\leq \frac{||x-y||}{\delta}+1$.
Assume that $M=\frac{1}{\delta}$, and we choose $\epsilon =1$., then $|f(x)-f(y)|\leq M||x-y||+\epsilon$.
Is this proof is correct?
 A: Here is a proof that does not rely on $K$ being convex. In fact, it holds for any continuous function $f$ from a compact metric space $K$ to another metric space.
Given $\epsilon>0$, pick $\delta>0$ such that $\|y-x\|<\delta$ implies $|f(y)-f(x)|<\epsilon$ for all $x,y\in K$. Put
\begin{align}
M=\frac{1}{\delta}\max_{x,y\in K}|f(y)-f(x)|\,.
\end{align}
We claim that $|f(y)-f(x)|\leq M\|y-x\|+\epsilon$ for all $x,y\in K$. There are two cases.

*

*When $\|y-x\|<\delta$, we have $|f(y)-f(x)|<\epsilon$.


*When $\|y-x\|\geq\delta$, we have $\frac{|f(y)-f(x)|}{\|y-x\|}\leq M$,
so $|f(y)-f(x)|\leq M\|y-x\|$.
A: Let me bring my view for easy case and sorry for little off top - it is not exactly sentence above, but may be interesting. I can put it in comments, if it will be more good, but there is hard to type formulas and is limitation on length.
Suppose $E=[a, +\infty)$ and $f:E \rightarrow \mathbb{R}$ is uniformly continuous. Then exists $M$ and $d$ such, that for $\forall x,y \in E$ will be $\left| f(x)-f(y)  \right| \leqslant M \left| x-y \right|+d$
If desire is put forward I can bring my proof.
