Take that, William Shanks!

Every once in a while, I get the urge to write a program for the sheer fun of it. I wrote my first (and second, and third) raytracer just for fun. I’d like to write a chess playing program just for fun. I’ve written some chunks of programs that have to do with evolutionary computation just for fun. Some are big projects, and may never get done. Some are small.

One of the small programs I thought I might try to write would be one to calculate pi to arbitrary (or relatively arbitrary) numbers of digits. An hour later, I have a program which spits out the following:

3.

1415926535 8979323846 2643383279 5028841971 6939937510
5820974944 5923078164 0628620899 8628034825 3421170679
8214808651 3282306647 0938446095 5058223172 5359408128
4811174502 8410270193 8521105559 6446229489 5493038196
4428810975 6659334461 2847564823 3786783165 2712019091
4564856692 3460348610 4543266482 1339360726 0249141273
7245870066 0631558817 4881520920 9628292540 9171536436
7892590360 0113305305 4882046652 1384146951 9415116094
3305727036 5759591953 0921861173 8193261179 3105118548
0744623799 6274956735 1885752724 8912279381 8301194912
9833673362 4406566430 8602139494 6395224737 1907021798
6094370277 0539217176 2931767523 8467481846 7669405132
0005681271 4526356082 7785771342 7577896091 7363717872
1468440901 2249534301 4654958537 1050792279 6892589235
4201995611 2129021960 8640344181 5981362977 4771309960
5187072113 4999999837 2978049951 0597317328 1609631859
5024459455 3469083026 4252230825 3344685035 2619311881
7101000313 7838752886 5875332083 8142061717 7669147303
5982534904 2875546873 1159562863 8823537875 9375195778
1857780532 1712268066 1300192787 6611195909 2164201989

William Shanks spent his entire life computing pi to 707 decimal digits. Unfortunately, he made a mistake 527 digits in, and the rest were hopelessly screwed up as a result. Now, a hundred plus years later, redoing the calculation takes an hour of my time, and about two seconds of computer time. That’s what Moore’s Law has done for humanity: a century ago, to compute this would have been the work of a lifetime. Now, it’s just a coffee break. Oh, and by tomorrow I’ll have pi to a million digits (and the program I wrote is laughably inefficient, we could obviously do much, much better).

[tags]Mathematics,Pi[/tags]

3 thoughts on “Take that, William Shanks!

  1. Mark Post author

    Yes, they are fascinating. In fact, it’s on my list to understand the idea behind such algorithms. The BBP algorithm is efficient when used in hexadecimal or binary bases, but the best known algorithms for decimal bases is greater than O(n^2) time (but very nearly constant space). Neat stuff!

    For more info, check out Fabrice Bellard’s Pi Page.

  2. J. D. Harper

    I’m about to reveal my ignorance here, but: Seriously, his whole life to get to 707 digits?

    That sounds like an afternoon’s work with a really big piece of a paper for a long-division problem. Find a circle, measure the circumference and the diamater, and divide.

    What am I missing?

    Editor’s note: Apparently the distinction between the terms “precision” and “accuracy”. 707 decimal digits is a lot. To determine the pi this way, you’d need to be able to determine the diameter and the circumference of the circle accurate to one part in 10^707. If your circle has a diameter of one meter, that means you need to measure them accurate to one part in 10^707. To give you some hint of the problem, the diameter of a proton is only 2 * 10^-14 meters in diameter.

Comments are closed.