Hi,
Le lundi 30 mars 2015 06:46:08 UTC+2, William a écrit :
>
> Hi,
>
> If I type
>
> sage: N(sqrt(floor(80000000000*pi) - 1))
>
> I get a number as expected.
>
> If I type
>
> sage: h(x) = (floor(8*pi*10^x)-1)^(1/2)
> sage: a = h(10); a
> sqrt(floor(80000000000*pi) - 1)
>
> that seems fine.
Already at this level, there is something dubious:
sage: a
sqrt(floor(80000000000*pi) - 1)
sage: b = sqrt(floor(80000000000*pi) - 1) ; b
sqrt(251327412286)
> But if I then do
>
> sage: N(a)
> Traceback:
> File
> "/usr/local/sage/sage-6.5/local/lib/python2.7/site-packages/sage/misc/functional.py",
>
>
> line 1298, in numerical_approx return x._numerical_approx(prec,
> algorithm=algorithm) File "sage/symbolic/expression.pyx", line 4874,
> in sage.symbolic.expression.Expression._numerical_approx
> (build/cythonized/sage/symbolic/expression.cpp:27342)
> raise TypeError("cannot evaluate symbolic expression numerically")
>
>
> Any idea what is going on here?
>
>
>
Probably this is to do with the floor function: from the documentation:
The floor function.
The floor of x is computed in the following manner.
1. The "x.floor()" method is called and returned if it is there.
If it is not, then Sage checks if x is one of Python's native
numeric data types. If so, then it calls and returns
"Integer(int(math.floor(x)))".
2. Sage tries to convert x into a "RealIntervalField" with 53
bits of precision. Next, the floors of the endpoints are
computed. If they are the same, then that value is returned.
Otherwise, the precision of the "RealIntervalField" is increased
until they do match up or it reaches "maximum_bits" of
precision.
3. If none of the above work, Sage returns a symbolic
"Expression" object.
I guess that for a, we are in case 3.
Note that
sage: a.simplify()
sqrt(251327412286)
sage: N(a.simplify())
501325.654925020
Best wishes,
Eric.
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.