# Proving piecewise function is not continuous [closed]

Let $$f: \mathbb{R} \rightarrow \mathbb{R}$$ be given by $$f(x) = \left\{ \begin{array}{ll} 2x & \quad x \text{ is rational} \\ -2x & \quad x \text{ is irrational } \end{array} \right.$$

Show that $$f$$ is discontinuous at every point $$x_0 \neq 0$$.

My idea to show this is to consider when $$x_0$$ is rational and then consider when it is irrational. Then using the density of the rationals we have sequences which converge to $$x_0$$. Then use The Divergence Criterion for Functional Limits Theorem to finish the proof. Is this along the right track?

• For reference, you'll probably find the proof that the Dirichlet function is discontinuous everywhere somewhat fruitful with this. I haven't tried the proof for myself, but I imagine showing the discontinuity will have a similar flavor, and then you have the special case of $0$ to handle. On the other hand, here's a similar exercise, a bit closer to the flavor of this one: math.stackexchange.com/questions/2369895/… Commented Mar 8, 2019 at 6:32

Let $$x_0 \in \mathbb R$$. Take a sequence $$(r_n)$$ of rational numbers and a sequence $$(s_n)$$ of irrational numbers with $$r_n \to x_0$$ and $$s_n \to x_0$$.
Then: $$f(r_n) =2r_n \to 2x_0$$ and $$f(s_n) =-2s_n \to -2x_0$$.
This shows that $$f$$ is not continuous in $$x_0$$, if $$x_0 \ne 0.$$
• If $f$ is continuous at $x_0$, then we have $\lim f(r_n)= \lim f(s_n)$, hence $2x_0=-2x_0$, thus $x_0=0$.