Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integrate() problem #16643

Closed
rwst opened this issue Jul 10, 2014 · 16 comments
Closed

integrate() problem #16643

rwst opened this issue Jul 10, 2014 · 16 comments

Comments

@rwst
Copy link

rwst commented Jul 10, 2014

I interrupted Sage after 5min of churning without result:

sage: f=diff((tan(x)+x)*e^tan(x),x)
(tan(x)^2 + 1)*(x + tan(x))*e^tan(x) + (tan(x)^2 + 2)*e^tan(x)
sage: integrate(f,x)

On a faster computer:

sage: %time integrate(f,x)
CPU times: user 3min 58s, sys: 50 ms, total: 3min 58s
Wall time: 3min 58s
integrate((tan(x)^2 + 1)*(x + tan(x))*e^tan(x) + (tan(x)^2 + 2)*e^tan(x), x)

On the other hand, for the equivalent expression

sage: g=e^tan(x)*sec(x)^2*(tan(x)+x)+e^tan(x)*(sec(x)^2+1)
sage: %time integrate(g,x)
RuntimeError: ECL says: In function CAR, the value of the first argument is
  0
which is not of the expected type LIST

which happens in maxima/ECL with abs_integrate loaded, but not in maxima/SBCL. Upstream: https://sourceforge.net/p/maxima/bugs/2781/

Upstream: Fixed upstream, but not in a stable release.

Component: symbolics

Keywords: integration, maxima

Reviewer: Peter Bruin, Ralf Stephan, Karl-Dieter Crisman

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

@rwst rwst added this to the sage-6.3 milestone Jul 10, 2014
@nbruin
Copy link
Contributor

nbruin commented Jul 10, 2014

comment:1

This may be a reportable issue upstream:

Maxima 5.33.0 http://maxima.sourceforge.net
using Lisp ECL 12.12.1
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) display2d: false;

(%o1) false
(%i2) load(abs_integrate);

(%o2) "/usr/local/sage/sage-git/local/share/maxima/5.33.0/share/contrib/integration/abs_integrate.mac"
(%i3) f: diff((tan(x)+x)*exp(tan(x)),x);

(%o3) %e^tan(x)*sec(x)^2*(tan(x)+x)+%e^tan(x)*(sec(x)^2+1)
(%i4) integrate(f,x);

Maxima encountered a Lisp error:

 In function CAR, the value of the first argument is
  0
which is not of the expected type LIST

Automatically continuing.
To enable the Lisp debugger set *debugger-hook* to nil.

Without the load(abs_integrate) the code seems to execute fine (by returning the integral unevaluated). This does not fully explain why sage seems to get stuck on it, though. Perhaps a try/except that is a little too agressive in suppressing problems?

Also, the problem does not arise in Maxima 5.30.0 on SBCL 1.1.8-2, so it may be a problem with maxima-ecl interaction (so it depends a little on how well the maxima-devs want to support ECL)

Also executing domain: complex;load(to_poly_solve);load(simplify_sum); (as we do in sage) doesn't affect the outcome.

@nbruin
Copy link
Contributor

nbruin commented Jul 10, 2014

comment:2

The following helps perhaps to locate the problematic code. The following fragment does complete (but after considerable time):

from sage.interfaces.maxima_lib import *
args=((tan(x)^2 + 1)*(x + tan(x))*e^tan(x) + (tan(x)^2 + 2)*e^tan(x), x)
expr=EclObject(([max_integrate],[sr_to_max(SR(a)) for a in args]))
result=maxima_eval(expr)
max_to_sr(result)

this is the code the integrator would execute, and it does return the integral unevaluated. So somehow we're avoiding the error above.

Indeed, the difference seems to be how you feed the expression. Sage actually DOES return this integral (unevaluated), it just takes longer. The difference is in how you give the integral. The expression for the derivative that maxima computes gives the result above. However, the form computed by sage still works. If you do in maxima

...
(%i6) f: (tan(x)^2 + 1)*(x + tan(x))*exp(tan(x)) + (tan(x)^2 + 2)*exp(tan(x));

(%o6) %e^tan(x)*(tan(x)^2+2)+%e^tan(x)*(tan(x)+x)*(tan(x)^2+1)
(%i7) integrate(f,x);

(%o7) 'integrate(%e^tan(x)*(tan(x)^2+2)+%e^tan(x)*(tan(x)+x)*(tan(x)^2+1),x)

everything is fine.

So the only report for Maxima is the above question why ECL runs into an error for the particular integral given there. This integral is not the one encountered with the original sage script and the sage code does finish correctly (albeit after a rather long time).

@nbruin
Copy link
Contributor

nbruin commented Jul 10, 2014

comment:3

I changed the title and description, because I found evidence there is no infinite loop involved. Please change back if you're unhappy with the change.

@nbruin

This comment has been minimized.

@nbruin nbruin changed the title integrate() infinite loop integrate() problem Jul 10, 2014
@nbruin

This comment has been minimized.

@nbruin

This comment has been minimized.

@kcrisman
Copy link
Member

Upstream: Reported upstream. No feedback yet.

@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@kcrisman
Copy link
Member

kcrisman commented Dec 8, 2014

comment:8

See also #12731.

@kcrisman
Copy link
Member

Changed upstream from Reported upstream. No feedback yet. to Fixed upstream, but not in a stable release.

@kcrisman
Copy link
Member

comment:9

It's claimed that upstream has this 'fixed' in some sense now.

@pjbruin
Copy link
Contributor

pjbruin commented Dec 16, 2014

Reviewer: Peter Bruin

@pjbruin
Copy link
Contributor

pjbruin commented Dec 16, 2014

comment:10

With Maxima 5.34.1 and also with 5.35.1 (see #17514), both integrals are returned unevaluated:

sage: f = diff((tan(x) + x) * e^tan(x), x)
sage: %time integrate(f, x)
CPU times: user 5min 32s, sys: 12 ms, total: 5min 32s
Wall time: 5min 33s
integrate((tan(x)^2 + 1)*(x + tan(x))*e^tan(x) + (tan(x)^2 + 2)*e^tan(x), x)
sage: g = e^tan(x) * sec(x)^2 * (tan(x) + x) + e^tan(x) * (sec(x)^2 + 1)
sage: %time integrate(g,x)
CPU times: user 4min 43s, sys: 128 ms, total: 4min 44s
Wall time: 4min 44s
integrate((x + tan(x))*e^tan(x)*sec(x)^2 + (sec(x)^2 + 1)*e^tan(x), x)

I propose to close this since the ECL error appears to have been fixed upstream and the example takes too long to be a sensible doctest.

@pjbruin pjbruin removed this from the sage-6.4 milestone Dec 16, 2014
@kcrisman
Copy link
Member

comment:11

some terrifyingly huge trig expression

says upstream... though I am agnostic on whether to close this, one could repurpose it as "make this integral faster" and ask upstream for that (or see if Sympy can do it faster, or whatever).

@rwst
Copy link
Author

rwst commented Jan 2, 2015

comment:12

SymPy is much faster to concede defeat.

sage: f=(tan(x)^2 + 1)*(x + tan(x))*e^tan(x) + (tan(x)^2 + 2)*e^tan(x)
sage: %time integrate(f,x)
CPU times: user 5min 45s, sys: 219 ms, total: 5min 45s
Wall time: 5min 45s
integrate((tan(x)^2 + 1)*(x + tan(x))*e^tan(x) + (tan(x)^2 + 2)*e^tan(x), x)
sage: import sympy
sage: x = sympy.Symbol('x')
sage: %time sympy.integrate(f,x)
CPU times: user 9.51 s, sys: 36 ms, total: 9.54 s
Wall time: 9.52 s
Integral((x + tan(x))*(tan(x)**2 + 1)*exp(tan(x)) + (tan(x)**2 + 2)*exp(tan(x)), x)

@kcrisman
Copy link
Member

kcrisman commented Feb 3, 2015

Changed reviewer from Peter Bruin to Peter Bruin, Ralf Stephan, Karl-Dieter Crisman

@kcrisman
Copy link
Member

kcrisman commented Feb 3, 2015

comment:13

Yeah, probably can't have a ticket that says "make integrals that take a long time faster", too vague.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants