Tag Archives: continued fractions

How Homer Simpson Likes His Pi

by Bill Wood, mathematics professor and novice tweeter @MathProfBill

What is a number?

That’s a terrifyingly deep question for one blog entry, so let’s refine it a bit: How can we represent a number?

For counting numbers \(1,2,3,\ldots\), tally marks get tedious quickly, so I start grouping.  I like to group by tens because I have ten fingers to count on, so whenever I use up one set of ten fingers I will write that down to the left of where I am tracking my units and then start over: \(9, 10, 11\ldots 19, 20\ldots\).  That works great for a while until I get ten groups of ten and I’m out of fingers again.  So I write that down further to the left to bank a group of ten tens, and so on: \(99, 100, 101,\ldots,999, 1000,\ldots.\)  When I want fractions, I count tenths, hundredths, and so on, always in groups of ten, and write them to the right of my number. But I need to remember where my unit digits are, so I put a decimal point there to remind myself.  Now I understand that \(27.85\) means \(2\times 10 + 7\times 1 + 8\times \frac{1}{10} + 5\times\frac{1}{100}\).

I’m talking about decimal representations of a number, of course.  We call the symbols in each of the places digits — just like my fingers — and we use them all the time.  The ratio of a circle’s circumference to its diameter, which we call \(\pi\), has an unending digit representation \(3.14159\ldots\) that programmers like to compute and kids like to memorize for some reason.

But what about Homer Simpson?  Homer’s most important feature for our purposes is that he has eight fingers.  He would more naturally group tallies in eights. For him, \(27 = 2\times 10 + 7\times 1\) makes more sense to write as \(33 = 3\times 8 + 3\times 1\).  (Because eight is a power of two, the base 8 (or octal) representation has use in computer science as a shorthand for binary.)

But this is mathematics we are trying to do here, and mathematics absolutely should not care how many fingers we have.  We have polluted the concept of number with our choice of representation; those digits of \(\pi\) have as much to do with the chosen base as they do with \(\pi\).  Is there a more objective way to represent a number?

A continued fraction is a number of the form \(a_0+\frac{1}{a_1 + \frac{1}{a_2+ \frac{1}{a_3+\ldots}}}\) where the \(a_i\)’s are counting numbers (\(a_0\) can be 0, the others cannot).  We will denote this by \([a_0; a_1, a_2, a_3,\ldots]\). Calculating this representation is straightforward enough using the division algorithm.  We demonstrate for \(\frac{34}{27}\).

\begin{eqnarray*}
\frac{34}{27} & = & 1+\frac{7}{27} \\
& = & 1+\frac{1}{27/7} \\
& = & 1+\frac{1}{3+\frac{6}{7}} \\
& = & 1+\frac{1}{3+\frac{1}{7/6}}\\
& = & 1+\frac{1}{3+\frac{1}{1+\frac{1}{6}}}\\
& = & [1;3,1,6]
\end{eqnarray*}

The process terminated because the number is rational.  In fact, the irrational numbers are precisely those whose continued fraction representations are infinite, a fact that is not true of digital representations (\(\frac{1}{3}\), for example).  The representation for irrationals is also unique.

Now we try reversing the process.  We will jump in with an infinite sequence, but  a nice one, \(x=[1; 1,1,1,\ldots]\).  So \(x=1+\frac{1}{1+\frac{1}{1+\frac{1}{1+\ldots}}}.\)
But look at the denominator of the right hand side: it’s just \(x\) again!  You can play tricks like that with infinite sequences.  Then \(x\) must satisfy the relation \(x = 1+\frac{1}{x}\).  A little algebra gets \(x^2-x-1\) and the quadratic formula tells me  that \(x=\frac{1+\sqrt{5}}{2}\) (after I reject one solution for being negative).

That number \(\frac{1+\sqrt{5}}{2}\) is in the A-list of celebrity constants.  It is the golden ratio, usually denoted \(\phi\), and it is ubiquitous in nature and art.  Rabbit populations, pine cones, the pyramids, and the Fibonacci sequence all have something to do with \(\phi\). It is satisfying that the first continued fraction we might think of gave us something interesting.

Note that our decimal digits do still show up in the continued fraction — there is no getting around having to represent the number somehow — but the procedure for determining which number you have is independent of the representation.  The operations of addition and reciprocation that define the continued fraction do not care about the base, but the meaning of place values does.

So the next time we are asked to approximate \(\pi\), maybe we shouldn’t spout the usual \(\pi\approx 3.14159\ldots\), or even Homer’s preferred base eight representation \(\pi \approx 3.11037552\ldots \) and consider instead the continued fraction expansion for \(\pi \approx  [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2,  \ldots]\). If you need more convincing, have a look at how good the approximation is after just a few terms.

Consult your local internet for more on the properties of continued fractions — it is  a rich subject with plenty of fascinating connections.