ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 21 Oct 2013 02:23:13 -0500Problem outputting inequalitieshttp://ask.sagemath.org/question/10640/problem-outputting-inequalities/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.Mon, 21 Oct 2013 01:43:27 -0500http://ask.sagemath.org/question/10640/problem-outputting-inequalities/Answer by vdelecroix for <p>The following code :</p>
<pre><code>x, y, z = var('x, y, z')
x < y < z
</code></pre>
<p>outputs :</p>
<pre><code>x < y
</code></pre>
<p>but the "< z" seems to be taken into account, as in :</p>
<pre><code>x, y, z = var('x, y, z')
x = 1; y = 2; z = 0
x < y < z
</code></pre>
<p>which prints "False".</p>
<p>Analogous behavior with :</p>
<pre><code>x, y, z = var('x, y, z')
# x = 1; y = 0; z = 0;
x < y or x < z
</code></pre>
<p>Is there a way to make Sage prints the entire expression ?
It seems like a bug when printing expression containing multiple inequalities.</p>
http://ask.sagemath.org/question/10640/problem-outputting-inequalities/?answer=15579#post-id-15579Hi,
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 !Mon, 21 Oct 2013 02:23:13 -0500http://ask.sagemath.org/question/10640/problem-outputting-inequalities/?answer=15579#post-id-15579