Is there a simple, constructive, 1-1 mapping between the reals and the irrationals?

Map numbers of the form $q + k\sqrt{2}$ for some $q\in \mathbb{Q}$ and $k \in \mathbb{N}$ to $q + (k+1)\sqrt{2}$ and fix all other numbers.


Let $\phi_i$ be an enumeration of the rationals. Let $\eta_i$ be some countable sequence of distinct irrationals; say for concreteness that $$\eta_i = \frac{\sqrt2}{2^{i}}.$$

Then define $$f(x) = \begin{cases} \eta_{2i} & \text{if $x$ is rational and so equal to $\phi_i$ for some $i$} \\ \eta_{2i+1} & \text{if $x$ is irrational and equal to $\eta_i$ for some $i$} \\ x & \text{otherwise} \end{cases}$$

$f$ is now a bijective mapping between the reals and the irrationals.

This mapping was found by Cantor in 1877; I saw it in the paper "Was Cantor Surprised?" by Fernando Q. Gouvêa. (American Mathematical Monthly, 118, March 2011, pp. 198–209.) The construction is described at the middle of page 208.


There's a map between the irrational numbers and the non-eventually zero sequences of natural numbers, namely continued fractions.

We can prove, easily (using the Cantor-Bernstein theorem, anyway), that there is a bijection between $\Bbb R$ and the set of these non-eventually zero sequences of integers.

Now the composition works out just fine as a bijection from $\Bbb R$ and $\Bbb{R\setminus Q}$. But it's not nearly as sleek as MJD's solution.