# density of irrationals and rationals in reals implies rational and irrational sequences

My analysis professor presented us with a proof for the following question.

Suppose $f: \mathbb{R} \rightarrow \mathbb{R}$ is defined as follows, $$f(x) := \begin{cases} 2x & \text{if x \in \mathbb{Q}} \\ x + 3 & \text{if x \in \mathbb{R} - \mathbb{Q}} \end{cases}$$ Find all the points of continunity for $f$.

Suppose $f$ is continuous at some $c \in \mathbb{R}$. By density, there exist sequences $(x_n), (y_n) \in \mathbb{R}$ of rationals and irrationals converging to $c$. Then, $$\lim_{n \rightarrow \infty} f(x_n) = \lim_{n \rightarrow \infty} f(y_n) = f(c)$$ which implies $$f(c) = \lim_{n \rightarrow \infty} (2x_n) = \lim_{n \rightarrow \infty} (y_n + 3) \implies 2c = c + 3 \implies c = 3$$

This problem is fairly straight forward if you understand the Sequential Criterion for Continuity.

Which leads to my question, how does the density theorem imply the existence of these two sequences? Maybe the straight forward question is, how would we formally construct these two sequences using the density theorem?

My intuition says, since $\mathbb{Q}$ and $\mathbb{R - Q}$ are infinite on every open interval there exist an infinite sequence of rationals and irrationals that converge to $c$.

which seems terribly informal.

• For any $n$ consider $x_n,y_n\in (c-|c|/n,c+|c|/n)$, if $c\ne 0.$ If $c=0$ then consider $x_n,y_n\in (-1/n,1/n).$ – mfl Jul 15 '17 at 23:16

You can construct the sequence of Rationals by using the Decimal expansion representation of the number to construct a sequence $b_k$ converging to $a$. For the Irrational sequence, you can , e.g., use the Decimal expansion + , say, $\sqrt3/n$. Then, for a number $a$, use its expansion : $$a=a.a_0a_1....a_k.. \rightarrow b_0:=a, b_1:=a.a_0,....b_k:=a.a_0a_1...a_k,....$$, for the irrational one, use, e.g:

$$a+ \sqrt3/n \rightarrow b_0:=a+ \sqrt3, b_1:= a.a_0+ \sqrt3/2,......b_k:= a.a_0a_1...a_k +\sqrt3/k,....$$

For fans of the non-use of the Axiom of Choice:

(I). For $c\in \mathbb Q :$ For $n\in \mathbb N$ let $x_n=c+2^{-n}$ and $y_n=c+2^{-n-1/2}.$

(II). For $c\in \mathbb R$ \ $\mathbb Q:$ For $n\in \mathbb N$ let $y_n=c(1+2^{-n}).$

For $n\in \mathbb N$ let $f(n)$ be the least $m\in \mathbb N$ such that $\phi \ne (c,c+2^{-n})\cap \{\frac {a}{m}:a\in \mathbb Z\}$

and let $g(n)$ be the least $b\in \mathbb N$ such that $\phi \ne \left\{-\frac {b}{f(n)},\frac {b}{f(n)}\right\}\cap (c,c+2^{-n})$ and let $$x_n=\max \left(\left\{-\frac {g(n)}{f(n)},\frac {g(n)}{f(n)}\right\}\cap (c,c+2^{-n})\right).$$