continuity, rational numbers and real numbers Define $f: \mathbb{R} \rightarrow \mathbb{R}$ by 
$ f(x) = \left\{ \begin{array}{ll}
         |x| & \mbox{if $x \in \mathbb{Q}$}\\
        -|x| & \mbox{if $x \notin \mathbb{Q}$}.\end{array} \right. $
Prove that $f$ is continuous at $x=0$ but not continuous at other points. 
I can't show the latter part, can anyone helps?
 A: You should know there's a rational and an irrational number in every interval $(x-\frac1n,x+\frac1n)$ both different from $x$.
Use this to construct a sequence of rational numbers $a_n\to x$ such that $f(a_n)\to|x|$ and a sequence of irrational numbers $b_n\to x$ such that $f(b_n)\to-|x|$.
This contradicts the existence of a limit if $x\ne0$.
A: Hint:
take $\epsilon = \frac {|x|}2$ in the definition of continuity.
details:
Assume that $f$ is continuous in $x\in \Bbb Q$,
hence for $y$ close to $x$ you should have 
$$
f(y) \ge |x| -  \epsilon >0
:$$ this is not true for $y\notin \Bbb Q$, and 
if  $f$ is continuous in $x\notin \Bbb Q$,
$$
f(y) \le -|x| +  \epsilon <0
:$$
this is not true for $y\in \Bbb Q$.
A: 1) We shall show that $\lim_{x\to 0}f(x)=0$. 
Given $\varepsilon>0$, let $\delta = \varepsilon$. So for $|x|< \varepsilon$ we have $|f(x)|=||x||=|x|<\varepsilon$ if $x\in \mathbb{Q}$, and $|f(x)|=|-|x||=|x|<\varepsilon$ if $x\in \mathbb{R}\setminus \mathbb{Q}$ as desired.
2) We shall show that $f$ is not continuous for $a\not=0$.
It will suffice to show that the limit  for $a\not=0$ does not exist. Suppose to the contrary that $\lim_{x\to a}f(x)=L$ and $a\not=0$. Let $\varepsilon= |a|/2$. Then there is a $\delta>0$ such that $|f(x)-L|< \varepsilon$ whenever $0<|x-a|<\delta$. For $x$ rational we have $-\varepsilon<|x|-L<\varepsilon$ and for $x'$ irrational $-\varepsilon<|x'|+L< \varepsilon$.
Let $0<|x-a|<\min(\varepsilon,\delta)$. Then $|x|>|a|/2$. Let $x$ rational and $x'$ irrational in the neighborhood. Then 
$$|a|<|x|+|x'|+L-L=(|x|-L)+(|x'|+L)< 2\varepsilon=|a|$$
a contradiction.
