Efficient Force Function Evaluation Methods
June 9, 1996
1.3 on page
17, there were two types of errors that were mentioned.
First, there is the discretization error and the minimization of that error was the chief
concern of Sections 2.0 and 3.0. The other type of error that was mentioned was floating
point rounding errors, but it was noted that as long as the step size was sufficiently large,
this was not a primary concern. In the evaluation of the force function, this is not the case
and the effects of rounding errors can be quite pronounced. For this reason, a brief discus-
sion of the cause and effects of rounding errors is in order.
Internally, computers keep floating point (non-integral) numbers in a format that
has a fixed number of significant digits, while the decimal point can float to the left or
right. While most modern computers can have at least 15 significant digits, for easy of
illustration, let us assume that the computer can only store 4 significant digits. So, we can
have numbers such as 3.141, 100, 0.0000456, and 1E+99, but we can't have numbers such
as 3.1415, 100.01, or 0.000045678. When the computer adds two numbers together, often
the result has more than 4 significant digits. In order to store result, it is necessary to round
the result to 4 significant digits.
As an example, say the computer has to add 3.141 to 100. The exact result would
be 103.141, but that has 6 significant digits. The computer would then round the result to
be just 103.1, losing the 0.041 from the result. It may not be obvious, but this means that
addition is no longer commutative. Say the computer was to calculate 0.005 + 3.141 +
100. If the computer adds the first two numbers together, it will get 3.191 and then when
100 is added to this result, the computer will end up with 103.2. On the other hand, if the
computer adds 3.141 and 100 together first and gets the result of 103.1, when it tries to add
the 0.005 to this number, the result will still be 109.1. The addition of 0.005 had no effect
For the evaluation of
, the lack of commutativity of addition and the inverse
square nature of each term of
interact very poorly. Say there is a binary star system on
the edge of a galaxy (a common occurrence). The force between the two stars in the
system will be very large, but all the stars in the center of the galaxy or on the other side of
the galaxy will each have a very small effect. When the computer is adding together the
terms in the force function, if it adds together the force from the other binary star first, all
the other stars in the galaxy may, individually, not be significant enough to change the
final force. The result would be that the binary star system would act as if it was not in the
galaxy at all and just drift off. On the other hand, if the other binary star is added in last,
the result will be much more accurate.
A second type of problem with rounding can occur when two numbers of opposite
signs are added together. If there are two numbers which are exactly represented by
8.1414926 and -8.1413867, the computer will have to represent them as 8.141 and -8.141.
If you add these two numbers together, the exact result should be 0.001059 which can be
exactly represented with 4 digits, but the computer will calculate the result as being zero.
This document is best viewed as n-body.pdf because the translation to html was buggy.