ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 17 Aug 2012 06:15:41 +0200assume() command with functionshttps://ask.sagemath.org/question/9190/assume-command-with-functions/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)
False
And even
sage: bool(abs(Q)>0)
False
Am I forgetting or neglecting something?
Thank you
Mon, 30 Jul 2012 12:00:21 +0200https://ask.sagemath.org/question/9190/assume-command-with-functions/Answer by benjaminfjones for <p>How can this be?</p>
<pre><code>sage: x = var('x')
sage: Q = function('Q', x)
sage: assume(x>0)
sage: assume(Q>0)
sage: bool(Q>0)
False
</code></pre>
<p>And even </p>
<pre><code>sage: bool(abs(Q)>0)
False
</code></pre>
<p>Am I forgetting or neglecting something?
Thank you</p>
https://ask.sagemath.org/question/9190/assume-command-with-functions/?answer=13870#post-id-13870The `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.Mon, 30 Jul 2012 13:41:27 +0200https://ask.sagemath.org/question/9190/assume-command-with-functions/?answer=13870#post-id-13870Comment by kcrisman for <p>The <code>assume</code> function doesn't work with symbolic functions. </p>
<p>I think the command <code>assume(Q>0)</code> should raise an exception (it doesn't right now obviously). If you look at the documentation for <code>assume</code> you'll see that all the examples involve symbolic variables only. </p>
<p>On the other hand, the type of <code>Q</code> in your example is <code>sage.symbolic.expression.Expression</code> so maybe this is supposed to work and you've found a bug. I'll dig deeper and see what I can find.</p>
https://ask.sagemath.org/question/9190/assume-command-with-functions/?comment=19314#post-id-19314And cc: me if you end up opening a ticket...Mon, 30 Jul 2012 15:11:42 +0200https://ask.sagemath.org/question/9190/assume-command-with-functions/?comment=19314#post-id-19314Answer by andi for <p>How can this be?</p>
<pre><code>sage: x = var('x')
sage: Q = function('Q', x)
sage: assume(x>0)
sage: assume(Q>0)
sage: bool(Q>0)
False
</code></pre>
<p>And even </p>
<pre><code>sage: bool(abs(Q)>0)
False
</code></pre>
<p>Am I forgetting or neglecting something?
Thank you</p>
https://ask.sagemath.org/question/9190/assume-command-with-functions/?answer=13932#post-id-13932I 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);
assume(P1-Nr*p2+p2-Nr*p0+p0+Nr-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
assume(p0+p2-1<0);
and
Is p2+p0-1 positive or negative?
obviously. Did I get you right, this is not supposed to work?
Thank youThu, 16 Aug 2012 11:46:09 +0200https://ask.sagemath.org/question/9190/assume-command-with-functions/?answer=13932#post-id-13932Comment by brenogil for <p>I guess my problem is related to this one:</p>
<pre><code>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);
assume(P1-Nr*p2+p2-Nr*p0+p0+Nr-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?
</code></pre>
<p>The important parts are</p>
<pre><code>assume(p0+p2-1<0);
</code></pre>
<p>and</p>
<pre><code>Is p2+p0-1 positive or negative?
</code></pre>
<p>obviously. Did I get you right, this is not supposed to work?</p>
<p>Thank you</p>
https://ask.sagemath.org/question/9190/assume-command-with-functions/?comment=19215#post-id-19215Deleted 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. Fri, 17 Aug 2012 06:15:41 +0200https://ask.sagemath.org/question/9190/assume-command-with-functions/?comment=19215#post-id-19215Comment by andi for <p>I guess my problem is related to this one:</p>
<pre><code>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);
assume(P1-Nr*p2+p2-Nr*p0+p0+Nr-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?
</code></pre>
<p>The important parts are</p>
<pre><code>assume(p0+p2-1<0);
</code></pre>
<p>and</p>
<pre><code>Is p2+p0-1 positive or negative?
</code></pre>
<p>obviously. Did I get you right, this is not supposed to work?</p>
<p>Thank you</p>
https://ask.sagemath.org/question/9190/assume-command-with-functions/?comment=19216#post-id-19216I 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.Fri, 17 Aug 2012 06:01:14 +0200https://ask.sagemath.org/question/9190/assume-command-with-functions/?comment=19216#post-id-19216