Simple Continued Fraction Expansion of Pi

Hans Havermann hahaj at
Thu Mar 14 21:54:09 CET 2002

A Brief History of an Obsession [A001203]:

In late 1984, I complained to Martin Gardner, then mathematical-games
columnist for Scientific American, about the paucity of simple continued
fraction terms for the number pi. C.D. Olds' "Continued Fractions" had
whetted my 1960s teenage-appetite with only the first 23 numbers of the
sequence. Mr. Gardner let me know that a Bill Gosper had calculated many
thousands of terms and was kind enough to supply me with Mr. Gosper's

Incredibly, after I sent Mr. Gosper my inquiry, he mailed me a 205-page
Xerox of his (19 August 1977) 204103-term computer calculation. I still have
it. Bill went on to calculate 17001303 terms in 1985, a feat that (if I
remember correctly) was mentioned at the time in "Science News".

By 1995, I was able to calculate only a measly 10000 terms of the number
using Mathematica on my first Macintosh. Lack of adequate memory was the
major impediment to progress. That year I looked up Bill Gosper's e-mail and
asked for an electronic version of his calculations. He replied: "I just
lost a disk with 17000000. When I get a new one, we'll see how well my old
backup tapes work."

When Mathematica 4 came out in May 1999, I immediately ordered my upgrade.
They had incorporated the ContinuedFraction function into the body of the
program (it used to reside in an add-on package) and, on my first try, I was
able to come up with 10 million terms (of pi) on my G3/300/384. Next I
calculated 17 million. Finally, playing with assorted larger values, I
managed to get 20 million terms without running out of memory. The
calculation took 6 hours and resulted in a 62 MB output file. Simon Plouffe
of Plouffe's Inverter believed the 20 million terms were a record and was
kind enough to give them web-space: <>.

One year later, a RAM doubling allowed me to calculate 40 million terms.
And, in October 2000, a 400 MHz iMac G3 equipped with a GigaByte of RAM
churned out 53 million terms in under 20 hours.

Last month I became the proud owner of an 800 MHz flat-panel iMac G4,
running OS X. Because of OS X's significantly different memory architecture,
I was able to churn out 100 million terms with no more RAM than I had in my
previous computer. Filled with bold expectations I tried for a billion, only
to run into a Mathematica overflow-error. And my subsequent 200-million
attempt shut down the Mathematica kernel because of a lack of memory. So
there *was* a limit to what even OS X could do for me.

On 10 March, I finished a 62.5-hour run that generated 160 million terms.
Mathematica did not have enough memory, alas, to input the entire file, so I
was forced to use a text-editor (BBEdit Lite) to search and subsequently
shape the file (I wanted 100 numbers per line).

Gosper's 878783625 [A033089] at position 11504931 [A033090] is still
unsurpassed. 5983 is the smallest number yet to appear. There's still a gap
to bridge between the 160 million attained and the 200 million no-go. In the
meantime, I'm web-sharing the 160 million term files:

The 100 MB StuffIt-compressed file <cfpi160m.sit> therein is probably
downloadable with a fast connection, but you're still going to have figure
out how to interact with the unstuffed 483 MB file. I've compiled the 18
largest number-occurrences (in context) in the <overview> document. I won't
likely update my own pi-page <>
until *after* I've maxed out the number of terms I can generate.

Nature requires five,
Custom allows seven,
Idleness takes nine,
And wickedness eleven.

More information about the SeqFan mailing list