Showing that $\mathbb{R}$ and $\mathbb{R}\backslash\mathbb{Q}$ are equinumerous using Cantor-Bernstein

Solution 1:

Given any real number $x$, map it to the real number obtained by interleaving the digits of $x$ after the decimal point with the digits of some fixed irrational number, such as $\pi$. The result is an irrational number, since the digits of the resulting will not repeat, and the map is one-to-one because we can recover $x$ from the resulting number.

Solution 2:

Let $f:\mathbb R\to(\mathbb R\setminus \mathbb Q)$ be defined by

$$f(x) = \left\{ \begin{array}{lr} \arctan(x) & \text{if }\ \arctan(x)\not\in\mathbb Q, \\ \arctan(x)+\pi & \text{if }\ \arctan(x)\in\mathbb Q. \end{array} \right.$$

The relevant features of $\arctan$ are that it is bounded and injective (every bounded injective map would work). The relevant features of $\pi$ are that it is irrational and that adding it to the range of $\arctan$ translates outside of that range (every larger irrational would work). The relevant feature of $\mathbb Q$ is that it is a proper subgroup of $\mathbb R$ (every proper subgroup $G$ could replace $\mathbb Q$ if $\pi$ is replaced with a big enough element of $\mathbb R\setminus G$).

Another variant: $f(x)=e^x$ if $e^x$ is irrational, $f(x)=-e^x-\sqrt 2$ if $e^x$ is rational.

(This is similar to my answer to a related question which had $[0,1]$ as the domain.)

Solution 3:

Let $a_i=i\cdot\pi$ for $i\in\Bbb Z/\{0\}$ and enumerate the non-zero rationals $r_1, r_{-1}, r_2, r_{-2}, \ldots$.

For $x$ irrational and not a multiple of $\pi$, map $x$ to $x$.

Map 0 to $a_1$.

Map the rational $r_i$ to $a_{2i}$.

Now you need only find the images of the $a_i$. But note there are infinitely many $a_i$ left in the range which as yet have nothing mapped to them...




More generally:

Let $A$ be an infinite set and let $B\subset A$ be countably infinite with $A\setminus B$ infinite.

Enumerate $B=\{\,b_1,b_2,\ldots\,\}$ and let $C=\{\,c_1,c_2,\ldots\,\}$ be a countably infinite subset of $A\setminus B$.

Define $f:A\rightarrow A\setminus B$ via $$ f(x)=\cases{x,&$x\in A\setminus (B\cup C)$ \cr c_{2i},& $x=b_i$\cr c_{2i-1},& $x=c_i$ }. $$ Then $f$ is a bijection.