Numerical Methods in Computational Finance. Daniel J. Duffy
example, theorem 5.2.1 in Øksendal (1998) addresses these issues. We discuss SDEs in more detail in Chapter 13.
3.5 NUMERICAL METHODS FOR ODES
In this section we introduce a class of one-step methods to approximate the solution of ODE system (3.1).
The first step is to replace continuous time by discrete time. To this end, we divide the interval [0, T] into a number of subintervals. We define
In this case we define a set of subintervals
In general, we speak of a non-uniform mesh when the sizes of the subintervals are not necessarily the same. However, in this book we consider in the main a class of finite difference schemes where the N subintervals have the same length (we then speak of a uniform mesh), namely
In general, we define
where
The increment function represents the increment of the approximate solution. In general, the goal is to produce a formula for
where:
Other methods are:
Second-order Ralston method:
and Heun's (improved Euler) method:
This is a predictor-corrector method that also has applications to stochastic differential equations.
In general, explicit Runge–Kutta methods are unsuitable for stiff ODEs.
3.5.1 Code Samples in Python
We show hand-crafted code for the explicit Euler method as well as the schemes (3.22), (3.23) and (3.24). The main reason is to get hands-on experience with coding solvers for ODEs before using production solvers (for example, Python's or Boost C++ odeint libraries), especially for readers for whom numerical ODEs are new, for example readers with an economics or econometrics background. A good strategy is 1) get it working (write your own code and examples), then 2) get it right (use a library with the same examples) and then and only then get it optimised (use a library in a larger application).
The following code is for the methods:
Explicit Euler
Fourth-order Runge–Kutta (RK4)
Second-order Ralston.
Heun