Suppose that $f:\Bbb R\to \Bbb R$ is continuous and that $f(x)\to 0$ as $x\to \pm\infty.$Prove that $f$ is uniformly continuous.

Suppose that $f:\Bbb R\to \Bbb R$ is continuous and that $f(x)\to 0$ as $x\to \pm\infty$. Prove that $f$ is uniformly continuous.

Since $f(x)\to 0$ as $x\to \pm\infty$ we have $|f(x)|<\epsilon $ whenever $x<-K$ and $x>K$ where $K>0$.

Also $f$ is uniformly continuous on $[-K,K]$ as the domain is compact.

Hence $f$ is uniformly continuous in $(-\infty,-K)\cup [-K,K]\cup (K,\infty)$.

But how to conclude that $f$ is uniformly continuous on $\Bbb R$ from above as I may chose $x\in (-\infty,-K);y\in [-K,K]$ ,how to conclude that $|f(x)-f(y)|<\epsilon $ from above for a given $\epsilon$?

Please suggest the edits required.


Hint. For $|x|\geq K$ and $|y|\geq K$ then $|f(x)-f(y)|\leq 2\epsilon$.

If $|x|\leq K$, $y>K$ and $|x-y|<\delta$ then $|x-K|<\delta$ and $$|f(x)-f(y)|\leq |f(x)-f(K)|+|f(K)-f(y)|\leq \epsilon+2\epsilon.$$

Can you take it from here?