Opened 2 months ago

Last modified 5 weeks ago

#16643 new defect

integrate() problem

Reported by: rws Owned by:
Priority: major Milestone: sage-6.4
Component: symbolics Keywords: integration, maxima
Cc: Merged in:
Authors: Reviewers:
Report Upstream: Reported upstream. No feedback yet. Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by nbruin)

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
which is not of the expected type LIST

which happens in maxima/ECL with abs_integrate loaded, but not in maxima/SBCL. Upstream:

Change History (7)

comment:1 Changed 2 months ago by nbruin

This may be a reportable issue upstream:

Maxima 5.33.0
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
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.

comment:2 Changed 2 months ago by nbruin

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]))

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).

comment:3 Changed 2 months ago by nbruin

  • Description modified (diff)
  • Summary changed from integrate() infinite loop to integrate() problem

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.

Last edited 2 months ago by nbruin (previous) (diff)

comment:4 Changed 2 months ago by nbruin

  • Description modified (diff)

comment:5 Changed 2 months ago by nbruin

  • Description modified (diff)

comment:6 Changed 2 months ago by kcrisman

  • Report Upstream changed from N/A to Reported upstream. No feedback yet.

comment:7 Changed 5 weeks ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4
Note: See TracTickets for help on using tickets.