I have this problem I'm working on:
Problem: Suppose $f: \mathbb{R} \rightarrow \mathbb{R}$ is a continuous function such that $\lim_{x \to \infty} f(x) = 0$ and $\lim_{x \to -\infty} f(x) = 0.$ Prove that $f$ is uniformly continuous on $\mathbb{R}$.
Attempt: Since $\lim_{x \to \infty} f(x) = 0$, there exists a $N_1 \in \mathbb{R}$ such that $\forall x \in \mathbb{R}$ we have that $|f(x) - 0 | = |f(x)| < 1$ whenever $x > N_1$. Similarly, since $\lim_{x \to - \infty} f(x) = 0$, there exists a $N_2 \in \mathbb{R}$ such that $\forall x \in \mathbb{R}$ it holds that $|f(x)| < 1$ whenever $x < N_2$.
Without loss of generality we can assume that $N_2 < N_1$. Since $[N_2, N_1]$ is a bounded and closed interval, and since $f$ is continuous there, we also know it is uniformly continuous on that interval.
Now it is left to show that $f$ is also uniformly continuous outside that interval. I tried proving this by using the definition of uniform continuity, but I don't know how to pick my $\delta$. Also tried proving Lipschitz continuity, but didn't succeed either.
Any help for this part would be appreciated.
From scratch:
Take $M>0$ so large that $\vert f(x)\vert <\epsilon/3$ whenever $x\leq M$ or $x\leq-M$.
$f$ is uniformly continuous on the compact set $[-M,M]$ so there is a $\delta >0$ s.t. if $x,y\in [-M,M]$ then $\vert x-y\vert<\delta \Rightarrow \vert f(x)-f(y)\vert<\epsilon/2$.
If $x,y\in (-\infty, -M)$, then $\vert f(x)-f(y)\vert\leq \vert f(x)\vert +\vert f(y)\vert<2\epsilon/3<\epsilon$. A similar result holds for for $x,y\in (M,\infty )$.
If $x\in (-\infty, -M), y\in [-M,M]$ and $\vert x-y\vert <\delta,\ $then $\vert-M-y\vert <\delta$ and so
$\vert f(x)-f(y)\vert<\vert f(x)-f(-M)\vert+\vert f(-M)-f(y)\vert\leq \epsilon/3+\epsilon/2<\epsilon$. A similar result holds for $x\in (M,\infty), y\in [-M,M]$