# Connections between two definitions of locally Lipschitz mapping

Let's consider two following definitions of locally Lipschitz mapping.

Let $f: D\subset \mathbb R^n \rightarrow \mathbb R$.

We say that $f$ is localy Lipschitz in 1. sense, if for each $a\in D$ there exist a neighbourhood $U_x$ of $a$ and a constant $K_a>0$ such that $$|f(x)-f(a)| \leq K_a \|x-a\|\textrm{ for } x\in U_x.$$

We say that $f$ is localy Lipschitz in 2. sense, if for each $a\in D$ there exist a neighbourhood $U_x$ of $a$ and a constant $K_a>0$ such that $$|f(x)-f(y)| \leq K_a \|x-y\|\textrm{ for } x,y \in U_x.$$

If $f$ is locally Lipschitz in the 2.sense then also is in the 1. sense. Are these conditions equivalent on compacts in $D$ ?

No. Consider $f(x)=x\sin(\frac{1}{x}), x \in (0,1]$ and $f(0)=0$. Then $f$ is locally Lipschitz in 1 . sense on compact $[0,1]$. At $x=0$, it's because $\sin$ is bounded. For $x \in (0,1]$, $f$ is Lipschitz due to bounded derivative.
But $f$ is not Lipschitz in 2 sense in any neighborhood of $0$.
In fact, consider $a_n=\frac{1}{(2n+\frac{1}{2})\pi}$,$b_n=\frac{1}{(2n+1)\pi}$, then $$|\frac{f(a_n)-f(b_n)}{a_n-b_n}|=4n+2 \rightarrow \infty \quad \text{as} \quad n \rightarrow \infty$$
And $a_n, b_n\rightarrow 0 \quad \text{as} \quad n \rightarrow \infty$.