Continuous function with $\lim_{x \rightarrow + \infty}f(x)=0$ and $\lim_{x \rightarrow - \infty}f(x)=0$ is uniformly continuous Suppose that $f: \mathbb{R} \rightarrow \mathbb{R}$ is a continuous function with $\lim_{x \rightarrow + \infty}f(x)=0$ and $\lim_{x \rightarrow - \infty}f(x)=0$. Show that $f$ is uniformly continuous on $\mathbb{R}$
My attempt: Take a random $\epsilon >0$. As  $\lim_{x \rightarrow + \infty}f(x)=0$, there exists a $M_{1} \in \mathbb{R}$ so that for every $x \in \mathbb{R}$ with $x > M_{1}$ it holds that $|f(x)-0|< \epsilon$. As  $\lim_{x \rightarrow - \infty}f(x)=0$, there exists a $M_{2} \in \mathbb{R}$ so that for every $x \in \mathbb{R}$ with $x < M_{2}$ it holds that $|f(x)-0|< \epsilon$. Now take $M \geq \max \{|M_{1}|,|M_{2}|\}$. Then surely will $|f(x)|< \epsilon$ for every $x \in \mathbb{R} \backslash [-M,M]$.
Now I'm not sure how to go on from this. I do know that $f$ is uniformly continuous on the interval $[-M,M]$ because it is continuous. But how can I expand this to $]- \infty,+\infty[$ ?
 A: For every $|x| \ge M$.. $|f(x)| < \epsilon/3$. Then choose $\delta$ which works for $[-M,M]$ and take $x,y$ such that $|x-y| < \delta$. If $x$ and $y$ are both in $[-M,M]$ then nothing to prove and if both are outside $[-M,M]$ also nothing to prove. So without losing generality let us say $y<-M <x$. Then $|x-(-M)| < \delta$ and $|f(x) - f(-M)| < \epsilon/3$. But $|f(x)-f(y)| \le |f(x) - f(-M)| + |f(-M)| + |f(y)| < \epsilon/3 + \epsilon/3 + \epsilon/3 = \epsilon$.
A: hint
WLOG, you suppose that $f $ is continuous at $[0,+\infty) $ with $\lim_{x\to+\infty}f (x)=0$.
Given $\epsilon>0$
$f $ goes to zero then $\exists M>0$ st for all $x>M , |f (x)|<\epsilon/2$
and for $x,y>M $
$$|f (x)-f (y)|\leq |f (x)|+|f (y)|<\epsilon $$
on the other hand, $f $ is continuous at the compact $[0,M] $ thus it is uniformly continuous at $[0,M] $ and
$\exists \eta_1>0 \;$ st for $x,y\in [0,M] $
$$|x-y|<\eta_1\implies |f (x)-f (y)|<\epsilon .$$
remains the case where $0\le x<M $ and $y>M $.
I let you thinking about continuity at $M $ to find $\eta_2$.
A: After finding a compact interval $[-M, M]$ by the convergence assumption and being given an $\varepsilon > 0$, by convergence we have $|f(x)-f(y)| < \varepsilon$ for all $x,y$ outside $[-M, M]$; let $\delta_{1}$ be a corresponding bound for $|x-y|$. We have the inequality again by uniform continuity for all suitable $x,y \in [-M,M]$; let $\delta_{2}$ be a corresponding bound for $|x-y|$. By continuity at $M$ in particular, there is some $\delta_{3} > 0$ such that $|x-M|, |x+M| < \delta_{3}/2 =: \delta_{3}'$ implies $|f(x) - f(M)|, |f(x) - f(-M)| < \varepsilon/2$, implying 
$$
|f(x)-f(y)| = |f(x) - f(M) - f(y) + f(M)|\ \ (\text{resp.}\ |f(x) - f(-M) -f(y) + f(-M)|) \leq |f(x) - f(M)| + |f(y) - f(M)|\ \ (\text{resp.}\ |f(x)-f(-M)| + |f(y) - f(-M)|) < \varepsilon.
$$ 
Noting that 
$$
|x-y| = |x-M-y+M|\ \ (\text{resp.}\ |x+M-y-M|)\\ \leq |x-M| + |y-M|\ \ (\text{resp.}\ |x+M| + |y+M|) < \delta_{3}',
$$
 we have, if $x < -M < y$ or $x < M < y$, that the number $\delta_{3}'$ is such that $|x-y| < \delta_{3}'$ implies $|f(x) -f(y)| < \varepsilon$. All in all, the number $\delta := \min \{ \delta_{1},\delta_{2},\delta_{3}'\}$ is such that $|x-y| < \delta$ implies $|f(x)-f(y)| < \varepsilon$; we are done.
A: Given $\epsilon >0$, take $n>0$  such that  $|x|\geq n\implies |f(x)|<\epsilon /3.$
Since $f|_{[-n,n]}$ is uniformly continuous, take $\delta\in (0,n)$ such that $|f(x)-f(y)|<\epsilon /3$ whenever $x, y \in [-n,n]$ with $|x-y|<\delta.$
Now when $|x|$ and |$y|$ are each at least $n,$ we have $|f(x)-f(y)|\leq |f(x)|+|f(y)|<2\epsilon /3.$ 
If $|x|\leq n\leq |y|$ and $|x-y|<\delta$ then, as $\delta <n,$ we have either (i) $y\leq -n\leq x< y+\delta<n$  or  (ii) $-n<x\leq n \leq y<x+\delta.$
For (i) we have $\{x,-n\}\subset [-n,n]$ with $|x-(-n)|<\delta,$ so $$|f(y)-f(x)|\leq$$ $$\leq  |f(y)-f(-n)|+|f(-n)-f(x)|\leq$$ $$\leq |f(y)|+|f(-n)|+|f(-n)-f(x)|<\epsilon.$$ For (ii) we have $\{x, n\}\subset [-n,n]$ with $|x-n|<\delta,$ so $$|f(y)-f(x)|\leq$$ $$\leq |f(y)-f(n)|+|f(n)-f(x)|\leq$$ $$\leq |f(y)|+|f(n)|+|f(n)-f(x)|<\epsilon.$$
