Prove that a continuous function on a compact subset of ${\mathbb{R} }^n$ is almost like a Lipschitz function. Suppose I have $K \subset { \mathbb{R} }^n $ a compact subset,and a continuous function $f : K \to \mathbb{R} $.
Given some $\epsilon >0$ prove there exist some $L$ such that for all $x,y \in X$
I have $$|f(x)-f(y) | \leq L |x-y | + \epsilon $$
Now I was able to find some proofs for a similar problem where $K$ is convex but couldn't find a proof that doesn't use convexity.
One thing I considered is to approximate the derivative of $f$ like this $$Df \approx \frac{f(x)-f(y)}{x-y} - \epsilon $$ and somehow prove that the approximation is bounded but couldn't come up with a proof, maybe the mean value theorem may help.
How can I show this?
 A: Now given $\epsilon$, there is $\delta$ so that $|x-y|<\delta$ implies
$|f(x)-f(y)|<\epsilon$: such $\delta$ exists since $K$ is compact so $f$
is uniformly continuous; also note $f$ is bounded, so $|f|\leq M$ for
some $M$.
So we can let $L=\frac{2M}{\delta}$: if $|x-y|<\delta$, then $|f(x)-f(y)|<\epsilon\leq L|x-y|+\epsilon$; if $|x-y|\geq\delta$, then
$$
|f(x)-f(y)|\leq |f(x)|+|f(y)|\leq 2M=\frac{2M}{\delta}\delta=L\delta 
\leq L|x-y|<L|x-y|+\epsilon.
$$
This estimate looks quite weak.
A: Fix $\epsilon>0.$ If the claim is false, then there are sequences $(x_n), (y_n)\subseteq K$ such that
$\tag1 |f(x_n)-f(y_n) | > n |x_n-y_n | + \epsilon.$
Since $K$ is compact, there is a convergent subsequence $(x_{n_k})\to x\in K$, of $(x_n)$. For the same reason, there is a convergent subsequence  $(y_{n_{k_l}})\to y\in K.$ Thus, $x_{n_{k_l}}-y_{n_{k_l}}\to x-y.$ Continuity of $f$ implies that $f(x_{n_{k_l}})\to f(x)$ and $f(y_{n_{k_l}})\to f(y)$ and continuity of the absolute value function now implies that
$\tag2 |f(x_{n_{k_l}})-f(y_{n_{k_l}})|\to |f(x)-f(y)|.$
If $x=y$ then $(1)$ and $(2)$ combine to give a contradiction: $0>\epsilon.$
But if $x\neq y$ we also get a contradiction since in this case we have $|f(x_{n_{k_l}})-f(y_{n_{k_l}})|\to |f(x)-f(y)|<\infty$ whereas $n |x_n-y_n |\to \infty.$
