TITLE: How does the existence of a limit imply that a function is uniformly continuous
QUESTION [47 upvotes]: I am working on a homework problem from Avner Friedman's Advanced Calculus (#1 page 68) which asks

Suppose that $f(x)$ is a continuous function on the interval $[0,\infty)$. Prove that if $\lim_{x\to\infty} f(x)$ exists (as a real number), then $f(x)$ is uniformly continuous on this interval.

Intuitively, this argument makes sense to me. Since the limit of $f(x)$ exists on $[0,\infty)$, we will be able to find a $\delta > |x_0 - x_1|$ and this implies that, for any $\epsilon>0$, we have $\epsilon > |f(x_0) - f(x_1)|$ (independent of the points chosen). I am aware that the condition of uniform continuity requires that $\delta$ can only be a function of $\epsilon$, not $x$. 
What information does the existence of a real-valued limit provide that implies $f(x)$ is uniformly continuous on this interval?

REPLY [2 votes]: This result is deeper and  has a simpler proof in general Euclidean spaces or general metric spaces. In fact let's  the result for Euclidean spaces.

Lemma If $f:\mathbb R^d\to \mathbb R$ is a continuous function such that $\lim_{|x|\to\infty } f(x) = L$ with $L\in\mathbb R$, then $f$ is uniformly continuous on $\mathbb R^d.$ 

Proof of the Lemma
Let $\varepsilon >0$. We want to show there is $\delta>0$ such that $ |f(x)-f(y)|\le \varepsilon$ whenever $|x-y|\le \delta$.
But since $\lim_{|x|\to\infty } f(x) = L$  we know that there is $R>0$ such that 
$$
\begin{equation}\label{eq1}\tag{I}|f(x)-L|\le \varepsilon/2 \qquad\text{whenever}\qquad |x|\ge R\end{equation}
$$
But since $f$ is continuous it is uniformly continuous on the compact $$\bar{B}(0,R+1) = \{x\in\mathbb R^d: |x|\le R+1\}$$

Hein Borel result  Every function $f$ continuous on compact set is therein uniformly continuous.

hence there exists $0<\delta<1$ such that for every 
\begin{equation}\label{eq2}\tag{II}
\text{$x,y\in \bar{B}(0,R+1)$ with $|x-y|<\delta$ we have $ |f(x)-f(y)|\le \varepsilon /2$}
.
\end{equation}

Now let $x,y\in \mathbb R^d$ such that $|x-y|<\delta$

If $x,y\notin \bar{B}(0,R)$ i.e $|x|>R$ and $|y|>R$ by $\eqref{eq1}$ it readily follows that 
  $$|f(x)-f(y)|\le|f(x)-L|+|f(y)-L|\le \varepsilon .$$
If $x,y\in \bar{B}(0,R)\subset\bar{B}(0,R+1)$ then \eqref{eq2} yields
  $$|f(x)-f(y)|\le \varepsilon .$$
If $x \in \bar{B}(0,R)$ and $y\notin \bar{B}(0,R)$ then $y\in \bar{B}(0,R+1)$ indeed
  $$|y|\le|x|+|x-y|\le R+\delta <R+1$$
  thus \eqref{eq2} yields 
  $$|f(x)-f(y)|\le \varepsilon .$$


In any case we have  $ |f(x)-f(y)|\le \varepsilon$for all $x,y\in\mathbb R^d$ such that $|x-y|\le \delta$. Which prove the uniform continuity.

The case where $ \mathbb R^d$ is replaced by a locally compact metric space $(X,d)$ analogious reason lead to same conclusion. except that, $ f:(X,d)\to \mathbb R$ vanish at infinty means: for a given $ \varepsilon > 0$ there exists a Compact subset $K$ of $X$ such that $|f(x)|\le \varepsilon $ for every $x\in X\setminus K.$ Here the ball $\bar{B}(0,R+1)$ is replaced by the compact set . $$K_1 = \{x\in X: d(x,K)\le 1\}$$