# Show that there exists a real function $f$ such that $x\to a, |f(x)|\to |L|$ but the limit of $f(x)$ does not exist.

Show that there exists a real function $f$ such that $x\to a, |f(x)|\to |L|$ but the limit of $f(x)$ does not exist.

Just before this problem I was asked to prove the theorem:

If $L=\lim_{x\to a}f(x)$ exists, then $|f(x)|\to|L|$ as $x\to a$.

I was able to prove that just fine which is causing the confusion here. I was under the impression that in order to have $\lim_{x\to a}f(x)=L, f(x)$ must approach L whenever $x$ approaches $a$. Based on that, how do we create an example where the limit does not exist?

• You're not supposed to use the first part to prove the second. The second part is meant to show that the converse of the first part is false. – user180040 Oct 1 '14 at 2:58

The classic Dirchlet Function,

$$f(x) =\left\{\begin{matrix} 1 & x \in \Bbb Q \\ -1& x \notin \Bbb Q \end{matrix}\right..$$

Notice $\lim_{x \to 0} f(x)$ does not exist, but $\lim_{x \to 0} | f(x) | = 1.$

• Or more simply, $x<0$ and $x \geq 0$. – user180040 Oct 1 '14 at 3:11
• @user180040, I just love to complicate things don't I? – IAmNoOne Oct 1 '14 at 3:12

Hint. Take $a = 0$ and $L = 1$, for example. Can you find an example where $|f(x)|$ is constant, but $f(x)$ has no limit at $0$?

• Would this work? Let $f(x)=\large\frac{x+1}{x}$ and $L=-1$ and $a=0$ then $-1=\lim_{x\to 0}\large\frac{x+1}{x}$? Because $\large\frac{x+1}{x+1-1}=\frac{1}{-1}=-1$ And the limit does not exist? – Vincent Oct 1 '14 at 3:04
• No, the limit of $|(x+1)/x|$ at zero is $+\infty$, but $L$ is supposed to be finite. – user180040 Oct 1 '14 at 3:06

The classic Sign Function is also Okay:

$$f(x) =\left\{\begin{matrix} 1 & x>0 \\ 0 & x =0 \\ -1 & x<0 \end{matrix}\right..$$

$\lim_{x \to 0} f(x)$ does not exist, but $\lim_{x \to 0} | f(x) | = 1.$