Opened 8 years ago

Closed 8 years ago

## #16643 closed defect (invalid)

# integrate() problem

Reported by: | Ralf Stephan | Owned by: | |
---|---|---|---|

Priority: | major | Milestone: | sage-duplicate/invalid/wontfix |

Component: | symbolics | Keywords: | integration, maxima |

Cc: | Merged in: | ||

Authors: | Reviewers: | Peter Bruin, Ralf Stephan, Karl-Dieter Crisman | |

Report Upstream: | Fixed upstream, but not in a stable release. | Work issues: | |

Branch: | Commit: | ||

Dependencies: | Stopgaps: |

### Description (last modified by )

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/

### Change History (14)

### comment:1 Changed 8 years ago by

### comment:2 Changed 8 years ago by

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

### comment:3 Changed 8 years ago by

Description: | modified (diff) |
---|---|

Summary: | integrate() infinite loop → 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.

### comment:4 Changed 8 years ago by

Description: | modified (diff) |
---|

### comment:5 Changed 8 years ago by

Description: | modified (diff) |
---|

### comment:6 Changed 8 years ago by

Report Upstream: | N/A → Reported upstream. No feedback yet. |
---|

### comment:7 Changed 8 years ago by

Milestone: | sage-6.3 → sage-6.4 |
---|

### comment:9 Changed 8 years ago by

Report Upstream: | Reported upstream. No feedback yet. → Fixed upstream, but not in a stable release. |
---|

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

### comment:10 Changed 8 years ago by

Milestone: | sage-6.4 → sage-duplicate/invalid/wontfix |
---|---|

Reviewers: | → Peter Bruin |

Status: | new → needs_review |

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.

### comment:11 Changed 8 years ago by

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

### comment:12 Changed 8 years ago by

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)

### comment:13 Changed 8 years ago by

Reviewers: | Peter Bruin → Peter Bruin, Ralf Stephan, Karl-Dieter Crisman |
---|---|

Status: | needs_review → positive_review |

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

### comment:14 Changed 8 years ago by

Resolution: | → invalid |
---|---|

Status: | positive_review → closed |

**Note:**See TracTickets for help on using tickets.

This may be a reportable issue upstream:

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.