Intel's Ronler Acres Plant

Silicon Forest
If the type is too small, Ctrl+ is your friend

Friday, March 19, 2021

All π

π

Looking over my program for computing the value of pi, I realized that the method I had labeled as 'classic' was actually a copy of the BBP method, so I set about correcting this mistake. Turns out the classic method (the infinite sum of alternating positive and negative fractions of ever decreasing magnitude) is poorly suited for implementation on a modern computer. Where all the other methods can calculate pi to the limit of the machine's precision in 25 steps or so, the classic method takes something like two trillion steps to get anywhere close. After a bit of futzing about, I find it gets pretty close after about two million steps. Up until then the difference between the computed value of pi and our reference value keeps getting smaller, but at that point it inexplicably gets larger. It starts getting smaller again, but nobody wants to wait for hours for a demo to run, so we call it quits.

Then I got to wondering just how do we know just what the digits of π are? A physical measurement is only going to get us a handful of digits. How do we know what the rest of the digits are? Well, you need to have a little faith. You come up idea of how it can be calculated, and then you implement that idea in a computer program, turn the machine on and let the program run. If it's a well behaved program it will run forever or until it runs into it's limitations (like my demo program) or it runs out of space to store the result. Asking for a zillion digits of π is like asking how far your car can drive. It's a machine and it will keep running until it breaks down. It's kind of pointless actually.

Still, it's a good exercise for the computationally inclined, kind of like target practice in archery.


No comments: