ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 21 Jan 2012 11:34:17 -0600Interactive question in notebookshttps://ask.sagemath.org/question/8650/interactive-question-in-notebooks/When trying to find some solution to [the double integral problem](http://ask.sagemath.org/question/1077/symbolic-expectations-and-double-integrals) and poking around with Sage (4.7.2), I stumbled upon this behavior:
x,y,u,v,p,k=var('x,y,u,v,p,k')
integrate(x+y^k, y)
output (resembles maxima interaction):
Traceback (click to the left of this block for traceback)
...
Is k+1 zero or nonzero?
How can I answer to this (with nonzero)?
**Update**: I accept @god.one solution below as there seems no way as for now to interactively answer those maxima questions. Sat, 21 Jan 2012 03:25:29 -0600https://ask.sagemath.org/question/8650/interactive-question-in-notebooks/Answer by god.one for <p>When trying to find some solution to <a href="http://ask.sagemath.org/question/1077/symbolic-expectations-and-double-integrals">the double integral problem</a> and poking around with Sage (4.7.2), I stumbled upon this behavior:</p>
<pre><code>x,y,u,v,p,k=var('x,y,u,v,p,k')
integrate(x+y^k, y)
</code></pre>
<p>output (resembles maxima interaction):</p>
<pre><code>Traceback (click to the left of this block for traceback)
...
Is k+1 zero or nonzero?
</code></pre>
<p>How can I answer to this (with nonzero)?</p>
<p><strong>Update</strong>: I accept <a href="/users/640/godone/">@god.one</a> solution below as there seems no way as for now to interactively answer those maxima questions. </p>
https://ask.sagemath.org/question/8650/interactive-question-in-notebooks/?answer=13158#post-id-13158Hi, you can use the assume command
x,y,u,v,p,k=var('x,y,u,v,p,k')
assume(k+1!=0)
integrate(x+y^k, y)
which calculates to
x*y + y^(k + 1)/(k + 1)Sat, 21 Jan 2012 06:12:53 -0600https://ask.sagemath.org/question/8650/interactive-question-in-notebooks/?answer=13158#post-id-13158Comment by god.one for <p>Hi, you can use the assume command</p>
<pre><code>x,y,u,v,p,k=var('x,y,u,v,p,k')
assume(k+1!=0)
integrate(x+y^k, y)
</code></pre>
<p>which calculates to</p>
<pre><code>x*y + y^(k + 1)/(k + 1)
</code></pre>
https://ask.sagemath.org/question/8650/interactive-question-in-notebooks/?comment=20474#post-id-20474I do not understand what you mean with interactive questions. It is an error code from sage which gives you information where the error is and what to correct so the code can compile completely.Sat, 21 Jan 2012 09:00:48 -0600https://ask.sagemath.org/question/8650/interactive-question-in-notebooks/?comment=20474#post-id-20474Comment by kcrisman for <p>Hi, you can use the assume command</p>
<pre><code>x,y,u,v,p,k=var('x,y,u,v,p,k')
assume(k+1!=0)
integrate(x+y^k, y)
</code></pre>
<p>which calculates to</p>
<pre><code>x*y + y^(k + 1)/(k + 1)
</code></pre>
https://ask.sagemath.org/question/8650/interactive-question-in-notebooks/?comment=20469#post-id-20469You are correct.Sat, 21 Jan 2012 09:49:52 -0600https://ask.sagemath.org/question/8650/interactive-question-in-notebooks/?comment=20469#post-id-20469Comment by Green diod for <p>Hi, you can use the assume command</p>
<pre><code>x,y,u,v,p,k=var('x,y,u,v,p,k')
assume(k+1!=0)
integrate(x+y^k, y)
</code></pre>
<p>which calculates to</p>
<pre><code>x*y + y^(k + 1)/(k + 1)
</code></pre>
https://ask.sagemath.org/question/8650/interactive-question-in-notebooks/?comment=20475#post-id-20475Ok, thanks, that solves this particular question. But in general, how can one answer to interactive questions?Sat, 21 Jan 2012 08:42:34 -0600https://ask.sagemath.org/question/8650/interactive-question-in-notebooks/?comment=20475#post-id-20475Comment by Green diod for <p>Hi, you can use the assume command</p>
<pre><code>x,y,u,v,p,k=var('x,y,u,v,p,k')
assume(k+1!=0)
integrate(x+y^k, y)
</code></pre>
<p>which calculates to</p>
<pre><code>x*y + y^(k + 1)/(k + 1)
</code></pre>
https://ask.sagemath.org/question/8650/interactive-question-in-notebooks/?comment=20472#post-id-20472I would have preferred to have the possibility to answer nonzero to the above question i.e. interactively as I would in Maxima. But maybe it's not possible and the only solution is to add extra-assumptions and evaluate again as in your proposed solution.Sat, 21 Jan 2012 09:30:25 -0600https://ask.sagemath.org/question/8650/interactive-question-in-notebooks/?comment=20472#post-id-20472Answer by achrzesz for <p>When trying to find some solution to <a href="http://ask.sagemath.org/question/1077/symbolic-expectations-and-double-integrals">the double integral problem</a> and poking around with Sage (4.7.2), I stumbled upon this behavior:</p>
<pre><code>x,y,u,v,p,k=var('x,y,u,v,p,k')
integrate(x+y^k, y)
</code></pre>
<p>output (resembles maxima interaction):</p>
<pre><code>Traceback (click to the left of this block for traceback)
...
Is k+1 zero or nonzero?
</code></pre>
<p>How can I answer to this (with nonzero)?</p>
<p><strong>Update</strong>: I accept <a href="/users/640/godone/">@god.one</a> solution below as there seems no way as for now to interactively answer those maxima questions. </p>
https://ask.sagemath.org/question/8650/interactive-question-in-notebooks/?answer=13161#post-id-13161You can avoid the question:
sage: x,y,u,v,p,k=var('x,y,u,v,p,k')
sage: integrate(x+y^k, y,algorithm='sympy')
x*y + y^(k + 1)/(k + 1)Sat, 21 Jan 2012 10:47:35 -0600https://ask.sagemath.org/question/8650/interactive-question-in-notebooks/?answer=13161#post-id-13161Comment by Green diod for <p>You can avoid the question:</p>
<p>sage: x,y,u,v,p,k=var('x,y,u,v,p,k')</p>
<p>sage: integrate(x+y^k, y,algorithm='sympy')</p>
<p>x*y + y^(k + 1)/(k + 1)</p>
https://ask.sagemath.org/question/8650/interactive-question-in-notebooks/?comment=20465#post-id-20465Could you tell me where this algorithm option is documented? I'm going to try that for my [original problem](http://ask.sagemath.org/question/1077/symbolic-expectations-and-double-integrals)Sat, 21 Jan 2012 11:34:17 -0600https://ask.sagemath.org/question/8650/interactive-question-in-notebooks/?comment=20465#post-id-20465