Uniform continuity general case Let $f: \mathbb{R} \rightarrow \mathbb{R}$ be a continuous function defined on (all of) the real axis. Assume that $$f(x) \rightarrow a, \quad \text{for } x \rightarrow -\infty$$ $$f(x) \rightarrow b, \quad \text{for } x \rightarrow \infty$$ for some real numbers $a,b$. Show/explain that for every $\epsilon >0$ there exists a $M >0$ such that $$\left | f(x)-f(y) \right |<\varepsilon$$ given $x,y \geq M$. Furthermore, show that $g$ is uniformly continuous.
Attempt (or rather thoughts)
I am fairly sure that I have gotten the solution down for the first part of the question as it can be solved directly form the definition of a limit at infinity.
Now, I have absolutely no idea on how to show that the function is uniformly continuous as I am not confident at all in the approach of these sort of problems. I would have to use my the fact given above that I have shown but, again, no idea how to approach such a problem as I seem to be missing a general approach and lack of properties. I really need some explanation as to what is going on.
 A: $$
\forall\varepsilon>0 \, \exists \delta>0\, \forall x,y \, \Big( |x-y|<\delta \longrightarrow |f(x)-f(y)|<\varepsilon\Big).
$$
The point is that $\delta$ does not depend on $x$ and $y.$
Given $\varepsilon>0,$ there exists $M_1$ such that for $x,y>M_1$ you have $|f(x)-f(y)|<\varepsilon,$ and for the same reason there exists $M_2$ such that for $x,y<M_2$ you have $|f(x)-f(y)|<\varepsilon.$
A theorem asserts that a continuous function on a compact set is uniformly continuous. And $[M_2,M_1]$ is a compact set.
A: You have to consider different cases. Let's take an example: $f:[-2,2] \rightarrow \mathbb{R}$ defined by $f(x)=x^2$, now consider $f:[-1,1]\rightarrow \mathbb{R}$ and choose $\epsilon=1$, then if we take $\delta=\frac{1}{2}$ see that whenever $x,y \in [-1,1]$ and $|x-y|<\frac{1}{2}$, $|f(x)-f(y)|<1$. But if you take $x=0.9,y=1.35$, then also $|x-y|=0.45<\frac{1}{2}$ but $|f(x)-f(y)|=1.0125>1$. So one $\delta$ doesn't work for all $|x-y|<\delta$.
For given $\epsilon>0~\exists~M_1,M_2 >0$ such that $|f(x)-a|<\frac{\epsilon}{2}$ whenever $x<-M_1$ and $|f(x)-b|<\frac{\epsilon}{2}$ whenever $x>M_2$. Let $M=\max\{M_1,M_2\}$.
So there will be the following cases:
(i) $x,y<-M$, (ii) $x,y>M$, (iii) $x,y \in [-M,M]$, (iv) $x \in [-M,M],~y<-M$, (v) $x \in [-M,M],~y>M$ and (vi) $x<-M,~y>M$, (where $M>0$ is what we got from the definition of limit at infinity).
(i) Let $x,y<-M(\leq-M_1)$, then $|f(x)-f(y)|=|f(x)-a-f(y)+a|\leq |f(x)-a|+|f(y)-a|<\epsilon$. So no specific role of $\delta $ here.
(ii) is done similarly.
From (iii) for chosen $\epsilon>0$ we get a $\delta_1>0$ such that $|f(x)-f(y)|<\epsilon$ whenever $|x-y|<\delta_1$ (using the fact that continuous function on compact set is uniformly continuous).
For (iv) we have to the continuity of $f$ at $-M$, for chosen $\epsilon>0~~~\exists~\delta_2>0$ such that $|f(x)-f(-M)|<\frac{\epsilon}{2}$ whenever $|x-(-M)|<\delta_2$. For $|f(x)-f(y)|$ to be small enough $x,y$ can't be too far apart and $x,y$ should belong to $(-M-\frac{\delta_2}{2},-M+\frac{\delta_2}{2})$. Now if we take $|x-y|<\frac{\delta_2}{2}$ then since $|x-(-M)|\leq |x-y|+|y+M|<\frac{\delta_2}{2}+\frac{\delta_2}{2}=\delta_2$ and similarly $|y-(-M)|<\delta_2$ we get $|f(x)-f(y)|<\epsilon$ whenever $|x-y|<\frac{\delta_2}{2}$.
For (v) similarly using continuity of $f$ at $M$ we get a $\frac{\delta_3}{2}$.
Note that we have to find a $\delta>0$ for which the definition of uniform continuity is satisfied. So we take $\delta =\frac{1}{2}\min\{\delta_1, \frac{\delta_2}{2}, \frac{\delta_3}{2},2M\}$ (if certain $\delta$ works, then so will anything less than that $\delta$, so multiplying by 0.5 doesn't violate anything! It just helps with the strict inequalities. You may not take it if you wish. Actually we could have also simply taken $\epsilon$ instead of $\frac{\epsilon}{2}$ in the beginning.). Because in the case of (vi) $|x-y|\geq 2M$ and $\delta<2M$ (why strict inequality?!), we don't have to actually consider (vi).
All in all now $|x-y|<\delta\Rightarrow |f(x)-f(y)|<\epsilon$.
