Ken Steiglitz: Happy π Day!

As every grammar school student knows, π is the ratio of the circumference to the diameter of a circle. Its value is approximately 3.14…, and today is March 14th, so Happy π Day! The digits go on forever, and without a pattern. The number has many connections with computers, some obvious, some not so obvious, and I’ll mention a few.

The most obvious connection, I suppose, is that computers have allowed enthusiasts to find the value of π to great accuracy. But how accurately do we really need to know its value? Well, if we knew the diameter of the Earth precisely, knowing π to 14 or 15 decimal places would enable us to compute the length of the equator to within the width of a virus. This accuracy was achieved by the Persian mathematician Jamshīd al-Kāshī in the early 15th century. Of course humans let loose with digital computers can be counted on to go crazy; the current record is more than 22 trillion digits. (For a delightful and off-center account of the history of π, see A History of Pi, third edition, by Petr Beckmann, St. Martin’s Press, New York, 1971. The anti-Roman rant in chapter 5 alone is worth the price of admission.)

A photo of a European wildcat, Felis silvestris silvestris. The original photo is on the left. On the right is a version where the compression ratio gradually increases from right to left, thereby decreasing the image quality. The original photograph is by Michael Ga¨bler; it was modified by AzaToth to illustrate the effects of compression by JPEG. [Public domain, from Wikimedia Commons]

Don’t condemn the apparent absurdity of setting world records like this; the results can be useful. Running the programs on new hardware or software and comparing results is a good test for bugs. But more interesting is the question of just how the digits of π are distributed. Are they essentially random? Do any patterns appear? Is there a message from God hidden in this number that, after all, God created? Alas, so far no pattern has been found, and the digits appear to be “random” as far as statistical tests show. On the other hand, mathematicians have not been able to prove this one way or another.

Putting aside these more or less academic thoughts, the value of π is embedded deep in the code on your smartphone or computer and plays an important part in storing the images that people are constantly (it seems to me) scrolling through. Those images take up lots of space in memory, and they are often compressed by an algorithm like JPEG to economize on that storage. And that algorithm uses what are called “circular functions,” which, being based on the circle, depend for their very life on… π. The figure shows how the quality of an original image (left) degrades as it is compressed more and more, as shown on the right.

I’ll close with an example of an analog computer which we can use to find the value of π. The computer consists of a piece of paper that is ruled with parallel lines 3 inches (say) apart, and a needle 3 inches long. Toss the needle so that it has an equal chance of landing anywhere on the paper, and an equal chance of being at any angle. Then it turns out that the chance of the needle intersecting a line on the piece of paper is 2/π, so that by repeatedly tossing the needle and counting the number of times it does hit a line we can estimate the value of π. Of course to find the value of π to any decent accuracy we need to toss the needle an awfully large number of times. The problem of finding the probability of a needle tossed this way was posed and solved by Georges-Louis Leclerc, Comte de Buffon in 1777, and the setup is now called Buffon’s Needle. This is just one example of an analog computer, in contrast to our beloved digital computers, and you can find much more about them in The Discrete Charm of the Machine.

Ken Steiglitz is professor emeritus of computer science and senior scholar at Princeton University. His books include The Discrete Charm of the MachineCombinatorial OptimizationA Digital Signal Processing Primer, and Snipers, Shills, and Sharks (Princeton). He lives in Princeton, New Jersey.