Consider the function, with domain $\mathbb{R}$, defined by
$$f(x) = \begin{cases} x & \text{if $x$ is rational,} \\ -x & \text{if $x$ is irrational.} \end{cases} $$
Prove that $\lim_{x\rightarrow 0}f(x)=0.$
Obviously, intuitively, the limit is $0$. But how do I prove this by definition?
My attempt:
Let $\epsilon>0$. Then $\exists\delta > 0$, such that, if $0<|x-0|<\delta$, then $|f(x)-0|<\epsilon$, i.e.,$|x-0|<\epsilon \Rightarrow |x|<\epsilon$.
Then, $$|f(x)-0|<\epsilon \text{ iff } |(x)-0|<\epsilon$$ $$|x|<\epsilon$$ Choose $\delta = \epsilon$ it follows that $|f(x)-0|<\epsilon$.
Just want to see if this fulfills the proof. All critiques welcome.
To show the existence of a limit in our case:
I see some problems. For one, how do you go from $|f(x) - 0| < \epsilon$ to $|0-0| < \epsilon$? Note that this is true only if $x = 0$, whereas you need to show that it is true for $|x -0| < \delta$ for some $\delta$.
Note that if for any $\epsilon > 0$ we pick $\delta = 0.5$, then this won't work out. An example is when $\epsilon = 0.1$ and $x = 0.2$, then while it is true that $|x - 0| < 0.5$, it is not true that $|f(x) - 0| < 0.1$. Therefore, $\delta = 0.5$ does not work for $\epsilon = 0.1$.
In our case, you believe that you intuitively have got the idea of why the limit is zero. The correct proof is as follows:
Please read this proof carefully before attempting comments. I would prefer it if you tell me exactly what the problem is.
EDIT : Okay, thank you for the response, now I will show you what exactly the squeeze theorem means.
So let's say we have three functions, $f(x),g(x),h(x)$. Now, suppose there is some point $a$, such that for $x$ "near" $a$ (that is, for $|x - a| < \delta$ for some appropriately chosen $\delta$), $f(x) \leq g(x) \leq h(x)$ is true. This is like putting the graph of $g$, in between both $f$ and $h$.
Now, suppose that $\lim_{x \to a} f(x)$ and $\lim_{x \to a} h(x)$ both exist and are equal. What does this mean? This means that as $x$ gets closer to $a$, both $f$ and $h$ get closer to the same point. But what does this imply about $g$? $g$, suffocated between $f$ and $h$, must go to the same point, right?
That is, a function squeezed between two other functions going to the same point, also must go to that point. This is the essence of the squeeze theorem, whose result would be that $\lim_{x \to a} g(x)$ exists, and equals the limit for $f$ or $h$.
Here, if we take $g(x) = x$ if $x$ is irrational and $-x$ otherwise, then take $f(x) = -x$ and $h(x) = x$, we see that $g$ squeeze between $f$ and $h$, but both $f$ and $h$ have the limit $0$ at $x = 0$, so $g$ must also have the same limit (no $\epsilon-\delta$ business involved here).
The idea with these tricks, is to eliminate your use of $\epsilon-\delta$ arguments for these situations, and come up with more slick proofs. I hope this will motivate you to read further.