Re: Compute pi by using Gregory series

Posted 29 September 2012 - 03:21 AM

I tried this out, so a few gotchas. In my python version, -1 ** n always yields -1, which is wrong. Make sure you're working in float. This means you'll want to use 1.0 rather than just 1. You must start at 1, not 10000.

Re: Compute pi by using Gregory series

Now, you really just need to do those sum += steps in a loop. Clearly, the numerator simply toggles the sign. The denominator just grows by 2. It's not much more complex than that. The value for pi, at any moment, is sum*4.

Now that I've described it in English, you try to describe it in Python. Good luck.

Now, you really just need to do those sum += steps in a loop. Clearly, the numerator simply toggles the sign. The denominator just grows by 2. It's not much more complex than that. The value for pi, at any moment, is sum*4.

Now that I've described it in English, you try to describe it in Python. Good luck.