Is there a function that maps each element of $\mathbb{Q}$ between 0 and 1 to $\mathbb{N}$?

127 Views Asked by At

Kepler devised a method to enumerate the rational numbers between 0 and 1. This clip from his Harmonices Mundi illustrates the method.

enter image description here

It works like this: Let $m=n=1$. Then $\tfrac{m}{n}$ is the first rational number. The next two are $\tfrac{m}{m+n}$ and $\tfrac{n}{m+n}$. These last two rationals become $m$ and $n$ for the next iteration. Wash, rinse, repeat for eternity. Done.

enter image description here

If we read Kepler's diagram left to right; down to up, the first 10 rationals are:

enter image description here

Suppose we want to know where, say, $\tfrac{6067}{9000}$ appears on that list. We could systematically run through Kepler's tree. Eventually the process will terminate.

But is there a better way to do this? Is there some function that maps each element of $\mathbb{Q}$ between 0 and 1 to $\mathbb{N}$?

EDIT: I'd like to specify that I'd like to know what that function is. I'd like to be able to plug in, say, $\tfrac{3}{8}$, and get the number $10$.

3

There are 3 best solutions below

0
On

Yes. Just define $f(\frac{p}{q})=42$.

But maybe you want an injective map. Then you can use $f(\frac{p}{q})=q^2 + p$.

Surjective: $f(p/q)=q$

Bijective is more difficult. You've presented one possibility already, but it sounds like you're looking for functions that are easier to compute. But maybe Kepler's function is easier to compute than you think. Let's say we're given the fraction (in lowest terms) $p/q$. We know that $p<q$. So $r = q-p$ is a positive number. Now one of $p/r$ or $r/p$ will be less than 1, whichever one that is, we rename it to $p'/q'$. We also know that $p/q = p / (p+r)$. So in the binary tree above, $p'/q'$ will be the fraction just above $p/q$. Then we repeat, starting from $p'/q'$ this time. A little bit of extra bookkeeping will tell us exactly which branch of the binary tree of fractions we're on, and from that we can compute our natural number output.

If you're observant, you'll notice that this algorithm is pretty much just Euclid's algorithm with extra steps. And Euclid's algorithm is fast.

0
On

Existence is easy, because both sets are countable.

To construct one, maybe take an easy injection in each direction, and then (try to) mimick (the proof of) Cantor-Schröder-Bernstein (where a bijection is constructed in just that situation).

0
On

You can put said rationals in an array, and then list them in the usual diagonal fashion. You get (something like) $1\mapsto 0,2\mapsto1,3\mapsto1/2,4\mapsto1/3,5\mapsto2/3,6\mapsto1/4,7\mapsto3/4,8\mapsto1/5,9\mapsto2/5,\dots $.