Compute pi to base 12 using Python?
Nick Craig-Wood
nick at craig-wood.com
Mon Apr 18 07:30:03 EDT 2005
mensanator at aol.com <mensanator at aol.com> wrote:
> Nick Craig-Wood wrote:
> > mensanator at aol.com <mensanator at aol.com> wrote:
> > > I'm using GMPY (see code).
> > [snip]
> >
> > If you are using gmpy you might as well do it like this.....
> >
> > gmpy.pi() uses the Brent-Salamin Arithmetic-Geometric Mean formula
> > for
> > pi IIRC. This converges quadratically, and it will calculate you a
> > million places without breaking a sweat.
>
> It would be nice if that were documented. What do I have to do, go get
> the documentation for the original GMP to find out what else is in GMPY
> that they didn't include in the doc file?
"pydoc gmpy" works for me. Not sure how you use pydoc on windows, but
you can do this...
>>> import gmpy
>>> help(gmpy)
Help on module gmpy:
NAME
gmpy
FILE
/usr/lib/python2.3/site-packages/gmpy.so
[snip]
Help on built-in function pi:
pi(...)
pi(n): returns pi with n bits of precision in an mpf object
[snip]
The original gmp documentation is sensible also, since gmpy is really
just a thin wrapper to it. There is also the gmp source code too.
--
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick
More information about the Python-list
mailing list