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

John Machin sjmachin at lexicon.net
Sat Jan 9 09:12:36 EST 2010


On Jan 9, 10:31 pm, "Richard D. Moores" <rdmoo... at gmail.com> wrote:
> 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?

Considering that my namesake calculated pi to 100 decimal places with
the computational equipment available in 1706 (i.e. not much), I'd bet
you London to a brick that Python (any version from 0.1 onwards) could
be used to simulate his calculations to any reasonable number of
places. So my answers to your questions are yes and yes.

Suggestion: search_the_fantastic_web("machin pi python")



More information about the Python-list mailing list