Saturday, September 18, 2010

Nerdy Number Corner: Recurring, recurring...

;Adler 81S calculator from the later 1970's :M...

Image via Wikipedia

If you've messed with a calculator for any length of time, you'll have noticed that when division isn't exact, the calculator has this nasty habit of responding with a decimal answer that fills the entire display. For instance, if you ask your calculator to evaluate that common approximation to pi, 22/7. The calculator will respond with something like 3.1428571; if you have a slightly more sophisticated calculator, you'll see the next two digits are 42; and, as you might correctly guess, the sequence 142857 goes on 'forever'. (Yes, I'll admit it. I'm being a bit careful with my choice of words here. The idea of a sequence of digits that goes on 'forever' is actually something abstract. Decimal expansions, streams of digits, exist so we can write numbers down. If a stream of digits really did go on 'forever' - well, we'd never finish writing it out). It turns out that's actually the norm when it comes to the decimal expansion for fractions. If (once we've reduced to lowest terms) the only factors that appear in the denominator are 2 and/or 5, then the decimal expansion comes to an end (because 2 and 5 are the factors of 10, the base of our number system). Otherwise, the decimal expansion of a fraction eventually repeats.

There's some immediate questions that might spring to mind, such as, how many digits long is the repeating cycle? 1/3 is 0.3333333... the pattern is one digit long. Likewise 1/6 is 0.1666666... - after that initial 1, the pattern is again one digit long. 1/7 is 0.142857... and that pattern is six digits long. What's happening? It turns out the length of the pattern can be at most one less than the denominator. A simple explanation would be to consider how you would work out the decimal expansion using pencil and paper. it would be a long division problem into n.0000... (where n is the numerator) - the string of zeroes on the right of the decimal point going on 'forever'. At each digit, the remainder carried to the next digit takes one of the values 1, 2, ... d-1, where d is the denominator. There are no other possibilities; the remainder at each step has to be less than d, and the remainder can't be zero, because the calculation doesn't terminate. Once a remainder repeats, the sequence forever thereafter also repeats. The enterprising of you might want to start Googling for things like the "order of 10, modulo d". The actual length of the repeating cycle can be determined.

The process works the other way around as well. Any repeating sequence of digits represents a fraction. For instance, the decimal 0.153439153439..., those six digits repeating over and over again, represents 153439/999999, or, in it's simplest form, 29/189. Similarly, even if the sequence doesn't immediately repeat, it still represents a fraction. For example, given the number X = 0.123153439153439...., that's also a fraction. To prove it, note that 1000X = 123 + 29/189 and then solve for X.

The recurring decimal pattern, occurring for sequences of digits that represent fractions, is so common that even if we try to construct some particularly unusual decimals, we'll get fractional answers and recurring patterns all over again. For instance, what if we start writing down the number 0.1234567... - the pattern continuing 8, 9, 10, 11.... Things start to get a bit tricky if we want to put numbers greater than 9 in a single digit position, so we have to worry about carries. What is this value? We can calculate it by writing

X = 0/1 + 1/10 + 2/100 + 3/1000 + 4/10000 + ....

and thus

10X = 0/10 + 1/1 + 2/10 + 3/100 + 4/1000 + ....

and subtracting one from the other

9X = 1/1 + 1/10 + 1/100 + 1/1000 + = 10/9

giving X = 10/81. It turns out that number X is 0.123456790123456790... - remarkably, the digits line up, repeating every nine positions, even with all the carries from digit to digit, and not a single digit 8 survives.

We can even make some even more difficult calculations. Consider the Fibonacci sequence 1, 1, 2, 3, 5, 8, 13, 21, 34... where each term is the sum of the two preceding ones. For clarity, write this out with each entry taking two digits (and, as before, we'll get carries occurring once numbers get larger). What is the value of X = 0.01010203050813213455....? Believe it or not, the answer is 101/9899. Can you prove it?

Related articles by Zemanta