# Given a continous real function, it is almost globally Lipschitz:

Let $$f:K\subset\mathbb{R}^N\longrightarrow\mathbb{R}$$ continous over $$K$$ compact. Show that: $$\forall\varepsilon>0\quad \exists L>0\hspace{0.5mm}\mid \hspace{0.5mm}\forall x,y\in K\quad\|f(x)-f(y)\|\leq L\|x-y\|+\varepsilon$$ The exercise simply states that continous functions over a compact set are "almost" Lipschitz continous. I'm supposed to explain the exercise to someone who doesn't even know about uniform continuity, how can I solve it without explicitly referring to it?

So far the best idea seems to be: $$f(K)$$ is compact in $$\mathbb{R}$$, thus it is of the form $$[f(\bar{x})-r, f(\bar{x})+r]$$ for certain $$x\in K$$ and $$r>0$$. We must use (simple) continuity of $$f$$, so by picking a smart $$\varepsilon$$ we should be able to prove the above statement, but I don't get how to choose such $$\varepsilon$$.

• 'continuous functions over a compact set are "almost" Lipshitz' - I don't agree with this statement. What this exercise shows is that Lipshitz continuity will break down locally, or, put the other way round, the notion is most powerful in local considerations. This is also what is revealed by the proof by contradiction which you got in Qiyu Wen's answer. Dec 8, 2021 at 18:49
• You are right, I should add "globally" in the title so to be a little more specific. Dec 8, 2021 at 18:52

A direct proof, more in line with @Thomas's comment: Fix any $$x,y\in K$$ and consider two cases.
Case 1. $$|x-y|<\delta$$, where $$\delta=\delta(\varepsilon)$$ is the one given by the uniform continuity of $$f$$ in $$K$$.
Here we see that $$|f(x)-f(y)|\leq \varepsilon\leq L|x-y|+\varepsilon$$ for any $$L>0$$ (in other words, the $$\varepsilon$$ "error" is making it so that you gain no information locally).
Case 2. $$|x-y|\geq \delta$$.
Here we have that $$|f(z)|\leq M$$ for every $$z\in K$$ and some $$M>0$$ and so $$|f(x)-f(y)|\leq 2M =(2M/\delta)\delta\leq L|x-y|$$, with $$L=2M/\delta$$ (so in this case the $$\varepsilon$$ is irrelevant, rather you're exploiting only that $$x,y$$ are far apart and $$f$$ is bounded on $$K$$).
Could as well prove by contradiction. Suppose not. Then for some $$\epsilon>0$$ there exist sequences $$(x_k)_{k\geq 1}$$ and $$(y_k)_{k\geq 1}$$ in $$K$$ such that \begin{align} |f(x_k)-f(y_k)|\geq k\|x_k-y_k\|+\epsilon. \end{align} By compactness of $$K$$, we may choose a convergent subsequence of $$(x_k,y_k)$$. Without loss of generality, assume $$(x_k)$$ and $$(y_k)$$ have already been improved to converge to $$x$$ and $$y$$ respectively. Then \begin{align} |f(x)-f(y)|\geq k\|x-y\|+\epsilon \end{align} for all $$k$$, which is impossible. Note that without $$\epsilon$$, it is possible that $$\|x-y\|=0$$. Indeed, a small $$\epsilon$$ is significant (comparing to $$L\|x-y\|$$) only when $$x$$ and $$y$$ are close to each other.