Give an explicit formula for a bijection from the set of rational numbers to the set of non-negative rational numbers $\{q:q∈\Bbb Q,q≥0\}$. I was able to find injective and surjective functions, but not a bijection. Does anyone know a possible solution?
-
Does this help? https://math.stackexchange.com/a/1067928/260674 – Fawkes4494d3 Sep 17 '20 at 18:18
3 Answers
Sure: Every rational number can be uniquely written as $\pm 2^k \frac ab$ were $a\in \mathbb N$ or $a = 0$ and $b \in \mathbb N$. $b$ is odd and if $a \ne 0$ then $a$ is odd. If $a = 0$ then $b=1; k=0$ but if $a\ne 0$ then $\gcd(a,b) =1$ and $k\in \mathbb Z$.
If $m = 2^k\frac ab \ge 0$ then let $\phi(m) = 2^{2k}\frac ab$ (note: $\phi(0) = 0$). If $m = -2^k\frac ab<0$ then let $\phi(m) =2^{2k+1}\frac ab$.
- 130,341
Integer Bijections $\boldsymbol{\mathbb{Z}^{\ge0}\leftrightarrow\mathbb{Z}}$
Define $\tilde{f}:\mathbb{Z}^{\ge0}\mapsto\mathbb{Z}$ as $$ \tilde{f}(n)=(-1)^n\left\lfloor\frac{n+1}2\right\rfloor\tag1 $$ Then $\tilde{f}:(0,1,2,3,4,5,6,\dots)\mapsto(0,-1,1,-2,2,-3,3,\dots)$ sends odds to negatives and evens to non-negatives.
Define $\tilde{g}:\mathbb{Z}\mapsto\mathbb{Z}^{\ge0}$ as $$ \tilde{g}(n)=2|n|-[n<0]\tag2 $$ Then $\tilde{g}:(-3,-2,-1,0,1,2,3,\dots)\mapsto(5,3,1,0,2,4,6,\dots)$ sends negatives to odds and non-negatives to evens.
It's not too difficult to see that $\tilde{f}\circ\tilde{g}(n)=n$ and $\tilde{g}\circ\tilde{f}(n)=n$.
Real Bijections $\boldsymbol{\mathbb{R}^{\ge0}\leftrightarrow\mathbb{R}}$
Mapping each interval $[n,n+1)$ to the interval $\left[\tilde{f}(n),\tilde{f}(n)+1\right)$, we get
$f:\mathbb{R}^{\ge0}\mapsto\mathbb{R}$ defined by $$ \bbox[5px,border:2px solid #C0A000]{f(x)=(-1)^{\lfloor x\rfloor}\left\lfloor\frac{x+1}2\right\rfloor+x-\lfloor x\rfloor}\tag3 $$ Mapping each interval $[n,n+1)$ to the interval $\left[\tilde{g}(n),\tilde{g}(n)+1\right)$, we get
$g:\mathbb{R}\mapsto\mathbb{R}^{\ge0}$ defined by $$ \bbox[5px,border:2px solid #C0A000]{g(x)=2|\lfloor x\rfloor|-[x\lt0]+x-\lfloor x\rfloor}\tag4 $$ Then $f\circ g(x)=x$ and $g\circ f(x)=x$.
$f$ given in $(3)$ and $g$ given in $(4)$ are the functions sought in the question since they both send rationals to rationals; i.e. $$ f(x)-x=(-1)^{\lfloor x\rfloor}\left\lfloor\frac{x+1}2\right\rfloor-\lfloor x\rfloor\in\mathbb{Z}\tag5 $$ and $$ g(x)-x=2|\lfloor x\rfloor|-[x\lt0]-\lfloor x\rfloor\in\mathbb{Z}\tag6 $$
- 353,833
Let $f(x)=\begin{cases}x&x\in\mathbb N_0\\x+1&x\in\mathbb Q^+\setminus\mathbb N_ 0\\\frac{|x|}{|x|+1}&x\in\mathbb Q^-\end{cases}$
This function fixes the naturals ($0$ included) and shift all positive rationals to the right by $1$. Negative rationals are then mapped to $(0,1)$ left empty by the shift.
Note that we need to fix naturals else if we do only the two other operations then $0$ is not mapped (has no antecedent).
Note that $\frac x{x+1}$ is a bijection $(0,+\infty)\mapsto(0,1)$ on reals that fixes rationals, but it is also surjective on rationals since if $\frac ab\in(0,1)\cap \mathbb Q$ (i.e. $0<a<b$) then $\frac{-\frac pq}{-\frac pq+1}=-\frac p{q-p}=\frac ab$ has antecedent $p=-a,q=b-a$ and $\frac pq\in\mathbb Q^-$ and $\gcd(p,q)=\gcd(a,b-a)=\gcd(a,b)=1$.
- 29,833
-
Thank you so much! Your solution to the problem was by far the simplest I've seen. – Ishaaq Sep 17 '20 at 21:45