sagemath / sage

Main repository of SageMath. Now open for Issues and Pull Requests.
https://www.sagemath.org
Other
1.19k stars 412 forks source link

Maxima fails to properly convert some floats to rationals #12152

Open dandrake opened 12 years ago

dandrake commented 12 years ago

From https://groups.google.com/d/topic/sage-devel/JZ54xk51F-E/discussion :

sage: a, b, t = var('a b t')
sage: f(a,b,t) = sin(t)^2/(a + b*cos(t))^2
sage: integrate(f(3/2,1,t), (t,0,2*pi))
-2/5*(sqrt(5) - 3)*pi*sqrt(5)

Works properly, but:

sage: integrate(f(1.5,1,t), (t,0,2*pi))

blows up with

RuntimeError: ECL says: Error executing code in Maxima: CRECIP:
attempted inverse of zero (mod 3)

From the discussion there, this seems to be related to Maxima's attempts to convert floats to rationals, and that Sage turns off such conversion with keepfloat:true.

Upstream: Reported upstream. No feedback yet.

CC: @kcrisman

Component: calculus

Keywords: maxima keepfloat integration

Issue created by migration from https://trac.sagemath.org/ticket/12152

kcrisman commented 12 years ago
comment:1

See the thread above for some additional discussion, in particular about whether to not consider this a bug, and whether one should just disallow integrals with decimal points.

kcrisman commented 11 years ago
comment:2

Here we go - another such report.


(%i1) keepfloat:true;
(%o1)                                true
(%i2) integrate(exp(-5.3*x),x,0,1);

Maxima encountered a Lisp error:

 Argument V is not a INTEGER: 1.0

Automatically continuing.

Based on this ask.sagemath.org post.

I've reported several similar things upstream at this Maxima bug.

kcrisman commented 11 years ago

Upstream: Reported upstream. No feedback yet.

kcrisman commented 11 years ago
comment:3

Interestingly, we never considered the following from an old sage-devel conversation.

No, it means that you have not noticed the value set for ratepsilon,
which governs the tolerance
for conversion of floats to rationals.  It is by default set to
2.0e-8, presumably for "single float"
systems.  It should probably be set to something more like 10e-16 for
double float systems.

Ah, that is very helpful.  In this case the numerical approximations
do indeed agree up to the output of n().  Perhaps we could potentially
go back to keepfloat:false but with whatever the standard precision in
Sage would equate to - Jason, would that help things with matrices?

This would probably keep a lot of problems away, especially since, as Nils says elsewhere, floats and symbolic integrals don't really mix.

Anyway, see also https://sourceforge.net/p/maxima/bugs/2510/#fd1d