# Two question regrading limit from spivak Calculus

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

You say: "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."
That is false. For a counterexample, pick $a=0$ and consider the countable set $\{\frac{1}{n}\vert n\in\mathbb{N}\}$, which has no element which is closest to $0$.
What you can say is that for any fixed q, the set of $\frac {p}{q}$ that are in a finite-size neighborhood of $a$ is finite, which means that there is some $p$ so that $\vert \frac {p}{q}-a\vert \leq \vert \frac {k}{q}-a\vert$ for any $k\in \mathbb{Z}$. From there, you can argue that the interval $(\frac {p}{q},a)$ contains only irrationals and rationals with a denominator larger than $q$ when reduced to lowest terms.
As for the other function (zero on irrationals and the identity on rationals), it is enough to note that the irrationals and the rationals are both dense in $\mathbb{R}$, so any interval will contain both rationals and irrationals.
• When we know that in the interval $(p/q,a)$, only irrationals and rational with greater denominators. Let $\delta$ be the distance from $p/q$ to $a$. For any x in this range, if it's irrational, $f$ is Zero, if it's rational, then $f$ is some $1/k$ for some $k>q$. This when it's irrational, 0 satisfied that f< $\epsilon$ but how do I know that $1/k <\epsilon$ ? – ElleryL Oct 18 '14 at 0:20
You have misunderstood his proof of the first theorem. Given $a\in(0,1)$ and $\epsilon>0$, choose a positive integer $q$ such that $\frac{1}{q} \le \epsilon$. Since $f$ is zero on the irrationals, the only values of $x$ for which $|f(x)-f(0)| = |f(x)-0| < \epsilon$ could be false are therefore the rational numbers whose denominators in lowest terms are less than or equal to $q$. This is a finite set, so among them there is one that is closest to $a$ (you have to treat specially the case where $a$ is one of these rationals). Choose $\delta$ to be this closest distance. Then if $|x-a| < \delta$, it follows that $x$ is none of those rationals, so that $f(x)$ is within $\epsilon$ of $0$.