Need a hint on problem 5-*20 from Spivak Prove that if $f(x) = x$ for rational $x$, and $f(x) = -x$ for irrational$ x$, then $\lim_{x \to a}f(x)$ does not exist if a $\ne$ 0.
 A: Hint: Construct a sequence of fractions $a_n$ with the limit a. Then take the same sequence and add $\sqrt{2}/n$ to it. you might have to look at a rational and a irrational also.
So If a is rational then $a_n=a+1/n\in Q$ and $b_n=a+\sqrt{2}/n\in R\wedge $ not $\in Q$. The limit is different for both cases. Hence, the limit does not exist. Similarly for a irrational. But you might need to consider the fractional approximants to your irrational number for $a_n$.
A: In case $a$ is rational, the two sequences mentioned by user MrYouMath in his answer show $\lim_{x \to a}f(x)$ does not exist.
Now suppose $a$ is irrational. Then the sequence $a_n=a+1/n$ is a sequence of irrationals which approach $a.$ But a bit more work is needed to make a sequence $b_n$ of rationals which approach $a.$ So let $q$ be any positive integer. Since $a$ is irrational there will then be a unique integer $p$ with
$$p < qa < p+1. \tag{1}$$
Dividing by $q$ then gives $p/q<a<(p+1)/q.$ Since the difference of the left and right sides here is $1/q,$ we now have
$$|a-\frac pq|<\frac1q. \tag{2}$$
So we can define for each $n$ the rational $b_n$ to be this $p/q$ where $q=n$ and $p$ comes from $(1).$ Since then $n \to \infty,$ and $q=n,$ we see that as desired $b_n \to a$ as $n \to \infty. $ Thus for this case in which $a$ is irrational, we also have sequences of both rationals and irrationals which approach $a$ and may conclude $\lim_{x \to a}f(x)$ does not exist in this case also [assuming $a \neq 0$].
A: My hint is that every interval $(\delta -a, \delta + a)$ of $\mathbb{R}$ contains a rational and irrational number.
A: First, consider this useful lemma. If $\lim_{x \to a} f(x)$ exists and equals $L$, then there is a $\delta$ such that for all $x,y \in (a-\delta,a+\delta)$, $|f(x) - f(y)| < \epsilon$. 
To prove this, fix $\epsilon$ and note that for some $\delta$ with $x,y \in (a-\delta,a+\delta)$ we have $|L -  f(x)|<\frac{\epsilon}{2}$ and $|f(y) - L|<\frac{\epsilon}{2}$. The result follows from the triangle inequality. 
Now take $c >0$ and note that the $f[(c-\delta, c+\delta)] \subset  (c-\delta, c+\delta) \ \cup (-c-\delta, \delta - c)$ and by density $f$ takes on values in both sets for all $\delta$. But then choosing $\epsilon$ less than the difference between the respective $\inf$ and $\sup$ of the two sets, namely $(c-\delta) - (\delta - c) = 2(c-\delta)$ contradicts the lemma, again for every choice of $\delta$. It is analogous for $c<0$. 
