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

Bryan Van de Ven bryanv at enthought.com
Mon Jan 15 01:44:54 EST 2007


I'm going to go out on a limb here and say that when you do that print, 
the mpf object is first converted to a regular python float, which does 
not have enough precision, of course.

Converting the mpf object to a clnum rational mpq object in ipython:

In [17]: a = cl.log(640320**3 + 744)/cl.sqrt(163)

In [18]: cl.mpq(a)
Out[18]: mpq(181338285223186289202345004581,57721768930156197489438103340)

And then just as check, evaluating this fraction to 50 digits in 
Mathematica:

In[6]:= N[ 181338285223186289202345004581/57721768930156197489438103340,50]

Out[6]= 3.1415926535897932384626433832797266193475498808835

Seems to match up...


Dick Moores wrote:
> On 1/13/07, Fernando Perez <fperez.net at gmail.com> wrote:
> 
>> In [16]: import clnum as n
>>
>> In [17]: n.set_default_precision(50)
>>
>> In [18]: n.log(640320**3 + 744)/n.sqrt(163)
>> Out[18]: mpf('3.141592653589793238462643383279726619347549880883522422293',55)
>>
> 
> I assumed you did that in Python. So I tried it with this script,
> adding a print statement:
> ===================================
> # clnumTest1-a.py
> 
> import clnum as n
> 
> n.set_default_precision(50)
> 
> print "%.50f" % (n.log(640320**3 + 744)/n.sqrt(163))
> ======================================
> result: 3.141592653589793100000000000000
> 
> So clarify, if you would, please.
> 
> Thanks,
> 
> Dick Moores
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
> 




More information about the SciPy-User mailing list