ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 03 Mar 2019 18:09:16 +0100Error in false statementhttps://ask.sagemath.org/question/45623/error-in-false-statement/Hello
I write in SAGE the following
p=0+0*I
q=1/2+1/2*I
r=3/4+1/3*I
(real(p)==real(q))==false
and it returns "false", but it is true because 0 is not equal to 1/2. Why?Sun, 03 Mar 2019 17:10:55 +0100https://ask.sagemath.org/question/45623/error-in-false-statement/Answer by vdelecroix for <p>Hello</p>
<p>I write in SAGE the following</p>
<pre><code>p=0+0*I
q=1/2+1/2*I
r=3/4+1/3*I
(real(p)==real(q))==false
</code></pre>
<p>and it returns "false", but it is true because 0 is not equal to 1/2. Why?</p>
https://ask.sagemath.org/question/45623/error-in-false-statement/?answer=45625#post-id-45625The operation
real(p) == real(q)
creates an "inequality". As you can check, the output prints as
>> real(p) == real(q)
0 == (1/2)
You know that the above is false but it is not automatically evaluated within Sage. If you want to force the evaluation you need to run
>>> bool(real(p) == real(q))
FalseSun, 03 Mar 2019 17:55:57 +0100https://ask.sagemath.org/question/45623/error-in-false-statement/?answer=45625#post-id-45625Comment by creyesm1992 for <p>The operation</p>
<pre><code>real(p) == real(q)
</code></pre>
<p>creates an "inequality". As you can check, the output prints as</p>
<pre><code>>> real(p) == real(q)
0 == (1/2)
</code></pre>
<p>You know that the above is false but it is not automatically evaluated within Sage. If you want to force the evaluation you need to run</p>
<pre><code>>>> bool(real(p) == real(q))
False
</code></pre>
https://ask.sagemath.org/question/45623/error-in-false-statement/?comment=45626#post-id-45626thank you very much :-) !!!!!!!!!!!!!!!!!Sun, 03 Mar 2019 18:09:16 +0100https://ask.sagemath.org/question/45623/error-in-false-statement/?comment=45626#post-id-45626