Ask Your Question
0

solve_ineq returns strange output

asked 2016-03-13 10:40:27 +0200

Erel Segal-Halevi gravatar image

updated 2016-03-13 10:52:38 +0200

I ask:

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?

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
1

answered 2016-03-13 12:03:36 +0200

tmonteil gravatar image

updated 2016-03-13 13:39:36 +0200

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
edit flag offensive delete link more

Comments

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 13:30:23 +0200 )edit

i updated my answer to explain how.

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

Stats

Asked: 2016-03-13 10:40:27 +0200

Seen: 386 times

Last updated: Mar 13 '16