# solve_ineq returns strange output

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


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?

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 close merge delete

Sort by ยป oldest newest most voted

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

EDIT

You can recognize the operators by doing:

sage: s[1][0].operator() == operator.eq
True
sage: s[1][1].operator() == operator.gt
True

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?

( 2016-03-13 13:30:23 +0200 )edit

i updated my answer to explain how.

( 2016-03-13 13:39:54 +0200 )edit