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.Mon, 03 Nov 2014 11:26:53 +0100Evaluation questionhttps://ask.sagemath.org/question/24732/evaluation-question/Please explain to me the difference between the two computations:
lin=2*x - y + 2.0;lin(x=-11/9,y=-4/9)
-2.22044604925031e-16
and
2*(-11/9)-(-4/9)+2.000000000000000000
0.000000000000000000
It has to be a floating point computation, and I'm interested only in the sign of the outcome, which is why the first example gives me trouble.
Fri, 31 Oct 2014 20:56:22 +0100https://ask.sagemath.org/question/24732/evaluation-question/Comment by rws for <p>Please explain to me the difference between the two computations:</p>
<p>lin=2*x - y + 2.0;lin(x=-11/9,y=-4/9) <br/>
-2.22044604925031e-16</p>
<p>and </p>
<p>2*(-11/9)-(-4/9)+2.000000000000000000 <br/>
0.000000000000000000</p>
<p>It has to be a floating point computation, and I'm interested only in the sign of the outcome, which is why the first example gives me trouble.</p>
https://ask.sagemath.org/question/24732/evaluation-question/?comment=24741#post-id-24741Cannot confirm. In sage-6.2 this is both 0.000000000000.Sun, 02 Nov 2014 08:10:44 +0100https://ask.sagemath.org/question/24732/evaluation-question/?comment=24741#post-id-24741Comment by Justin Hynes for <p>Please explain to me the difference between the two computations:</p>
<p>lin=2*x - y + 2.0;lin(x=-11/9,y=-4/9) <br/>
-2.22044604925031e-16</p>
<p>and </p>
<p>2*(-11/9)-(-4/9)+2.000000000000000000 <br/>
0.000000000000000000</p>
<p>It has to be a floating point computation, and I'm interested only in the sign of the outcome, which is why the first example gives me trouble.</p>
https://ask.sagemath.org/question/24732/evaluation-question/?comment=24749#post-id-24749I've had other examples. I'm new at this, so please tell me if there are specs (version, my computer or the like) where I can look for clues to fix this bugMon, 03 Nov 2014 11:26:53 +0100https://ask.sagemath.org/question/24732/evaluation-question/?comment=24749#post-id-24749Answer by Justin Hynes for <p>Please explain to me the difference between the two computations:</p>
<p>lin=2*x - y + 2.0;lin(x=-11/9,y=-4/9) <br/>
-2.22044604925031e-16</p>
<p>and </p>
<p>2*(-11/9)-(-4/9)+2.000000000000000000 <br/>
0.000000000000000000</p>
<p>It has to be a floating point computation, and I'm interested only in the sign of the outcome, which is why the first example gives me trouble.</p>
https://ask.sagemath.org/question/24732/evaluation-question/?answer=24736#post-id-24736 I'm in 6.3. It doesn't automatically offer to update?Fri, 31 Oct 2014 22:28:29 +0100https://ask.sagemath.org/question/24732/evaluation-question/?answer=24736#post-id-24736Answer by FrédéricC for <p>Please explain to me the difference between the two computations:</p>
<p>lin=2*x - y + 2.0;lin(x=-11/9,y=-4/9) <br/>
-2.22044604925031e-16</p>
<p>and </p>
<p>2*(-11/9)-(-4/9)+2.000000000000000000 <br/>
0.000000000000000000</p>
<p>It has to be a floating point computation, and I'm interested only in the sign of the outcome, which is why the first example gives me trouble.</p>
https://ask.sagemath.org/question/24732/evaluation-question/?answer=24735#post-id-24735 In sage 6.4.rc0, they give just the same for me. Which version of sage are you using ?
sage: var('x,y')
(x, y)
sage: lin = 2 * x - y + 2.0
sage: lin.parent()
Symbolic Ring
sage: lin(x=-11/9, y=-4/9)
0.000000000000000
sage: 2 * (-11/9) - (-4/9) + 2.0
0.000000000000000
Fri, 31 Oct 2014 22:12:32 +0100https://ask.sagemath.org/question/24732/evaluation-question/?answer=24735#post-id-24735