Ask Your Question

solve_ineq returns strange output

asked 2016-03-13 04:40:27 -0500

Erel Segal-Halevi gravatar image

updated 2016-03-13 04:52:38 -0500

I ask:

var("x y")
ineq = [x==y,  y<=0]
s = solve_ineq(ineq,[x]) 

and get:

[[x == y, y], [x == y, -y > 0]]

I understand the second set, but not the first. What does it mean when the inequality is just "y"?

A related question: how do I differentiate between inequalities with "==" or ">" and inequalities without?

Currently, when I ask:

print type(s[0][0])
print type(s[0][1])

I get the same result:

<type 'sage.symbolic.expression.Expression'>
<type 'sage.symbolic.expression.Expression'>
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-03-13 06:03:36 -0500

tmonteil gravatar image

updated 2016-03-13 07:39:36 -0500

For your first question, i guess it is a bug, but it should be inspected further.

For your second question, you can decide which inequalities with the operator() method:

sage: s[1][0].operator()
<built-in function eq>
sage: s[1][1].operator()
<built-in function gt>

(eq stands for "equal", gt stands for "greater than")


You can recognize the operators by doing:

sage: s[1][0].operator() == operator.eq
sage: s[1][1].operator() ==
edit flag offensive delete link more


Thanks! How do I check this in a condition? I can use something like:

if s[1][1].operator() == (x>y).operator():

but this requires x and y to be defined... is there a better way?

Erel Segal-Halevi gravatar imageErel Segal-Halevi ( 2016-03-13 07:30:23 -0500 )edit

i updated my answer to explain how.

tmonteil gravatar imagetmonteil ( 2016-03-13 07:39:54 -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

1 follower


Asked: 2016-03-13 04:40:27 -0500

Seen: 48 times

Last updated: Mar 13 '16