Newton's second law of motion for a particle of mass moving under
the influence of a force
is
In PHYS 105 you studied the kinematics of uniformly accelerated motion to compute the trajectory of a projectile under gravity, with the inclusion of various complicating factors, such as air resistance, and variation of gravity with height. We repeat some of these solutions here.
A Simple Integration Scheme
The basic idea in numerical integration of the particle's equation of
motion is to subdivide the trajectory into many short pieces--for
simplicity, let's imagine that we describe the motion as a series of
time segments, each of constant duration . The key (which
also seems intuitively reasonable) is to choose
sufficiently short that the force
may be regarded as constant during the interval. You can quickly convince yourself
that, if
is sufficiently ``well behaved''--differentiable,
or even just continuous--that this requirement on
can
always be met by choosing a sufficiently short time step
.
Having made the assumption that may be regarded as constant,
we can easily connect the positions and velocities at the start and
end of the step. More precisely, if we let
,
, and
represent
the state of the system at the end if the
-th step, and we define
, we can write
![]() |
![]() |
![]() |
|
![]() |
![]() |
![]() |
|
![]() |
![]() |
![]() |
Note that the map is explicit--the procedure for getting from
state to state
depends only on quantities determinable at
time
. At time
, a new
is computed, and the process
repeats.
Exercise 1: Write a program to follow the
(1-dimensional) motion of mass moving under the influence of a
restoring force
, with ``spring constant''
, starting
with
,
.
Plot your numerical solution
and compare it with the analytic solution
, for
and
.
The equations presented above were not in the standard form usually adopted when we derive and express numerical algorithms for the solutions of ODEs, nor is the scheme as stated widely used. Nevertheless, the approach serves as a quite intuitive introduction to the subject.
Numerical Errors
A numerical integration scheme such as the one just described solves an approximation to the true differential equation. Thus, it necessarily makes errors--deviations between the numerical and the true solution that have nothing to do with mistakes in the program, nor misconceptions on the part of the programmer. Errors are part and parcel of the approximations underlying the scheme.
In our case, since we approximate by a constant for the
duration of each step, if
is differentiable is is clear that
the error we incur in
is
--actually
, the next term in the Taylor series expansion of
, which we explicitly throw away. The corresponding errors
in
and
at the end of the step are evidently
and
, respectively. The lowest power
of
appearing in the error terms is referred to as the order of the integration scheme. The total error in the calculation
is the accumulation of these errors over all steps. Understanding
these errors and how they scale with
is critical to any
study of numerical integration.
Exercise 2: Analyze the errors in the numerical solution of Newton's equation in exercise #1.
Realistic Numerical Errors
Your results from the exercise above should be at
odds with the discussion of errors just presented. You should have
found that, for any choice of for which an analytic solution
is known, both the position and the velocity errors scale only as the
first power of
--in other words, reducing the
time step results in a far smaller improvement in accuracy than the
earlier analysis would suggest. Why is this?
Part of the problem comes from the fact that the errors in our scheme
are coherent, that is, errors in successive steps tend to be of
the same sign--they don't jump around randomly. Thus, if the error
after one step is , then the error after two is roughly
, the error after
is
, and so on. (We
assume here that the neglected terms in
don't vary
too much with time.) Since we are normally interested in integrating
across a fixed time interval, the number of steps needed varies
as
. We thus immediately lose one power of
in our error assessments when we move from integration over
a single step to integration over an interval.
A second problem is that the order of the integration is
greater than that of the
integration. Applying the
reasoning of the previous paragraph, we come to the conclusion that
the net scaling of the error in
is linear in
, as
observed. However, this in turn affects the
integration,
since
appears in the second term. The result is that the
per-step error in
acquires a term of the form
, i.e.
, and this becomes
when
integrated over a finite interval. The error in
actually
overwhelms any benefit of including the
term! You can verify this for yourself by simply omitting this
term from your program.
Better Integration Schemes
Newton's equation of motion
In the following sections we will systematically describe better integration schemes to solve such coupled systems of ordinary first order differential equations.