Consider a single differential equation of the type
Replace the derivative by a finite difference:
where
is a term of order
which is neglected
for sufficiently small step size h.
Now if we have a coupled system of first order differential equations of the form:
Then the set
can be computed from the set
by:
The basic algorithm then is:
Get the initial values of
at t = 0
Start the loop:
Calculate the
(the derivatives)
Project the
forward one time step
Go back round the loop till the final time is reached.
The forward difference method is not very accurate because
the derivative is
assumed to hold over the next h seconds. You should be able to see that in
oscillatory problems this will cause the calculation to overshoot
the correct answer
and the oscillation may grow when it should be damped. The method may also be
unstable and small errors may grow rather than be damped out. These problems
can often be overcome by choosing a sufficiently small step size h
but this makes computation relatively slow.