Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#6816 closed defect (duplicate)

[with patch, needs review] sage/maxima hang when doing an indefinite integral

Reported by: was Owned by: burcin
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: calculus Keywords:
Cc: mhansen Merged in:
Authors: Karl-Dieter Crisman Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges


Integration sometimes hangs in sage-4.1.1.

flat:~ wstein$ sage
| Sage Version 4.1.1, Release Date: 2009-08-14                       |
| Type notebook() for the GUI, and license() for information.        |
sage: var('t,theta')
(t, theta)
sage: integrate(t * cos(-theta*t), (t,-oo,oo))
[.. and it hangs forever ..]

In fact, in Maxima what is happening is the following:

(%i6) integrate(t*cos(-theta*t),t,-inf,inf);
Is  theta  positive, negative, or zero?

positive       <--- i type this.

(%o6)                                  0

For some reason the question "Is theta positive, negative, or zero?" is not getting seen by pexpect as it should. Argh!

This works in Maxima:

(%i1) assume(theta>0);
(%o1)                             [theta > 0]
(%i2) integrate(t*cos(-theta*t),t,-inf,inf);
(%o2)                                  0

The same doesn't work in Sage though, which is very weird:

sage: var('t,theta')
(t, theta)
sage: assume(theta>0)
sage: integrate(t * cos(-theta*t), (t,-oo,oo))

Attachments (1)

trac_6816-tuples-in-integral.patch (2.1 KB) - added by kcrisman 11 years ago.
Based on 4.2.alpha0

Download all attachments as: .zip

Change History (13)

comment:1 Changed 12 years ago by kcrisman

Just an update; in Maxima 5.19.1 (in Sage, in fact from maxima_console() ) this particular example does not even ask a question but returns zero.

But it still hangs in Sage. That is really strange. Note that the indefinite integral works fine in Sage.

comment:2 Changed 12 years ago by kcrisman

  • Milestone changed from sage-4.1.3 to sage-duplicate/invalid/wontfix

This ticket is invalid.

sage: var('t,theta')
(t, theta)
sage: integrate(t*cos(-theta*t),t,-oo,oo)

In fact, ANY sage integration attempted with the syntax provided by the originator of the ticket will fail!!! That's because (for better or for worse) we don't have #1221 or #2787 in Sage. But those tickets already exist.

comment:3 Changed 12 years ago by was

  • Milestone changed from sage-duplicate/invalid/wontfix to sage-4.1.3

I don't consider this ticket invalid. The fact that Sage totally hangs without an error is bad. Independent of implementing #1221 and #2787, we could easily and quickly improve the type checking of the input to integrate.

comment:4 Changed 12 years ago by kcrisman

Good point.

comment:5 Changed 12 years ago by kcrisman

  • Authors set to Karl-Dieter Crisman
  • Summary changed from sage/maxima hang when doing an indefinite integral to [with patch, needs review] sage/maxima hang when doing an indefinite integral

I am fixing the error, but not actually adding documentation (other than in testing) that this works, because I view that as the proper place of the afore-mentioned tickets, which still need to resolve how backwards-incompatibility will be dealt with and probably have much better ways of dealing with it than my hackish solution. I'm also not accepting lists, just tuples, which I think is reasonable given the syntax of all the other calculus functions.

comment:6 Changed 12 years ago by was

I read it and it looks good. If it passes tests I would give it a positive review.... I don't have time right now.

Changed 11 years ago by kcrisman

Based on 4.2.alpha0

comment:7 Changed 11 years ago by kcrisman

Rebased, otherwise should be fine.

comment:8 Changed 11 years ago by kcrisman

Now that #7327 has been opened, one of these two is a duplicate.

comment:9 Changed 11 years ago by jason

  • Status changed from needs_review to needs_work

Hmm...that code looks pretty long. Why not just:

if 1<=len(v)<=3:
    return integral(expression,*v)

and take care of all three cases in one swoop?

Also, it completely ignores the rest of the parameters in the function call, like algorithm, etc.

comment:10 Changed 11 years ago by kcrisman

  • Cc mhansen added

To release manager: please close this as a duplicate of #7327, where a patch including the doctests for the specific bug above resides.

comment:11 Changed 11 years ago by mhansen

  • Milestone changed from sage-4.2.1 to sage-duplicate/invalid/wontfix
  • Resolution set to duplicate
  • Status changed from needs_work to closed

comment:12 Changed 11 years ago by kcrisman

  • Report Upstream set to N/A

Just an update - it turns out the original integral reported here is not, in fact, convergent - it is an odd function, so the limit of the indefinite integral evaluated at N and -N is 0, though. Fixing this doctest so something mathematically correct happens will be done in #7745, since Maxima 5.20.1 simply returns that integral now, as opposed to giving 0.

Note: See TracTickets for help on using tickets.