Ask Your Question
0

solve_ineq returns strange output

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

Erel Segal-Halevi gravatar image

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

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 06:03:36 -0600

tmonteil gravatar image

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

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 07:30:23 -0600 )edit

i updated my answer to explain how.

tmonteil gravatar imagetmonteil ( 2016-03-13 07:39:54 -0600 )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 04:40:27 -0600

Seen: 40 times

Last updated: Mar 13 '16