Ask Your Question

assume() command with functions

asked 2012-07-30 05:00:21 -0500

brenogil gravatar image

How can this be?

sage: x = var('x')
sage: Q = function('Q', x)
sage: assume(x>0)
sage: assume(Q>0)
sage: bool(Q>0)

And even

sage: bool(abs(Q)>0)

Am I forgetting or neglecting something? Thank you

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2012-07-30 06:41:27 -0500

benjaminfjones gravatar image

The assume function doesn't work with symbolic functions.

I think the command assume(Q>0) should raise an exception (it doesn't right now obviously). If you look at the documentation for assume you'll see that all the examples involve symbolic variables only.

On the other hand, the type of Q in your example is sage.symbolic.expression.Expression so maybe this is supposed to work and you've found a bug. I'll dig deeper and see what I can find.

edit flag offensive delete link more


And cc: me if you end up opening a ticket...

kcrisman gravatar imagekcrisman ( 2012-07-30 08:11:42 -0500 )edit

answered 2012-08-16 04:46:09 -0500

andi gravatar image

I guess my problem is related to this one:

var('Nr N1 N2 yr x1 x2 y2 Pr p0 P1 p2')
assume(N1>0, N2>0, Nr>0, Pr>0, p0>0, p2>0, p0+p2-1<0);
h1 = 1/sqrt(2*pi*Nr)*exp(-(yr-(x1+x2))^2/(2*Nr))/sqrt(2*pi*N2)*exp(-(y2-sqrt(Pr/((1-p0)(Nr+P1/(1-p0-p2))))*yr)^2/(2*N2))*(y2-sqrt(Pr/((1-p0)(Nr+P1/(1-p0-p2))))*yr)/Nr*sqrt(Pr/((1-p0)*(Nr+P1/(1-p0-p2))))*yr*(1/(2*(1-p0))-P1/(2*(1-p0-p2)^2*(P1/(1-p0-p2)+Nr)))+1/sqrt(2*pi*N2)*exp(-(y2-sqrt(Pr/((1-p0)(Nr+P1/(1-p0-p2))))*yr)^2/(2*N2))/sqrt(2*pi*Nr)*exp(-(yr-(x1+x2))^2/(2*Nr))*(yr-(x1+x2))/Nr*x1^3/(2*P1); h1
h2 = 1/2*h1(x2=0,x1=sqrt(P1/(1-p0-p2)))+1/2*h1(x2=0,x1=-sqrt(P1/(1-p0-p2))); h2
py2x1x2 = integrate(h2,yr,-oo,oo); py2x1x2
Traceback (click to the left of this block for traceback)
Is  p2+p0-1  positive or negative?

The important parts are



Is  p2+p0-1  positive or negative?

obviously. Did I get you right, this is not supposed to work?

Thank you

edit flag offensive delete link more


I do not really understand the implications of this, even reading the reference. Is there any way to accomplish what I am trying to do? p0 und p2 are just real positive constants the value of which I do not know.

andi gravatar imageandi ( 2012-08-16 23:01:14 -0500 )edit

Deleted that because it was not really an answer. I just meant that even facing similar results, sage does seem to behave differently when trying to solve our problems.

brenogil gravatar imagebrenogil ( 2012-08-16 23:15:41 -0500 )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



Asked: 2012-07-30 05:00:21 -0500

Seen: 808 times

Last updated: Aug 16 '12