Associated Topics || Dr. Math Home || Search Dr. Math

### Representing Positive Integers in an Irrational Base

```Date: 08/13/2007 at 09:32:54
From: Daniel
Subject: Representing positive integers in a given base

I know how to represent positive integers in other bases, such as
writing 3 in base 10 as 11 in base 2 (binary).  But what if the given
base is irrational?

```

```
Date: 08/15/2007 at 21:07:39
From: Doctor Luis
Subject: Re: Representing positive integers in a given base

Hi Daniel,

That shouldn't matter much.  If you think about it, expressing a
number in another base is simply finding out how a series of powers
of a fixed number "fits" the number that we want to represent.

For example, let's take the irrational base b = sqrt(2) and see if
we can express 3 in this base.

That means that we want to find something like this

3 = a_n * b^n + ... + a_2 * b^2 + a_1 * b^1 + a_0
+ a_{-1} * b^{-1} + a_{-2} * b^{-2} + ...

with coefficients a_k, k any integer.

Thus, in base b, 3 can be written as the number

a_n ... a_2 a_1 a_0 . a_{-1} a_{-2} ...

where the "..." denote the appropriate continuation, and the single
"." is the period denoting the "decimal" point.  Note that these
"decimal" digits after the dot can keep going indefinitely for some
numbers.

Preferably, the digits a_k should be integers no larger than the
integer part of b. That way, they can be juxtaposed easily as a single
string of digits.

Another thing to notice is that since b = 1.414213562.. our digits
will then consist of just 0's and 1's, as with your example in base 2.

Now, back to finding 3 in base b = sqrt(2).

The first question that must be asked is: what is the largest power of
b that "fits" into 3?  You can find this out easily with a calculator

3/b   = 2.121320344
3/b^2 = 1.500000001
3/b^3 = 1.060660173
3/b^4 = 0.7500000009

Here, you can see that b^3 fits into 3 best, indicating that the first
digit is 1.  You can also think of the coefficient of b^4 as 0.

So, our first approximation to 3 is

3 = 1 * b^3 + ...

Next, we look at what's left after taking away the known digits

R_1 = 3 - 1 * b^3
= 1.939339827..

And we repeat the process...in this case we find that

R_1/b^1 = 1.371320343
R_1/b^2 = 0.9696699140

This tells us that the coefficient of b^2 in R_1 is 0, and that the
coefficient of b^1 in R_1 is 1.  This gives us our second approximation:

3 = 1*b^3 + 0*b^2 + 1*b^1 + ...

and thus, our second remainder becomes:

R_2 = R_1 - 0*b^2 - 1*b^1
= 0.525126265...

We can repeat the process again.

R_2/b^1    = 0.3713203431
R_2/b^0    = 0.525126265
R_2/b^(-1) = 0.7426406857
R_2/b^(-2) = 1.050252529

Thus, the coefficient of b^1 is 0, the coefficient of b^0 is 0,
the coefficient of b^{-1} is also 0, but the coefficient
of b^{-2} is 1.

This means

3 = 1*b^3 + 0*b^2 + 1*b^1 + 0*b^0 + 0*b^{-1} + 1*b^{-2} + R_3

and the third remainder becomes

R_3 = R_2 - 0*b^0 - 0*b^{-1} - 1*b^{-2}
= 0.0251262647

One last time:

R_3/b^(-2) = 0.05025252937
R_3/b^(-3) = 0.07106780855
R_3/b^(-4) = 0.1005050587
R_3/b^(-5) = 0.1421356171
R_3/b^(-6) = 0.2010101173
R_3/b^(-7) = 0.2842712340
R_3/b^(-8) = 0.4020202344
R_3/b^(-9) = 0.5685424675
R_3/b^(-10) = 0.8040404684
R_3/b^(-11) = 1.137084935

this implies that the digits of b^{-2} down to b^{-10} are all 0,
while that of b^{-11} is 1, and so

3 = 1*b^3 + 0*b^2 + 1*b^1 + 0*b^0 + 0*b^{-1} + 1*b^{-2} +
0*b^{-3} + 0*b^{-4} + 0*b^{-5} + 0*b^{-6} + 0*b^{-7} +
0*b^{-8} + 0*b^{-9} + 0*b^{-10} + 1*b^{-11} + R_4

The fourth remainder is then:

R_4 = R_3 - 1*b^{-11}
= 0.00302917772

And so on and so on.  This process is well defined because the
successive remainders R_n, or errors in our representation, will only
get smaller and smaller as we keep subtracting the largest power that
fits into each successive remainder.

And so we obtain the "square-root-of-two-cimal" expansion of 3,
accurate to 0.003 (decimal):

3 = 1010.01000000001...

How curious that some terminating decimals seem to have an infinite
square-root-of-two-cimal expansion. That's not always the case,
though, as you can tell from:

2 =     100.0000...
4 =   10000.0000...
8 = 1000000.0000...

And even some irrationals now terminate as well:

sqrt(2) = 10.000000...
1/sqrt(2) = 0.100000...

Do any other irrationals terminate in this base?  Curiouser and curiouser!

Well, I hope that was helpful.  Let us know if you have any other
interesting questions.

- Doctor Luis, The Math Forum
http://mathforum.org/dr.math/
```
Associated Topics:
College Number Theory