Is there a bijection between $\mathbb{Q}$ and $\mathbb{Q}_{>0}$?

1.7k Views Asked by At

Is there a bijection between $\mathbb{Q}$ and $\mathbb{Q}_{>0}$?

For $\mathbb{R}$, we have the exponential function. Is there also a bijection $f: \mathbb{Q} \to \mathbb{Q}_{>0}$ or to $\mathbb{Q}_{\geq 0}$?

4

There are 4 best solutions below

2
On

EDIT: If $x\ge0$, then $f(x)=x+[x]$; if $x\lt0$, then $f(x)=x-3[x]-1$. Here, $[x]$ is the integer part of $x$, the largest integer not exceeding $x$ (also known as the "floor" of $x$).

The following, incorrect answer is kept so as not to make the comments look odd:

If $x=a/b$, $b\gt0$, let $f(x)=a/(2b+1)$ if $a\ge0$, $f(x)=(2|a|-1)/2b$ if $a\lt0$.

5
On

A bijection from $\mathbb N$ to $\mathbb Q_{\ge0}$ :

  1. $f(0)=0$
  2. $f(1)=1$
  3. $f(2n)=f(n)+1$
  4. $f(2n+1) = \frac{1}{f(2n)}$

You obtain $0,1,2,\frac{1}{2},3,\frac{1}{3},\frac{3}{2},\frac{2}{3},4,\frac{1}{4},\frac{4}{3},\frac{3}{4},\frac{5}{2},\frac{2}{5},\dots$

A bijection from $\mathbb N$ to $\mathbb Q$ :

  1. $g(0)=0$
  2. $g(2n+1)=f(n+1)$
  3. $g(2n+2)=-f(n+1)$

You obtain $0,1,-1,2,-2,\frac{1}{2},-\frac{1}{2},3,-3,\dots$

Compose those two bijections : $f \circ g^{-1}$ to obtain a bijection from $\mathbb Q$ to $\mathbb Q_{\ge 0}$

Or consider $x\mapsto f(g^{-1}(x)+1)$ to obtain a bijection from $\mathbb Q$ to $\mathbb Q_{>0}$

4
On

The function $f:\mathbb Q\to\mathbb Q_{\gt0}$ defined by $f(x)=x+1$ if $x\geqslant0$ and $f(x)=1/(1-x)$ if $x\lt0$, sends $0$ to $1$ and sends bijectively $\mathbb Q_{\gt0}$ to $\mathbb Q_{\gt1}$ and $\mathbb Q_{\lt0}$ to $\mathbb Q\cap(0,1)$. Thus, $f$ is bijective.

For a bijection $g:\mathbb Q_{\gt0}\to\mathbb Q_{\geqslant0}$, consider $g(x)=x-1$ if $x$ is an integer and $g(x)=x$ otherwise.

For a bijection from $\mathbb Q$ to $\mathbb Q_{\geqslant0}$, consider $h=g\circ f$, that is, $h(x)=1/(1-x)$ if $x$ is negative, $h(x)=x$ if $x$ is a nonnegative integer and $h(x)=x+1$ if $x$ is positive and not an integer.

0
On

The Stern-Brocot tree $\mathcal T$ is an infinite binary search tree containing all positive rationals. It's easy to create its counterpart $\mathcal T^{-}$ for all negative rationals.

Create a tree with 0 as root, $\mathcal T^{-}$ as the left subtree and $\mathcal T^{+}$ as the right subtree. This is also an infinite binary search tree, which is trivially isomorphic to $\mathcal T$, so there's an order isomorphism between $\mathbb Q^{+}$ and $\mathbb Q$.