Ask Your Question
0

Evaluation question

asked 2014-10-31 20:56:22 +0200

Justin Hynes gravatar image

updated 2014-10-31 20:56:55 +0200

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.

edit retag flag offensive close merge delete

Comments

Cannot confirm. In sage-6.2 this is both 0.000000000000.

rws gravatar imagerws ( 2014-11-02 08:10:44 +0200 )edit

I'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 bug

Justin Hynes gravatar imageJustin Hynes ( 2014-11-03 11:26:53 +0200 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2014-10-31 22:28:29 +0200

Justin Hynes gravatar image

I'm in 6.3. It doesn't automatically offer to update?

edit flag offensive delete link more
0

answered 2014-10-31 22:12:32 +0200

FrédéricC gravatar image

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
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

Stats

Asked: 2014-10-31 20:56:22 +0200

Seen: 320 times

Last updated: Oct 31 '14