I get the following strange result:
(289.575000000000, 289.617000000000, -0.0280000000000200)
My question is: where do those low order digits come from? And how can
I get rid of them?
When you are performing numerical computations on a computer, you always
have an imprecision due to rounding the numbers in the intermediate
computations; you cannot get rid of that. This is an intrinsic
limitation of computers' representations of numbers.
You should always consider the 15th decimal of a numerical answer
produced by a computer as random.
Look at the difference between
sage: a=10/3
sage: a*3
10
Here sage keeps track of the fact that the given number is a composite
object with a numerator and a denominator.
But if I say to Sage that my entry is a numerical approximation :
sage: b=float(10)/float(3)
sage: b
3.3333333333333335
The last digit "5" is more or less unpredictable.
Notice that the ability of Sage to keep correct answer is very specific
to Sage and few other heavy and modern softwares. In plain
python/C/ruby/basic, you will never get (10/3)*3=10.
In order to get back to your question if you want to have exact answer
you have to say Sage that the data are exact figures. Instead of
289.428000000000
you should provide
289428/1000
However in most of cases you don't mind on an error on the 15th decimal.
Even if your unit the billion of euro, the difference between
-0.0280000000000200
and
-0.0280000000000000
is neglectful.
Hope it somewhat answer the question
have a good afternoon
Laurent
--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org