Republic of Mathematics blog

The digits of 1/2 (base 2.5)

Posted by: Gary Ernest Davis on: April 27, 2010

The unusual title for this post comes from a tweet from my Twitter colleague Peter Flom.

Peter tweeted that he was thinking about writing numbers in base 2.5

I recalled that some years ago when I was teaching a graduate mathematics education class at Rutgers, we looked at an algorithm for generating the expansion of a number in a given whole number base, and one of the students asked what would happen if we chose a fractional base – like 2\frac{1}{2}.

We implemented the algorithm in Excel, so we just changed the base from a whole number – 2 – to a fractional number – 2\frac{1}{2} – and bingo! the digits of the expansion appeared.

Writing numbers in different whole number bases

How do we go about writing a number such as \frac{1}{3} as a sequence of digits base 2?

First we have to agree on what the digits base 2 are. The usual convention is that they are the digits 0 and 1.

So we are looking for a representation of \frac{1}{3} in the form \frac{1}{3}=0.b_1b_2 b_3\ldots   (base 2) where the b_n are digits 0 or 1.

By this we mean that \frac{1}{3}=\frac{b_1}{2}+\frac{b_2}{2^2}+\frac{b_3}{2^3}+\ldots.

How can we find the sequence of digits b_n?

The key is to begin by multiplying  \frac{1}{3} by the base 2.  This gives us the representation \frac{2}{3}=b_1+0.b_2b_3b_4\ldots.

The digit b_1 is then the integer part – or floor – of \frac{2}{3}, so b_1=0 and \frac {2}{3}=0.b_2b_3b_4\ldots

Now we multiply by 2 again to get the repesentation \frac {4}{3}=b_2+0.b_3b_4b_4\ldots.

This means that b_2 is the floor of \frac{4}{3}, namely 1, and \frac{1}{3}=\frac{4}{3}-1=0.b_3b_4b_5.

Now we are in luck, because we have a representation for \frac{1}{3} again, so we can take 0=b_1=b_3=b_5\ldotsand 1=b_2=b_4=b_6\ldots.

So the base 2 representation for \frac{1}{3} is 0.01010101\ldots

Recall this means that \frac{1}{3}=\frac{1}{2^2}+\frac{1}{2^4}+\frac{1}{2^6}+\ldots

Writing the algorithm in Excel

The recursive algorithm for finding the digits in the base 2 expansion of a number is so simple that we can code it in Excel (of course feel free to use Python or R).

Here’s how the Excel spreadsheet looks:

base = 2 n b(n) a(n)
number = 1/3 1 0 1/3
2 1 2/3
3 0 1/3
4 1 2/3
5 0 1/3
6 1 2/3
7 0 1/3
8 1 2/3
9 0 1/3
10 1 2/3
11 0 1/3
12 1 2/3
13 0 1/3
14 1 2/3
15 0 1/3
16 1 2/3
17 0 1/3
18 1 2/3
19 0 1/3
20 1 2/3

with the entries in the a(n) column set to be fractions (rather than decimal expansions).

The simple Excel code to generate this table is as follows:

base = 2 n b(n) a(n)
number = =1/3 1 =INT(E2*$B$1) =B2
=C2+1 =INT(E3*$B$1) =E2*B$1-D2
=C3+1 =INT(E4*$B$1) =E3*B$1-D3
=C4+1 =INT(E5*$B$1) =E4*B$1-D4
=C5+1 =INT(E6*$B$1) =E5*B$1-D5
=C6+1 =INT(E7*$B$1) =E6*B$1-D6
=C7+1 =INT(E8*$B$1) =E7*B$1-D7
=C8+1 =INT(E9*$B$1) =E8*B$1-D8
=C9+1 =INT(E10*$B$1) =E9*B$1-D9
=C10+1 =INT(E11*$B$1) =E10*B$1-D10
=C11+1 =INT(E12*$B$1) =E11*B$1-D11
=C12+1 =INT(E13*$B$1) =E12*B$1-D12
=C13+1 =INT(E14*$B$1) =E13*B$1-D13
=C14+1 =INT(E15*$B$1) =E14*B$1-D14
=C15+1 =INT(E16*$B$1) =E15*B$1-D15
=C16+1 =INT(E17*$B$1) =E16*B$1-D16
=C17+1 =INT(E18*$B$1) =E17*B$1-D17
=C18+1 =INT(E19*$B$1) =E18*B$1-D18
=C19+1 =INT(E20*$B$1) =E19*B$1-D19
=C20+1 =INT(E21*$B$1) =E20*B$1-D20

The key is to start with a(1) as the number whose base 2 representation we want to find. Then b(n)= integer part (=floor) of a(n-1)*base  (in this case the base is 2), and a(n)=a(n-1)*base-b(n-1).

Having set up the Excel code this way we can change the number whose representation we want to find from \frac{1}{3} to \frac{1}{4},\frac{1}{5} or even \pi.

Changing to another whole number base

We can also change the base. If we change the base to 3, so using the digits 0, 1, 2 in our representations, we get, for example, \frac{1}{4}=0.02020202\ldots (base 3).

Changing to a  fractional base

But nothing stops us from choosing a fractional base, such as 2\frac{1}{2}.

In this case the digits will be 0, 1 or 2  – the non-negative integers less than2\frac{1}{2}.

Then, we get, for example,  \frac{1}{2}=0.10111000011012100011111210001002000100120100111110\ldots (base 2.5).

Changing to arbitrary real number bases

We can even choose transcendental bases such as \pi and to within the numerical accuracy of Excel, we get \frac{1}{2}=0.11211202102012230001010010211022022021112301100001\ldots (base \pi).

Changing to complex integer bases

We can even calculate the base b expansion of a number where b is a complex integer – that is a complex number of the form m+ni where m and n are integers.  This is because there is a nice floor function for complex integers, which is \textrm{Floor}(m+ni)=\textrm{Floor}(m)+\textrm{Floor}(n)i.

We can use the built-in complex arithmetic of Excel to carry out the calculations as before (but you might want to use Mathematica, MATLAB, R or Python instead).

Two examples are:

\frac{1}{2} = 0.00i (base 1+i ) and \frac{1}{3 }= 0.00-1(-1+i)0i -1i repeated (base 1+i).

Postscript

Because of the problem of non-uniqueness of representation in weird bases, one needs to think a little about what are appropriate digits for a base b representation, where b is something other than a positive integer, as pointed out in the comment by John Lame, below.

A lovely account of representation in weird bases appears in James Tanton’s Exploding Dots.

1 Response to "The digits of 1/2 (base 2.5)"

This seems to be the standard interpretation of fractional bases and yet the problem I have with it has always been uniqueness of representation. Admittedly, even in base 10, we have 1.0 = 0.99999…, but at least we can make the claim that every real number is represented by at most finitely many expansions in base 10 (at most 2 representations in fact).

In base 2.5 however, (i suspect) we have infinitely many representations of every real number. For instance, if I’ve done this correctly:

2.5 = 10.0… = 2.101110000110121 … = 2.02212110011122…

Even if we define exactly what we mean by “the” base 2.5 expansion of a number, I wonder if there aren’t uncountably many expansions which would end up being invalid base 2.5 representations of anything. Again, nothing proven here, just a statement of why this whole approach seems unsatisfactory.

I would find either of the two following approaches more interesting.

1.) Throw away the idea that the “digits” in base 2.5 are {0, 1, 2}. Instead, let them be {0, x_1, x_2, …, x_n} (with n probably equal to 2, but without starting with that assumption) and then come up with real values for x_1, x_2, … such that for some fixed positive integer R. every real number in [0, 1) has at least 1 and at most R representations of the form 0.ddddddd… where each ‘d’ is one of the digits, and such that every representation of the form 0.ddddddd… does converge to some real number in [0, 1). This may be easily proven to be impossible, I just haven’t tried to work it out yet.

2.) Start much more abstractly by proving as many statements about representations of real numbers in an integral base B as one can, and then define “representation of real numbers in a non-integral base B” to be a representation scheme which satisfies an “interesting” sub-collection of those statements.

John

Leave a Reply to John LameCancel reply