Ask Your Question
1

Interactive question in notebooks

asked 2012-01-21 10:25:29 +0100

Green diod gravatar image

updated 2012-01-21 16:46:27 +0100

When trying to find some solution to the double integral problem 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.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2012-01-21 13:12:53 +0100

god.one gravatar image

Hi, 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)
edit flag offensive delete link more

Comments

Ok, thanks, that solves this particular question. But in general, how can one answer to interactive questions?

Green diod gravatar imageGreen diod ( 2012-01-21 15:42:34 +0100 )edit

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

god.one gravatar imagegod.one ( 2012-01-21 16:00:48 +0100 )edit

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

Green diod gravatar imageGreen diod ( 2012-01-21 16:30:25 +0100 )edit

You are correct.

kcrisman gravatar imagekcrisman ( 2012-01-21 16:49:52 +0100 )edit
0

answered 2012-01-21 17:47:35 +0100

achrzesz gravatar image

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

edit flag offensive delete link more

Comments

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

Green diod gravatar imageGreen diod ( 2012-01-21 18:34:17 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-01-21 10:25:29 +0100

Seen: 773 times

Last updated: Jan 21 '12