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

Vincent Nijs v-nijs at kellogg.northwestern.edu
Mon Jan 15 11:54:18 CST 2007


Try putting:

from __future__ import division

At the top of your program. This wil make division on integers act like
'true' division.

Then your calculation will work fine:

In [1]: from __future__ import division
In [2]: import numpy as n
In [3]: n.exp(n.log(5/23)*2/7)
0.646607324065

Vincent


On 1/15/07 10:52 AM, "Dick Moores" <rdm at rcblue.com> wrote:

> That's great! Thanks!
> 
> Now, how about something such as (5/23)**(2/7)?
> print repr(n.exp(n.log(5/23)*2/7))
> gets ValueError: log domain error
> 
> Dick
> 
> At 06:45 AM 1/15/2007, you wrote:
> 
>> Hi,
>> 
>> You should really ask the clnum guy, but I think you need to use exp()
>> and log() instead of pow().  Also, you have to use only integers.
>> 
>> pow(x,y) = exp(log(x)*y)
>> 
>> In your case...
>> 
>> from clnum import *
>> set_default_precision(50)
>> exp(log(2)*39/10)
>> 
>> which gives:
>> 
>> mpf('14.92852786458891865570149225839907467243567942962390462241',55)
>> 
>> -Frank
>> 
>> 
>> Dick Moores wrote:
>>> I hope I may ask another question. I'd like to know how use clnum to
>>> calculate 2**3.9 to a precision of 40. I looked carefully at
>>> http://calcrpnpy.sourceforge.net/clnumManual.html and tried various
>>> things, but to no avail.
>>> 
>>> Despite these words in the manual:
>>> 
>>> "Most of the functions in the clnum module are arbitrary precision
>>> floating point versions of Python builtins. See the Python
>>> documentation in the math, cmath, and builtins sections for the
>>> following functions: acos, acosh, asin, asinh, atan, atan2, atanh,
>>> ceil, cos, cosh, degrees, exp, floor, hypot, log, log10, radians,
>>> round, sin, sinh, sqrt, tan, and tanh."
>>> 
>>> it seems there is no clnum.pow(). Help, please.
>>> 
>>> Thanks,
>>> 
>>> Dick Moores
>>> _______________________________________________
>>> SciPy-user mailing list
>>> SciPy-user at scipy.org
>>> http://projects.scipy.org/mailman/listinfo/scipy-user
>>> 
>> 
>> _______________________________________________
>> SciPy-user mailing list
>> SciPy-user at scipy.org
>> http://projects.scipy.org/mailman/listinfo/scipy-user
> 
> 
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
> 

-- 
Vincent R. Nijs
Assistant Professor of Marketing
Kellogg School of Management, Northwestern University
2001 Sheridan Road, Evanston, IL 60208-2001
Phone: +1-847-491-4574 Fax: +1-847-491-2498
E-mail: v-nijs at kellogg.northwestern.edu
Skype: vincentnijs





More information about the SciPy-user mailing list