Maths is full of interesting numbers.

Among those numbers, is pi. We all know and love (or hate, depends on your point of view) the cute little constant with which we can calculate all kinds of fancy things about our circles and spheres. It’s seemingly endless. Well, seemingly, it really is endless. 3.1415926~ it keeps going on. Irregular, but we can still calculate it!

There’s a bunch of nifty formulas one can use to calculate pi. Often-times you’ll have to repeat the formula with a different value (one which you just calculated), or just keep stretching the formula into infinity. For a school project, I decided to see if I could go and accurately calculate pi myself. I’m… kind of disappointed with the results so far.

One series you can use, is the Gregory-Leibniz series.

It basically goes on like that. All you do is alternate add/subtract, and add 2 to the divisor. The longer you go on doing this, the more precise your calculation of pi becomes.

So far I’ve had the most success with this method, but it converges awfully slowly. (Meaning you need *a lot* of iterations to get somewhat precise.) Ten billion iterations in this series took my computer over 3.5 hours to complete, and the result I got was a mere eight decimal digits of accuracy (the same as with a billion iterations, oddly).

I’ve tried out other methods as well (there’s a lot, from the arcsine series to the Bailey-Borwein-Plouffe method (which is really awesome, by the way)), but my code isn’t working too well with those. I’m having a hard time putting some of those series or functions into Java code, especially with the need for BigIntegers and BigDecimals, since the numbers can (and need to) get really large.

I’ll keep working on it, I think. You guys’ll hear it when I make a breakthrough!

~ Fang

The Gregory-Leibniz series is merely an approximation to the number Pi.

Try this formula: http://www4a.wolframalpha.com/Calculate/MSP/MSP2531a5114fa0i1ff53200003f4ih6d30d0ahi5a?MSPStoreType=image/gif&s=54&w=110&h=56

This is a better approximation (I hope)

3.5 hours and only 8 correct decimals? That sucks. Better luck next time around. It can only improve from here!

Pi is a fun number but it’s one I never really got my brain around. Plus I’m still not convinced they don’t just keep adding random numbers to it.