[SciPy-user] Can SciPy compute ln(640320**3 + 744)/163**.5 to 30 places?
Dick Moores
rdmoores at gmail.com
Mon Jan 15 01:56:39 CST 2007
On 1/14/07, Robert Kern <robert.kern at gmail.com> wrote:
> 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
> > cl.set_default_precision(50)
> > a = cl.log(640320**3 + 744)/cl.sqrt(163)
> >
> > print cl.mpq(a)
> > =====================
> > And got
> > 181338285223186289202345004581/57721768930156197489438103340
> > Doing that division at the python interactive prompt gets me
> > 3.1415926535897927
> > 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 [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)
>
Well if you mean for me to do:
=============================
# clnumTest1-b.py
import clnum as n
n.set_default_precision(50)
print n.log(640320**3 + 744)/n.sqrt(163)
==================================
That gives me 3.1415926535897932385 .
So I STILL don't understand.
Also, what are those In [16]: things all you people use? Is that line
16? If so, line 16 of what?
Dick Moores
More information about the SciPy-user
mailing list