Ask Your Question

Problem outputting inequalities

asked 2013-10-21 01:43:27 -0600

Eric Gaul gravatar image

The following code :

x, y, z = var('x, y, z')
x < y < z

outputs :

x < y

but the "< z" seems to be taken into account, as in :

x, y, z = var('x, y, z')
x = 1; y = 2; z = 0 
x < y < z

which prints "False".

Analogous behavior with :

x, y, z = var('x, y, z')
# x = 1; y = 0; z = 0;
x < y or x < z

Is there a way to make Sage prints the entire expression ? It seems like a bug when printing expression containing multiple inequalities.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-10-21 02:23:13 -0600


An expression is made of an operator and a sequence of expressions as in

sage: var('x,y,z')
sage: E = x + y + z
sage: E.operator()
<function operator.add>
sage: E.operands()
[x, y, z]

Now, x < y < z is just a writing convention: it is equivalent to neither (x < y) < z or x < (y < z). It hence does not make sense to consider it as an expression from the computer point of vue. But, you are right when we write such thing in math we would like (x < y) AND (y < z) which should be a valid expression. But it seems that Sage does not support the logical and as an expression... this is a pitty !

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


Asked: 2013-10-21 01:43:27 -0600

Seen: 48 times

Last updated: Oct 21 '13