Simple function for enumerating bisections of $[0,1]$

57 Views Asked by At

Is there a simple function $f : \mathbb{N}\rightarrow\mathbb{Q}$ that returns further and further bisections of the segment $[0,1]$? For example, we could have $f(0)=0$, $f(1)=(1)$, $f(2)=1/2$, $f(3)=1/4, f(4)=3/4, f(5)=1/8,f(6)=3/8$, etc. The order can vary somewhat, but I would like it to work from top-down, so that lower $n$ gives fractions with the lower denominators.

I can think of a mechanical way to do this. Take the denominator as the largest power of 2 less than $n$. Then the numerator is the remainder, but we have to skip every reducible fraction that already came before. Is there a nice way to do this algebraically?

1

There are 1 best solutions below

0
On

One answer: as commented here, we can use the ratio of the sequences A006257/A062383.

So using those formulas we could get

$$f(n) = \frac{2(n - 2^{\lfloor\log_2(n)\rfloor}) + 1}{2^{\lceil\log_2(n+1)\rceil}}$$

For $n > 0$. The only thing we lose is that $1$ only comes at the end.