
339 Numerical integration
numbers, in a relative sense. By subtracting the nearly equal numbers, one can lose many
significant digits. Furthermore, roundoff errors become relatively more important if the
truncation errors are drastically reduced by using a very small step size.
To illustrate the nature of roundoff errors, suppose we are given y = e
t
and we desire
to calculate y
n+1
− y
n
for the case t
n
= 10 and h = 0.001. If one uses a calculator which
employs ten decimal digits, the result is
e
10.001
− e
10
= 22048.50328 − 22026.46579
= 22.03749
We notice that, although the numbers to be subtracted are given to ten significant digits, the
result has only seven significant digits, and there is some doubt concerning the accuracy
of the last digit. In order to avoid errors due to the small difference of large numbers, one
should attempt to recast the problem in a form in which the difference is obtained directly,
possibly through a change of variables. For example, in the above problem, we notice that
y
n+1
− y
n
= (e
h
− 1)e
t
n
(6.67)
and we can use a truncated series for the exponential function to obtain
e
h
− 1 = h +
1
2
h
2
+
1
6
h
3
+···
= 10
−3
+
1
2
× 10
−6
+
1
6
× 10
−9
= 1.000500167 × 10
−3
Then
y
n+1
− y
n
= 1.000500167 × 22.02646579 = 22.03748270
This result is accurate to the full ten digits. The improved accuracy is due to the replacement
of a difference by a product involving a convergent series.
Another example in which roundoff errors can become significant occurs in dynamical
problems using Euler angles as generalized coordinates, where these coordinate values are
near a singular point. For type I Euler angles, this singular orientation occurs for the attitude
angle θ near ±π/2. Suppose, for example, that these Euler angles are used in writing the
dynamical equations of a rigid body. A basic physical variable in the rotational dynamics
is the angular velocity component ω
x
, where
ω
x
=
˙
φ −
˙
ψ sin θ (6.68)
For the values of θ near ±π/2, the variables
˙
φ and
˙
ψ may be very large and almost equal,
with ω
x
a relatively small quantity. Thus, we have the small difference of large quantities
entering the equations of motion, and resulting in significant roundoff errors. At the same
time it also may be necessary to use a small step size h in order to keep the truncation
errors under control. Perhaps the best strategy under these conditions is to avoid the use
of Euler angles altogether in the dynamical equations. Another approach such as Euler’s
rotational equations could be used for the dynamics, with the orientation being specified