[SciPy-user] Can SciPy compute ln(640320**3 + 744)/163**.5 to 30 places?

Fernando Perez fperez.net at gmail.com
Sat Jan 13 14:37:50 CST 2007


On 1/13/07, Scott Ransom <sransom at nrao.edu> wrote:
> On Sat, Jan 13, 2007 at 03:02:42PM -0500, Tommy Grav wrote:
> > Actually if you use floats instead of int is the expression you get
> >
> >  >>> print '%1.32f' % (log(640320.**3. + 744.)/163.**.5)
> > 3.14159265358979311599796346854419
> >  >>> print '%1.32f' % (pi)
> > 3.14159265358979311599796346854419
> >  >>>
>
> Too bad neither of those is close to the real value of the OP's
> relation or the real value of Pi:
>   3.141592653589793238462643383279502884197169....
>
> You can't do better than 15-16 decimal points of precision with
> "normal" double-precision floating point math (which is what
> python and numpy use).

SAGE, which is python-based, offers the python MPFR wrappers as a
builtin, where this computation is trivial.  I've left a computation
here:

http://sage.math.washington.edu:8100/fperez

Feel free to open a new worksheet there to experiment, just name it
uniquely and start playing (the SAGE notebook server is free and open
to the public).

MPFR is LGPL, so it unfortunately can't be included as a scipy
component.  But if LGPL is OK for your work, it's an excellent
library.

Cheers,

f


More information about the SciPy-user mailing list