Ask Your Question

Strange behavior of bool()

asked 2020-04-23 06:41:02 +0200

Cyrille gravatar image

updated 2020-04-23 06:44:51 +0200

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])
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()
f_I = f.diff(I).full_simplify()

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.

edit retag flag offensive close merge delete


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

Cyrille gravatar imageCyrille ( 2020-04-23 09:47:38 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2020-04-23 09:41:19 +0200

Cyrille gravatar image

Sorry, I have forget to precise that

assume(I > 0)
assume(pi > 0)

in that case the behavior is normal

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2020-04-23 06:41:02 +0200

Seen: 165 times

Last updated: Apr 23 '20