# Let $f(x) = 1$ for rational numbers $x$, and $f(x)=0$ for irrational numbers. Show $f$ is discontinuous at every $x$ in $\mathbb{R}$

I am working on this proof, and wanted someone to check it and to help me understand what is happening in case (ii). The proof:

Let $f(x) = 1$ for rational numbers $x$, and $f(x)=0$ for irrational numbers. Show $f$ is discontinuous at every $x$ in $\mathbb{R}$.

We will consider two cases.

(i) $x \in \mathbb{Q}$

Consider the sequence $x_n = x + \frac{\sqrt{2}}{n}$. We have that $(x_n) \rightarrow x$, yet $x_n$ is irrational $\forall \ n$. $\Rightarrow x_n \ \in \ \mathbb{Q}$

$\Rightarrow x_n - x \in \ \mathbb{Q}$.

$\Rightarrow n(x_n-x) = \sqrt{2} \in \mathbb{Q}$.$\ \rightarrow \leftarrow$

This is a contradiction, therefore we have that $f(x_n) = 0 \ \forall \ n \Rightarrow \lim f(x_n) =0 \neq 1 =f(x)$.

Therefore, $f(x)$ is not continuous at any $x \in \mathbb{Q}$.

(ii) $x \not\in \mathbb{Q}$

Given the density of the rationals, there exists a subsequence of rational numbers that must converge to $x$. Call this subsequence $(x_{n_r})$. Therefore, we have that:

$f(x_{n_r})=1 \ \forall \ n \Rightarrow \lim f(x_{n_r}) = 1 \neq 0 = f(x).$

$\therefore \ f(x)$ is not continuous at any $x \in \mathbb{Q}$.

By cases (i) and (ii), we have that $f(x)$ is not continuous at any $x \in \mathbb{R}$.

For case (i), I used the hint in the back of my text book to generate a sequence I could work with. Part (ii) is almost identical to the solution in my text- I don't fully understand why we are using the denseness of the rationals, rather than just working with the sequence made in case (i).

• It is pretty easy to prove using the topological definition of continuity. Are you familiar? Oct 11, 2015 at 22:20
• @uniquesolution That's a pretty harsh thing to say to aomeone trying to learn and showing effort. Oct 12, 2015 at 2:00
• @TylerHG- I am not familiar. I'll look into for my own studies, though I expect my prof will want us to stick with our sequential definitions and/or the epsilons and deltas... Oct 12, 2015 at 2:07
• @YoTengoUnLCD I certainly thought so... my question was not far removed from the questions s/he has answered in the past. Ah well. Oct 12, 2015 at 2:19

When $x$ is irrational, the sequence defined in case (i) might not consist of only rationals. For example, if $x = \sqrt 2$, then $x + \frac {\sqrt 2} n = \frac {n+1} n {\sqrt 2}$ is irrational. (It will converge to $x$, but it doesn't accomplish what's needed.)

For (ii), you need a sequence of rationals converging to the irrational $x$. In theory, we already know one: consider the decimal expansion of $x$. When $x$ is irrational, the sequence is necessarily infinite, doesn't eventually repeat itself forever. Suppose $$x = m + 0.d_1 d_2 \dotso$$ where $m$ is an integer. Let $$x_n = m + 0. d_1 \dotso d_n$$ In other words, $x_n$ is the decimal representation of $x$ cut off at the $n^{th}$ digit after the decimal point ($x_0 = m$). Then every $x_n$ is rational, and: $$lim_{n \to \infty} x_n = x$$

• Ok. My professor actually suggested $x + \frac{\pi}{n}$ instead, though that would yield the same problem, wouldn't it? Oct 12, 2015 at 2:05
• Using $\pi$, some of the terms of the resulting sequence might be rational (suppose $x = k\pi)$. A little extra verbiage is needed to show that the sequence is eventually all rationals. I emended my answer to give a more concrete example of a sequence that works. Oct 12, 2015 at 2:40
• Thank you- that was helpful for part (ii). So, this would suffice to serve as a better way to show the second case (instead of trying to use the denseness argument), correct? Oct 12, 2015 at 2:48
• Actually yes, I thnk so. The argument using density of the rationals is certainly true, but it's nonconstructive, in that it just plucks a sequence $x_n$ out of thin air, The sequence I gave is more constructive in flavor: if you can say anything explicit about the irrational $x$ (e.g. how to compute it, to within any degree of precision), then we can figure out how to convert that to our standard sequence of approximations given by the decimal representation. Oct 12, 2015 at 2:59
• Thanks, BrianO. I often struggle with when we really need to construct something vs when we can just use pick something that will suffice for the proof. Oct 12, 2015 at 3:43

Rationals and irrationals are both dense in the real numbers. If we pick $x\in\mathbb{Q}$ then there is a sequence of irrationals converging to $x$, thus proving discontinuity of $f$ at $x$. If $x\notin\mathbb{Q}$ then there is a sequence of rationals...(I'm sure you can now formally make your complete proof)

• Ah, gotcha. Thanks, that makes sense. Oct 12, 2015 at 2:06