How to get many places of pi from Machin's Equation?

Richard D. Moores rdmoores at gmail.com
Sat Jan 9 12:31:49 CET 2010


Machin's Equation is

4 arctan (1/5) - arctan(1/239) = pi/4

Using Python 3.1 and the math module:

>>> from math import atan, pi
>>> pi
3.141592653589793
>>> (4*atan(.2) - atan(1/239))*4
3.1415926535897936
>>> (4*atan(.2) - atan(1/239))*4 == pi
False
>>> abs((4*atan(.2) - atan(1/239))*4) - pi < .000000000000000001
False
>>> abs((4*atan(.2) - atan(1/239))*4) - pi < .0000000000000001
False
>>> abs((4*atan(.2) - atan(1/239))*4) - pi < .000000000000001
True
>>>

Is there a way in Python 3.1 to calculate pi to greater accuracy using
Machin's Equation? Even to an arbitrary number of places?

Thanks,

Dick Moores



More information about the Python-list mailing list