Lecture 4: Introduction to numerical methods for ODEs
We have learnt to solve ODEs with
Mathematica
, and for that purpose we don't need to know much about what
Mathemat-ica
actually does to solve ODEs. However,
Mathematica
is not the final answer to all problems. The solution of verycomplex problems, such as three dimensional fluid dynamics on very large computational grids, may require a C or Fortrancode to achieve the necessary memory and computational efficiency. We will therefore venture a little into the world of numerical methods for the solution of ODEs, and still use
Mathematica,
as a learning tool, to program those methods.
Solving an ODE of order N is equivalent to performing N integrations. As the integral of a function corresponds to thesurface area below the function, each integration involves a computation of that area. The accuracy of a numerical methodfor solving ODEs is therefore the accuracy with which we compute that surface area. For initial value problems, for exam-ple with time as the free variable, the basic idea of most numerical methods is to discretize time into a number of smallintervals, and advance the solution step by step. In other words, we are computing that surface area below the function bysubdividing it into pieces. Each step of the computation then needs to evaluate the area of one of those pieces. The accuracyof the numerical solution increases as the time-step size decreases.The discretization of the problem is equivalent to defining a map that corresponds to the original function. Maps are knownto present chaotic solutions at lower phase-space dimensionality than functions. Two dimensional maps can be chaotic,while differential equations must explore at least a 3 dimensional phase space to exhibit chaotic behavior. That shouldimmediately alert you of a problem for our numerical solutions based on a discretization of the problem: You may start witha system that is not chaotic, and design a numerical scheme corresponding to a map that is instead chaotic, for certain valuesof the parameters or initial conditions. This is far from a simple academic discussion. The
stability
of numerical methods tosolve ODEs is a major concern, especially when advancing in time the solution of partial differential equations, where theother variable (e.g. space dimensions) have also been discretized.We will discuss here the Euler and the Predictor-Corrector schemes. The final problem of this week homework is animplementation of a centered-difference scheme.
The Euler Method
Let's not be too ambitious for now and consider the most simple first-order ODE:
„
v
ÅÅÅÅÅÅÅ
„
t
=
f
H
t
,
v
L
,
v
H
0
L
=
v
o
.
As we said above, the basic idea is to discretize the time into small intervals of size
D
t:
t
n
=
n
D
t
,
n
=
0,1,2,3,....
Discretizing the problem means that, while the integral of the original function could be evaluated at any real value of time,we now instead evaluate the integral of the function only at a finite number of time steps: