[SciPy-user] Can SciPy compute ln(640320**3 + 744)/163**.5 to 30 places?
robert.kern at gmail.com
Mon Jan 15 01:47:48 CST 2007
Dick Moores wrote:
> On 1/14/07, Robert Kern <robert.kern at gmail.com> wrote:
>> Dick Moores wrote:
>>> Please show me how to do that in just plain python. I don't have or
>>> know ipython.
>> It's the same.
> OK. Bryan Van de Ven's code lacked an import statement, a precision
> statement, and a print statement. So I tried
> # clnumTest2-a.py
> import clnum as cl
> a = cl.log(640320**3 + 744)/cl.sqrt(163)
> print cl.mpq(a)
> And got
> Doing that division at the python interactive prompt gets me
> hardly the precision I'm after.
> Someone please show me a whole python script.
Fernando already gave you exactly what you needed. You just printed it wrong.
Doing the string interpolation through '%.50f' casts the number to a Python
float object (16 decimal places of precision). If you were you simply print the
object that is the result of the computation (`a` above), you will get the
answer that you are looking for. As you can see from what Fernando showed you,
there is in fact 50 digits of precision using clnum:
In : import clnum as n
In : n.set_default_precision(50)
In : n.log(640320**3 + 744)/n.sqrt(163)
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the SciPy-user