Taking the Scenic Route Around a Circle

I’m not much of a computer programmer.  However, every so often, I get the urge to just “play around” and write something… just to see if I still can.  It’s not so much the programming that interests me.  I like to see if I can puzzle things out and maybe learn something new in the process.

So, I was thinking about pi (“π”).  For those who aren’t big on geometry, pi is the ratio of the diameter of a circle to its circumference.  If you have a circle that is one inch across, you will measure a little more than 3 inches around the outside edge.  Depending on how accurate you are, you may get 3.1 inches or even 3.14.  It actually breaks down farther than that.  Pi is a special kind of number; it goes on forever (as far as anyone can tell).  But it never repeats in a pattern unlike – say, 1/3, which is .3 and a trail of threes that goes on endlessly.

There are many ways to figure out pi.  The one I was familiar with from high school math was a series of additions that starts like this:

4/1 – 4/3 + 4/5 – 4/7…

It goes on forever and the ultimate answer (if you could calculate this to 4/infinity) is pi.  I started up the old TRS-80 Model III I keep in my closet (yes, I am a closet TRS-80 user) and wrote a little program.  I kicked it off and quickly had a string of numbers marching up the screen:

4, 2.666666, 3.466666, 2.895238, 3.339682…

It took a moment, but it eventually it locked in 3.1.  However, that next decimal place took quite awhile to settle down.  At first I thought I botched the programming.  However it was only six lines long; there wasn’t much to botch.  My TRS-80 isn’t exactly a powerhouse; it can do about 330 calculations a minute using BASIC, but still…  I got online and took a look around.  What I was using is called the Leibniz Series.  I happen to know the first eleven places of pi are 3.14159265358.  Using the Leibniz Series, my poor TRS-80 would have to labor through something like a hundred billion iterations to approach that level of accuracy!  I found an article on the Chudnovsky brothers who came up with a – shall we say – bit more involved way to calculate pi.  It wasn’t as simple to figure out, but it gave me the first 1,234,567,890 digits of pi in less than four hours.

Gottfried Leibniz was a legendary mathematician who came up with calculus (independent of Isaac Newton) and figured out binary.  He was also a noted philosopher in the 17th Century and developed what is now known as optimism.  He believed that everything in the universe was done in the best possible way.  With that in mind, I wonder what he would have made of the fact his name is lent to the slowest, most inefficient method of calculating pi?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s