Lets say that we want a list of the numbers 0,0.001,0.002 ... 2 if we use srange after some values we have rounding errors:
why? Is this a bug? A quick solution is to use numpy:
but the question remains... why srange doesn't work correctly?
(tested on Sage 5.0.1 & 5.0 & 4.7.2)
asked Jun 27 '12koukourikos
45 ● 6
The point is that these are well within tolerance for 53-bit precision. The numpy stuff is just tricking you with its rounding or something.
I'm sure that someone who understands machine numbers better can say why it's these particular numbers, but that's pretty much the story, I believe. Is there any particular reason why
posted Jun 27 '12kcrisman
6639 ● 13 ● 66 ● 150
This is a problem with floating point arithmetic. Even numpy doesn't do things exactly; it's only a question of magnitude of error. To get it exactly, use exact numbers:
posted Jun 27 '12Jason Grout
3185 ● 7 ● 27 ● 71
posted Jun 29 '12Volker Braun
2238 ● 5 ● 22 ● 52
If SRANGE is performing repeated additions to get these values, then this precision issue is related to the way SAGE handles real number addition.
From Sage Reference Manual @ http://www.sagemath.org/doc/reference/sage/misc/misc.html
Does anyone have a good reference on this issue for SAGE? If I find one I'll update this post.
posted Jun 28 '12trayres
Asked: Jun 27 '12
Seen: 81 times
Last updated: Jun 29 '12
powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.