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.Thu, 23 Apr 2020 09:47:38 +0200Strange behavior of bool()https://ask.sagemath.org/question/50942/strange-behavior-of-bool/Here is my code
var("w0, pi, D, I")
A = matrix(SR, 2, 2, [[w0, 1],[w0-pi,1]])
y = vector([w0-D, w0-D-pi+I])
sol=A.solve_right(y)
sola=sol[0].full_simplify().function(D, pi, I, w0)
solb=sol[1].full_simplify().function(D, pi, I, w0)
f(x, D, pi, I, w0)=sola*x + solb
show(f(x, D, pi, I, w0))
f_x = f.diff(x).full_simplify()
show(f_x)
f_I = f.diff(I).full_simplify()
show(f_I)
Now, I make some assumptions and I verify the sign of $f_x$ and $f_I$.
assume(I, "real")
assume(pi, "real")
assume(I > pi)
bool(f_x < 0)
assume(w0, "real")
assume(x, "real")
assume(w0 > x)
bool(f_I > 0)
What is weird is that the result doesn't change should I ask for `bool(f_x < 0)` or ` bool(f_x > 0)` and the same for $f_I$. I know that my question looks like an already asked question "symbolic functions and bool". But this time the expressions are elementary.Thu, 23 Apr 2020 06:41:02 +0200https://ask.sagemath.org/question/50942/strange-behavior-of-bool/Comment by Cyrille for <p>Here is my code</p>
<pre><code>var("w0, pi, D, I")
A = matrix(SR, 2, 2, [[w0, 1],[w0-pi,1]])
y = vector([w0-D, w0-D-pi+I])
sol=A.solve_right(y)
sola=sol[0].full_simplify().function(D, pi, I, w0)
solb=sol[1].full_simplify().function(D, pi, I, w0)
f(x, D, pi, I, w0)=sola*x + solb
show(f(x, D, pi, I, w0))
f_x = f.diff(x).full_simplify()
show(f_x)
f_I = f.diff(I).full_simplify()
show(f_I)
</code></pre>
<p>Now, I make some assumptions and I verify the sign of $f_x$ and $f_I$.</p>
<pre><code>assume(I, "real")
assume(pi, "real")
assume(I > pi)
bool(f_x < 0)
assume(w0, "real")
assume(x, "real")
assume(w0 > x)
bool(f_I > 0)
</code></pre>
<p>What is weird is that the result doesn't change should I ask for <code>bool(f_x < 0)</code> or <code>bool(f_x > 0)</code> and the same for $f_I$. I know that my question looks like an already asked question "symbolic functions and bool". But this time the expressions are elementary.</p>
https://ask.sagemath.org/question/50942/strange-behavior-of-bool/?comment=50949#post-id-50949I have resolved my problem but an other one rise. How to tell Sagemath that 0 should be considerer a real not an integer ? (It's for the cas where I add '>=' to all the inequalities)Thu, 23 Apr 2020 09:47:38 +0200https://ask.sagemath.org/question/50942/strange-behavior-of-bool/?comment=50949#post-id-50949Answer by Cyrille for <p>Here is my code</p>
<pre><code>var("w0, pi, D, I")
A = matrix(SR, 2, 2, [[w0, 1],[w0-pi,1]])
y = vector([w0-D, w0-D-pi+I])
sol=A.solve_right(y)
sola=sol[0].full_simplify().function(D, pi, I, w0)
solb=sol[1].full_simplify().function(D, pi, I, w0)
f(x, D, pi, I, w0)=sola*x + solb
show(f(x, D, pi, I, w0))
f_x = f.diff(x).full_simplify()
show(f_x)
f_I = f.diff(I).full_simplify()
show(f_I)
</code></pre>
<p>Now, I make some assumptions and I verify the sign of $f_x$ and $f_I$.</p>
<pre><code>assume(I, "real")
assume(pi, "real")
assume(I > pi)
bool(f_x < 0)
assume(w0, "real")
assume(x, "real")
assume(w0 > x)
bool(f_I > 0)
</code></pre>
<p>What is weird is that the result doesn't change should I ask for <code>bool(f_x < 0)</code> or <code>bool(f_x > 0)</code> and the same for $f_I$. I know that my question looks like an already asked question "symbolic functions and bool". But this time the expressions are elementary.</p>
https://ask.sagemath.org/question/50942/strange-behavior-of-bool/?answer=50947#post-id-50947Sorry, I have forget to precise that
assume(I > 0)
assume(pi > 0)
in that case the behavior is normalThu, 23 Apr 2020 09:41:19 +0200https://ask.sagemath.org/question/50942/strange-behavior-of-bool/?answer=50947#post-id-50947