Are limits and absolute values commutative In a homework problem, I am asked to calculate the limit:
$$\lim_{x\rightarrow 0}\left (   x\sin{\frac{1}{x}}\right )$$
In this question the use of the Squeeze theorem is used.
It states that:
$$\lim_{x\rightarrow 0} \left| x\sin{\left( \frac{1}{x}\right )}\right |  =0\Rightarrow\lim_{x\rightarrow 0} x\sin{\left(
 \frac{1}{x}\right )}  =0 $$
Is this the case for all limits, such that
$$\lim_{x\rightarrow a}\left | f(x)  \right |=\left | \lim_{x\rightarrow a}f(x) \right |$$
I can't find any information about this online, and I am confused about how they have found this limit.
 A: We have that by definition
$$-|f(x)|\le f(x)\le|f(x)|$$
therefore in general by squeeze theorem
$$\lim_{x\to x_0}|f(x)|= 0\implies \lim_{x\to x_0}f(x)= 0$$
For the reverse implication by continuity we have
$$\lim_{x\to x_0}f(x)= L\implies \lim_{x\to x_0}|f(x)|= \left|\lim_{x\to x_0}f(x)\right|=|L|$$
which holds for any $x_0,L\in \bar{\mathbb R}$.
A: It is true whenever $\lim_{x\to a}f(x)$ is defined, because the absolute value function is a continuous function.
An obvious counterexample is $$f(x)=\left\{\begin{array}{cc}1&\text{if}\ x\ge0\\
                              -1&\text{if}\ x\ge0\end{array}\right.$$
Then $\lim_{x\to0}f(x)$ doesn't exist. But $\lim_{x\to0}|f(x)|=1$.
A: In this case specifically...
Since $-1 \le \sin x \le 1$
$0 \le |x\sin\frac {1}{x}| \le |x|$
If we were so inclined we could say:
$-|x| \le x\sin \frac 1x \le |x|$
Since it is the nature of the absolute value bracket that $0\le |f(x)|$  Squeezing $|f(x)|$ below and some function that approaches zero, $|f(x)| \le g(x)$ and $\lim_{x\to a} g(x) = 0$ is sufficient to prove $\lim_{x\to a} f(x) = 0$
More generally, if your functions are continuous, you can interchange the limits in the composition of functions.
$\lim_\limits{x\to a} f(g(x)) = f\left(\lim_\limits{x\to a} g(a) \right)$
If $f$ is continuous at $a$ and $\lim_\limits{x\to a} g(a)$ exists.
