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

I need to prove that $\mathbb{R}\backslash\mathbb{Q} \sim \mathbb{R}$

Using Cantor-Bernstein, need to show an injection from $\mathbb{R}\backslash\mathbb{Q}$ to $\mathbb{R}$ and from $\mathbb{R}$ to $\mathbb{R}\backslash\mathbb{Q}$.

$\mathbb{R}\backslash\mathbb{Q}$ is a subset of $\mathbb{R}$ so only need to show injection from $\mathbb{R}$ to $\mathbb{R}\backslash\mathbb{Q}$ to complete the proof.

Possible injection:
$f:\mathbb{R}\to \mathbb{R}\backslash\mathbb{Q}$ defined as $f(x) = \pi x$ if $x$ is not a multiple of $\pi$; otherwise $f(x) = \sqrt{2} x$.

Not sure if $f$ actually is an injection...

-
What do you mean by "multiple of pi"? – Najib Idrissi Feb 5 '12 at 15:09
You may want to look at the decimal expansions. As a hint, it is easier to work with (0,1) and then extend that to a proof for all of R (can you think of a continuous map which sends (0,1) to all of R?). Any number in (0,1) has a decimal expansion $.a_1 a_2 a_3...$ which you can manipulate to force the output to be irrational. – Chris Janjigian Feb 5 '12 at 15:13
Actually your map is neither an injection nor is its image contained in $\mathbf R\setminus\mathbf Q$. The basic idea of making place for the images of the rationals and then mapping the irrationals elsewhere is good though, it just requires some care in the details. For instance, you can map all rationals to some irrational element in $(0,1)$ and make sure the irrationals go elsewhere. – Marc van Leeuwen Feb 5 '12 at 15:13
possible duplicate of Cardinality of the Irrationals – Asaf Karagila Feb 5 '12 at 15:17
As a second hint, no continuous function with continuous inverse exists between the reals and the irrationals, so you should avoid trying to find one. – Chris Janjigian Feb 5 '12 at 15:20

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.)

-

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.

-
Nice answer, though you should say which decimal representation to choose for numbers that have two of them, so as to make your map well defined (for instance forbid expansions that ultimately have only $9$'s). Not a big deal, but it may be noted that the numbers where this issue arises (those having a finite decimal representation) are exaclty the points where your mapping is discontinuous (cf. the comment by Chris to the question). – Marc van Leeuwen Feb 5 '12 at 17:56
Marc, you can choose either representation you like for each $x$ independently, and the map remains one-to-one. The issue does not arise for the target real, because we interleaved digits with an irrational number. (But you are right that we should specify a particular choice of representing each real $x$ to make the function well-defined.) – JDH Feb 5 '12 at 19:52
Ah, and I see now that Chris hinted at this answer just before I posted it. – JDH Feb 5 '12 at 19:53

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.

-
Mapping $0$ to $0$ is not a good idea if you have to avoid the rational numbers in the image (but you don't have to if you would include $0$ among the $r_i$). Also I would prefer to map $a_i\mapsto a_{2i}$ before assigning values to the rationals, in keeping with company policy of hotel Hilbert. – Marc van Leeuwen Feb 5 '12 at 17:51
@Marc 0 is rational, doh :) Thanks. – David Mitra Feb 5 '12 at 18:19