Sage: Ticket #9710: Assumptions not passed to differential equation solver
https://trac.sagemath.org/ticket/9710
<p>
The assume function doesn't seem to work with the differential equation solver, despite what the documentation for desolve suggests. This returns an error:
</p>
<pre class="wiki">sage: x = var('x')
sage: k = var('k')
sage: y = function('y',x)
sage: assume(k>0)
sage: print desolve(diff(y,x,x)+k*y-exp(-k*x),[y,x])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_25.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("eCA9IHZhcigneCcpCmsgPSB2YXIoJ2snKQp5ID0gZnVuY3Rpb24oJ3knLHgpCmFzc3VtZShrPjApCnByaW50IGRlc29sdmUoZGlmZih5LHgseCkrayp5LWV4cCgtayp4KSxbeSx4XSk="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpyNFGr0/___code___.py", line 7, in <module>
exec compile(u'print desolve(diff(y,x,x)+k*y-exp(-k*x),[y,x])
File "", line 1, in <module>
File "/home/kedlaya/sage-complete/local/lib/python2.6/site-packages/sage/calculus/desolvers.py", line 340, in desolve
soln = maxima(cmd)
File "/home/kedlaya/sage-complete/local/lib/python2.6/site-packages/sage/interfaces/expect.py", line 1032, in __call__
return cls(self, x, name=name)
File "/home/kedlaya/sage-complete/local/lib/python2.6/site-packages/sage/interfaces/expect.py", line 1451, in __init__
raise TypeError, x
TypeError: Computation failed since Maxima requested additional constraints (try the command 'assume(k>0)' before integral or limit evaluation, for example):
Is k positive, negative, or zero?
</pre><p>
Found by Praveen N. and Aashita during Sage Days 25 coding sprint.
</p>
en-usSagehttps://trac.sagemath.org/chrome/site/logo_sagemath_trac.png
https://trac.sagemath.org/ticket/9710
Trac 1.1.6kedlayaTue, 10 Aug 2010 02:58:22 GMT
https://trac.sagemath.org/ticket/9710#comment:1
https://trac.sagemath.org/ticket/9710#comment:1
<p>
Observed later: ticket <a class="closed ticket" href="https://trac.sagemath.org/ticket/8931" title="defect: desolve fails when assumptions required (closed: fixed)">#8931</a> is similar, possibly enough so for this to be considered a duplicate. Also, I misread the documentation:
</p>
<pre class="wiki"> This equation can be solved within Maxima but not within Sage. It
needs assumptions assume(x>0,y>0) and works in Maxima, but not in
Sage:
sage: assume(x>0) # not tested
sage: assume(y>0) # not tested
sage: desolve(x*diff(y,x)-x*sqrt(y^2+x^2)-y,y,show_method=True) # not tested
</pre><p>
So no promise is being made, but nonetheless I think this needs to be fixed.
</p>
Ticketrobert.marikTue, 21 Sep 2010 20:12:24 GMT
https://trac.sagemath.org/ticket/9710#comment:2
https://trac.sagemath.org/ticket/9710#comment:2
<p>
with <a class="closed ticket" href="https://trac.sagemath.org/ticket/9961" title="defect: Allow assumptions on the dependent variable in desolve (closed: fixed)">#9961</a>:
</p>
<pre class="wiki">marik@um-bc107:/opt/sage$ ./sage
----------------------------------------------------------------------
| Sage Version 4.5.3, Release Date: 2010-09-04 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
sage: x=var('x'); f=function('f',x); k=var('k'); assume(k>0)
sage: desolve(diff(f,x,2)/f==k,f,ivar=x)
k1*e^(sqrt(k)*x) + k2*e^(-sqrt(k)*x)
</pre>
Ticketrobert.marikTue, 21 Sep 2010 20:20:01 GMT
https://trac.sagemath.org/ticket/9710#comment:3
https://trac.sagemath.org/ticket/9710#comment:3
<p>
In fact, <a class="closed ticket" href="https://trac.sagemath.org/ticket/9835" title="defect: Make desolve more informative when solving BVP (closed: fixed)">#9835</a> is sufficient to solve this problem. The patch <a class="closed ticket" href="https://trac.sagemath.org/ticket/9961" title="defect: Allow assumptions on the dependent variable in desolve (closed: fixed)">#9961</a> which is on the top of <a class="closed ticket" href="https://trac.sagemath.org/ticket/9835" title="defect: Make desolve more informative when solving BVP (closed: fixed)">#9835</a> is not necessary. For the problem from the description we have with <a class="closed ticket" href="https://trac.sagemath.org/ticket/9835" title="defect: Make desolve more informative when solving BVP (closed: fixed)">#9835</a>:
</p>
<pre class="wiki">marik@um-bc107:/opt/sage$ ./sage
----------------------------------------------------------------------
| Sage Version 4.5.3, Release Date: 2010-09-04 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
sage: x = var('x')
sage: k = var('k')
sage: y = function('y',x)
sage: assume(k>0)
sage: desolve(diff(y,x,x)+k*y-exp(-k*x),[y,x])
k1*sin(sqrt(k)*x) + k2*cos(sqrt(k)*x) + e^(-k*x)/(k^2 + k)
sage:
</pre>
Ticketrobert.marikTue, 21 Sep 2010 20:20:23 GMTcc set
https://trac.sagemath.org/ticket/9710#comment:4
https://trac.sagemath.org/ticket/9710#comment:4
<ul>
<li><strong>cc</strong>
<em>robert.marik</em> added
</li>
</ul>
TicketkcrismanMon, 14 Mar 2011 20:45:45 GMTstatus, cc changed; reviewer, milestone set
https://trac.sagemath.org/ticket/9710#comment:5
https://trac.sagemath.org/ticket/9710#comment:5
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>needs_review</em>
</li>
<li><strong>reviewer</strong>
set to <em>Karl-Dieter Crisman</em>
</li>
<li><strong>cc</strong>
<em>kcrisman</em> added
</li>
<li><strong>milestone</strong>
set to <em>sage-4.7</em>
</li>
</ul>
<p>
Yup, and still works. Definitely same issue as <a class="closed ticket" href="https://trac.sagemath.org/ticket/8931" title="defect: desolve fails when assumptions required (closed: fixed)">#8931</a>, which now has positive review.
</p>
<p>
We could add yet another doctest, but in this case there are already so many tests of it, with another one coming at <a class="closed ticket" href="https://trac.sagemath.org/ticket/8931" title="defect: desolve fails when assumptions required (closed: fixed)">#8931</a>, that it seems appropriate to simply say this is a dup.
</p>
<p>
To release manager: please close this ticket.
</p>
TicketkcrismanMon, 14 Mar 2011 20:46:33 GMTstatus changed
https://trac.sagemath.org/ticket/9710#comment:6
https://trac.sagemath.org/ticket/9710#comment:6
<ul>
<li><strong>status</strong>
changed from <em>needs_review</em> to <em>positive_review</em>
</li>
</ul>
<blockquote class="citation">
<p>
We could add yet another doctest, but in this case there are already so many tests of it, with another one coming at <a class="closed ticket" href="https://trac.sagemath.org/ticket/8931" title="defect: desolve fails when assumptions required (closed: fixed)">#8931</a>, that it seems appropriate to simply say this is a dup.
</p>
</blockquote>
<p>
The other tests being from <a class="closed ticket" href="https://trac.sagemath.org/ticket/9961" title="defect: Allow assumptions on the dependent variable in desolve (closed: fixed)">#9961</a> and <a class="closed ticket" href="https://trac.sagemath.org/ticket/9835" title="defect: Make desolve more informative when solving BVP (closed: fixed)">#9835</a>.
</p>
TicketkcrismanMon, 14 Mar 2011 21:04:12 GMTcc changed
https://trac.sagemath.org/ticket/9710#comment:7
https://trac.sagemath.org/ticket/9710#comment:7
<ul>
<li><strong>cc</strong>
<em>jdemeyer</em> added
</li>
</ul>
<p>
Sorry, forgot to actually cc: the release manager.
</p>
TicketjdemeyerWed, 16 Mar 2011 11:09:00 GMTmilestone changed
https://trac.sagemath.org/ticket/9710#comment:8
https://trac.sagemath.org/ticket/9710#comment:8
<ul>
<li><strong>milestone</strong>
changed from <em>sage-4.7</em> to <em>sage-duplicate/invalid/wontfix</em>
</li>
</ul>
TicketjdemeyerThu, 17 Mar 2011 09:46:56 GMTstatus changed; resolution set
https://trac.sagemath.org/ticket/9710#comment:9
https://trac.sagemath.org/ticket/9710#comment:9
<ul>
<li><strong>status</strong>
changed from <em>positive_review</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>duplicate</em>
</li>
</ul>
Ticket