Given the function $$f(x) = \left\{ \begin{array}{l l} 0 & \quad \text{if $x$ is irrational}\\ 1/q & \quad \text{if $x = \frac{p}{q}$ in lowest terms(no common factor)} \end{array} \right.$$
Prove that for any number $a$, with $0<a<1$, the function $f$ approaches 0 at $a$.
Spivak's way of proving is : since all rational number in form of $\frac{p}{q}$ is countably infinite. Thus, there exist a $\frac{p}{q}$ that is closest to $a$. Then, the interval $(\frac{p}{q},a)$ only contains irrational. Let $\delta$ be $|\frac{p}{q} - a|$. If $0<|x-a|<\delta$, then $|f(x)-0|< \epsilon$.
My question here is that about another similar function: Given function $$f(x) = \left\{ \begin{array}{l l} 0 & \quad \text{if $x$ is irrational}\\ x & \quad \text{if $x$ is rational} \end{array} \right.$$
Prove that the function doesn't approach any number at $a$, if $a$ is not $0$.
here is the question: it seems to me that this function approaches to $0$ for any given $a$.
Just simply the same way of proving from the previous one.
let $\delta =|\frac{p}{q} - a|$, then for If $0<|x-a|<\delta$, then $|f(x)-0|< \epsilon$.
basically exact the same thing, I don't understand why it works on the previous example, but not the second one.
The only way to explain it, i must be misunderstand the proof of the first example from the beginning. If that's the case. Can anyone help me ?
Thanks