Sage: Ticket #6816: [with patch, needs review] sage/maxima hang when doing an indefinite integral
https://trac.sagemath.org/ticket/6816
<p>
Integration sometimes hangs in sage-4.1.1.
</p>
<pre class="wiki">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 ..]
</pre><p>
In fact, in Maxima what is happening is the following:
</p>
<pre class="wiki">(%i6) integrate(t*cos(-theta*t),t,-inf,inf);
Is theta positive, negative, or zero?
positive <--- i type this.
;
(%o6) 0
(%i7)
</pre><p>
For some reason the question "Is theta positive, negative, or zero?" is not getting seen by pexpect as it should. Argh!
</p>
<p>
This works in Maxima:
</p>
<pre class="wiki">(%i1) assume(theta>0);
(%o1) [theta > 0]
(%i2) integrate(t*cos(-theta*t),t,-inf,inf);
(%o2) 0
</pre><p>
The same doesn't work in Sage though, which is very weird:
</p>
<pre class="wiki">sage: var('t,theta')
(t, theta)
sage: assume(theta>0)
sage: integrate(t * cos(-theta*t), (t,-oo,oo))
</pre>en-usSagehttps://trac.sagemath.org/chrome/site/logo_sagemath_trac.png
https://trac.sagemath.org/ticket/6816
Trac 1.1.6kcrismanThu, 24 Sep 2009 13:49:10 GMT
https://trac.sagemath.org/ticket/6816#comment:1
https://trac.sagemath.org/ticket/6816#comment:1
<p>
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.
</p>
<p>
But it still hangs in Sage. That is really strange. Note that the indefinite integral works fine in Sage.
</p>
TicketkcrismanMon, 05 Oct 2009 15:45:51 GMTmilestone changed
https://trac.sagemath.org/ticket/6816#comment:2
https://trac.sagemath.org/ticket/6816#comment:2
<ul>
<li><strong>milestone</strong>
changed from <em>sage-4.1.3</em> to <em>sage-duplicate/invalid/wontfix</em>
</li>
</ul>
<p>
This ticket is invalid.
</p>
<pre class="wiki">sage: var('t,theta')
(t, theta)
sage: integrate(t*cos(-theta*t),t,-oo,oo)
0
</pre><p>
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 <a class="closed ticket" href="https://trac.sagemath.org/ticket/1221" title="enhancement: Consider using Mathematica syntax for integration (closed: fixed)">#1221</a> or <a class="new ticket" href="https://trac.sagemath.org/ticket/2787" title="enhancement: make the interface to integrate() like the (new consistent) interface ... (new)">#2787</a> in Sage. But those tickets already exist.
</p>
TicketwasMon, 05 Oct 2009 15:52:51 GMTmilestone changed
https://trac.sagemath.org/ticket/6816#comment:3
https://trac.sagemath.org/ticket/6816#comment:3
<ul>
<li><strong>milestone</strong>
changed from <em>sage-duplicate/invalid/wontfix</em> to <em>sage-4.1.3</em>
</li>
</ul>
<p>
I don't consider this ticket invalid. The fact that Sage totally hangs without an error is bad. Independent of implementing <a class="closed ticket" href="https://trac.sagemath.org/ticket/1221" title="enhancement: Consider using Mathematica syntax for integration (closed: fixed)">#1221</a> and <a class="new ticket" href="https://trac.sagemath.org/ticket/2787" title="enhancement: make the interface to integrate() like the (new consistent) interface ... (new)">#2787</a>, we could easily and quickly improve the type checking of the input to integrate.
</p>
TicketkcrismanMon, 05 Oct 2009 15:55:41 GMT
https://trac.sagemath.org/ticket/6816#comment:4
https://trac.sagemath.org/ticket/6816#comment:4
<p>
Good point.
</p>
TicketkcrismanMon, 05 Oct 2009 16:19:30 GMTsummary changed; author set
https://trac.sagemath.org/ticket/6816#comment:5
https://trac.sagemath.org/ticket/6816#comment:5
<ul>
<li><strong>author</strong>
set to <em>Karl-Dieter Crisman</em>
</li>
<li><strong>summary</strong>
changed from <em>sage/maxima hang when doing an indefinite integral</em> to <em>[with patch, needs review] sage/maxima hang when doing an indefinite integral</em>
</li>
</ul>
<p>
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.
</p>
TicketwasMon, 05 Oct 2009 16:28:56 GMT
https://trac.sagemath.org/ticket/6816#comment:6
https://trac.sagemath.org/ticket/6816#comment:6
<p>
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.
</p>
TicketkcrismanTue, 20 Oct 2009 06:23:09 GMTattachment set
https://trac.sagemath.org/ticket/6816
https://trac.sagemath.org/ticket/6816
<ul>
<li><strong>attachment</strong>
set to <em>trac_6816-tuples-in-integral.patch</em>
</li>
</ul>
<p>
Based on 4.2.alpha0
</p>
TicketkcrismanTue, 20 Oct 2009 06:23:37 GMT
https://trac.sagemath.org/ticket/6816#comment:7
https://trac.sagemath.org/ticket/6816#comment:7
<p>
Rebased, otherwise should be fine.
</p>
TicketkcrismanWed, 28 Oct 2009 01:13:05 GMT
https://trac.sagemath.org/ticket/6816#comment:8
https://trac.sagemath.org/ticket/6816#comment:8
<p>
Now that <a class="closed ticket" href="https://trac.sagemath.org/ticket/7327" title="defect: Make integrate accept a variable range as a tuple (closed: fixed)">#7327</a> has been opened, one of these two is a duplicate.
</p>
TicketjasonWed, 28 Oct 2009 01:28:40 GMTstatus changed
https://trac.sagemath.org/ticket/6816#comment:9
https://trac.sagemath.org/ticket/6816#comment:9
<ul>
<li><strong>status</strong>
changed from <em>needs_review</em> to <em>needs_work</em>
</li>
</ul>
<p>
Hmm...that code looks pretty long. Why not just:
</p>
<pre class="wiki">if 1<=len(v)<=3:
return integral(expression,*v)
</pre><p>
and take care of all three cases in one swoop?
</p>
<p>
Also, it completely ignores the rest of the parameters in the function call, like algorithm, etc.
</p>
TicketkcrismanThu, 05 Nov 2009 17:45:26 GMTcc set
https://trac.sagemath.org/ticket/6816#comment:10
https://trac.sagemath.org/ticket/6816#comment:10
<ul>
<li><strong>cc</strong>
<em>mhansen</em> added
</li>
</ul>
<p>
To release manager: please close this as a duplicate of <a class="closed ticket" href="https://trac.sagemath.org/ticket/7327" title="defect: Make integrate accept a variable range as a tuple (closed: fixed)">#7327</a>, where a patch including the doctests for the specific bug above resides.
</p>
TicketmhansenFri, 06 Nov 2009 05:53:32 GMTstatus, milestone changed; resolution set
https://trac.sagemath.org/ticket/6816#comment:11
https://trac.sagemath.org/ticket/6816#comment:11
<ul>
<li><strong>status</strong>
changed from <em>needs_work</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>duplicate</em>
</li>
<li><strong>milestone</strong>
changed from <em>sage-4.2.1</em> to <em>sage-duplicate/invalid/wontfix</em>
</li>
</ul>
TicketkcrismanTue, 22 Dec 2009 16:30:25 GMTupstream set
https://trac.sagemath.org/ticket/6816#comment:12
https://trac.sagemath.org/ticket/6816#comment:12
<ul>
<li><strong>upstream</strong>
set to <em>N/A</em>
</li>
</ul>
<p>
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 <a class="closed ticket" href="https://trac.sagemath.org/ticket/7745" title="enhancement: Update Maxima to 5.20.1 (closed: fixed)">#7745</a>, since Maxima 5.20.1 simply returns that integral now, as opposed to giving 0.
</p>
Ticket