If $f: \mathbb{R} \to \mathbb{R}$ such that $\displaystyle \lim_{x \to \pm \infty}\sqrt{|x|}(f(x)- cos(x))=1$ is continous, it is uniformly continous. There is a continous function $f: \mathbb{R} \to \mathbb{R}$ such that: $\displaystyle \lim_{x \to \pm \infty}\sqrt{|x|}(f(x)- \cos(x))=1$. Prove that function $f$ is uniformly continous.
I know that there are proofs on this forum that if $g$ is bounded and continous, $g$ is uniformly continous, but I don't know how to apply those to my situation.
Maybe I need to show that if function if $\sqrt{|x|}(f(x)- \cos(x))$ is bounded then $f$ is bounded?
 A: Principle
This is a really lovely problem, a case of "small $x$ , big $x$". The existence of the limit pretty much decides $f(x)$ for large values of $x$, while for small values of $x$ uniform continuity follows from the fact that a continuous function on a compact(same as closed and bounded) interval  is uniformly continuous.
Another point : it is true that $f$ is bounded, but we can actually derive the stronger statement that it is uniformly continuous without requiring this fact.
Let's quickly note that if
$
\sqrt{|x|}{(f(x)-\cos x)} \to 1
$
then for large $x$, $f(x)-\cos x \approx \frac{1}{\sqrt{|x|}}$ i.e. $f(x)$ behaves like $\cos x$ for large enough $x$. Because $\cos(x)$ is uniformly continuous (this is not difficult to prove from its periodicity), we would then expect the same from $f$.
The fundamental quantity to control for uniform continuity is $|f(x)-f(y)|$. So we want to express $f(x)-f(y)$ in terms of the approximation we have obtained. We use a split-into-three inequality , often called an $\frac{\epsilon}{3}$ split. The aim of this inequality is this : $f(x)$ is close to $\cos(x)$, $f(y)$ is close to $\cos(y)$ and $\cos(x)$ is close to $\cos(y)$. It's like : showing $f$ values are close, is transferred to showing that $\cos$ values are close, which we know is true.
This bounds $f(x)-f(y)$ for large enough $x,y$ close enough, which is all we need.
The large $x$ values
Let $x,y \in \mathbb R$ and $\epsilon>0$. Note the inequality :
$$
|f(x)-f(y)| \leq |f(x)-\cos(x)|+|\cos(x) - \cos(y)| + |f(y)-\cos(y)| \tag{1}
$$
which is true for all $x,y$.
First : by uniform continuity of $\cos(x)$, there is a $\delta_1>0$ such that for all $|x'-y'|<\delta_1$ we have $|\cos(x')-\cos(y')| < \frac{\epsilon}{3}$.
Now, for the other two terms we use the limit : let's see what it means. For every $\epsilon'>0$ there is $r'>0$ large enough such that $|x|>r'$ implies $|\sqrt{|x|}(f(x)-\cos(x))-1| < \epsilon'$. That is, $\frac{1-\epsilon'}{\sqrt{|x|}}<|f(x)-\cos(x)| <\frac{1+\epsilon'}{\sqrt{|x|}}$ from the triangle inequality.
This is helpful! Let's take $\epsilon'=1$, and so we get $r'>0$ such that the above happens. In particular, $|f(x)-\cos(x)| < \frac{2}{\sqrt{|x|}}$ for all $|x|>r'$.
But now life is simple : take $r''>0$ such that $\frac{2}{\sqrt{|x|}} < \frac{\epsilon}{3}$ for all $|x|>r''$. Then if $r = \max\{r',r''\}$, $|x|>r$ implies that $|f(x)-\cos(x)| < \frac{\epsilon}{3}$.
Finally, the following is true by $(1)$ :

For all $x,y$ with $|x|,|y|>r$ and $|x-y| < \delta_1$, we have $|f(x)-f(y)| < \epsilon$.

Small values
We never used the fact that $f$ is continuous above, so where does it come into play? For small values. The following result is standard, and hopefully has been studied. If not, I will attach the required links.

A continuous function on a closed and bounded subset of $\mathbb R$ is uniformly continuous.

We apply this, to $f$ restricted to $[-r-\delta_1,r+\delta_1]$ , where $r$ is coming from the previous argument. Of course this is closed and bounded, and $f$ is continuous, hence $f$ is uniformly continuous on this interval. You'll see why I added the $\delta_1$ part in some time.
Thus, for the given $\epsilon$, we have a $\delta_2 >0$ such that for all $|x-y| < \delta_2$ and $x,y \in [-r-\delta_1,r+\delta_1]$ we have $|f(x)-f(y)|<\epsilon$.
Conclusion
To conclude, we need to patch these up. Let $\delta = \min\{\delta_1,\delta_2\}$. If $|x-y| < \delta$, there are three possibilities :

*

*$|x|,|y|<r$. We use the "small values" discussion to conclude that $|f(x)-f(y)|<\epsilon$.


*$|x|,|y|>r$. We use the "large values" discussion to conclude that $|f(x) - f(y)| < \epsilon$.


*One of $|x|,|y| < r$ and other is $>r$. Say $|x|<r$. Then, because $|x-y|<\delta \leq \delta_1$, we get by the triangle inequality that $|x|,|y| < r+\delta_1$, and hence the "small values discussion" applies (can you now see why the interval was extended?) to conclude that $|f(x)-f(y)|<\epsilon$.
Principles to be kept in mind

*

*Using limits to control large values of $f(x)$.


*Using the $\frac \epsilon 3$ method to transfer closeness of $f$ to closeness of $\cos$, allowing us to use the uniform continuity of $\cos$.


*Controlling small values of $x$ using a result about continuity on closed and bounded intervals.


*Extending the interval by a $\delta_1$ factor to "patch" the two arguments together.

Sidenote
Please let me know if you do not know either of these facts, which should have been proved prior to the introduction of this question :

*

*$\cos(x)$ is uniformly continuous on $\mathbb R$.


*A continuous function defined on a closed and bounded interval of $\mathbb R$ is uniformly continuous.
I can direct you to sources, or we can have a conversation about why these are true.
Edit
To see that $\cos$ is uniformly continuous, we note that it has a period of $2 \pi$. Therefore, controlling it in the interval $[0,2\pi]$ is enough. But we again need to do a little "patching", so the interval is not quite $[0,2 \pi]$ for a "small" situation.
More precisely : note that $\cos$ is continuous and $[0,4\pi]$ is uniformly bounded, therefore $\cos$ is uniformly continuous on $[0,4\pi]$. Now, let $\epsilon>0$. There exists a $\delta>0$ such that for $x,y \in [0,4 \pi]$ we have $|x-y|<\delta$ implies $|\cos(x) - \cos(y)| < \epsilon$.
Now, let $x,y$ be arbitrary. We can, by subtracting multiples of $2 \pi$, ensure that there is are $x'$ and $y'$ in $[0,4 \pi]$ such that $x'-x$ and $y'-y$ are integer multiples of $2 \pi$, so that $f(x) = f(x')$ and $f(y) = f(y')$. Now, suppose that $|x-y|<\delta$. Prove that $x',y'$ can be chosen such that $|x'-y'|<\delta$, then by uniform continuity $|f(x) - f(y)| = |f(x')-f(y')| < \epsilon$. So this $\delta$ always works and we are done.
A: This is a streamlined version of Teresa Lisbon's proof.
In fact,
$$\lim_{x\to\pm\infty}\sqrt{|x|}(f(x)-\cos(x))=1
\implies \lim_{x\to\pm\infty}(f(x)-\cos(x))=0.$$
So for any $\epsilon>0$, there exists $X_0>0$ such that
when $|x|\geq X_0$,
$$|f(x)-\cos(x)|<\frac{\epsilon}{3}.$$
The function $\cos x$ is uniformly continuous on $\mathbb{R}$,
there exists $\delta>0$ such that when $|x_2-x_1|<\delta$,
$$|\cos x_2-\cos x_1|<\frac\epsilon 3.$$
For any $x_1,x_2\in[X_0,+\infty)$, when $|x_2-x_1|<\delta$,
$$|f(x_2)-f(x_1)|\leq |f(x_2)-\cos x_2|+|\cos x_2-\cos x_1|+|f(x_1)-\cos x_1|
<\epsilon.$$
So $f$ is uniformly continuous on $[X_0,+\infty)$.

In the same way, we can prove that $f$ is uniformly continuous on $(-\infty,-X_0]$.


By Cantor's theorem, $f$ is uniformly continuous on $[-X_0,X_0]$.

So the function $f$ is uniformly continuous on $\mathbb R$.
