Is a continuous function locally uniformly continuous?

Assume a function, $f : X \to Y$, mapping between two metric spaces, $X,Y$, is pointwise continuous, i.e. for every $\varepsilon >0$ and $x \in X$ there exists a $\delta>0$ such that $$ \|x-x'\|_X < \delta \implies \|f(x) - f(x')\|_Y < \varepsilon , \qquad \forall x' \in X. $$

Does this imply $f$ is locally uniformly continuous, i.e. for every $x \in X$ there exists a neighbourhood $U \subset X$ such that for every $\varepsilon > 0$ there exists a $\delta > 0$ such that $$ \|x_1-x_2\|_X < \delta \implies \|f(x_1) - f(x_2)\|_Y < \varepsilon , \qquad \forall x_1,x_2 \in U? $$

A positive answer without proof, under the condition that $X$ and/or $Y$ are locally compact, is implied here.


Solution 1:

Let $I_n = \left(\frac1{n+1}, \frac1{n} \right)$ for natural $n$, and let $X = \{0\} \bigcup_n I_n$. Now define $f : X \to\Bbb R$ by $$ x \mapsto \begin{cases} 0, & \text{ if }x=0\\ \frac1n, & \text{ if } x\in I_n \end{cases} $$ This function is continuous but not locally uniformly continuous at $0$.

Solution 2:

If $X$ is locally compact, the result follows from Cantor's theorem. If $X$ is not locally compact, the result is not necessarily true as Stefan's example shows.