Solving differential equations numerically

In MATLAB, differential equations can be solved numerically with the commands `ode45`

, `ode23`

or `ode15s`

. The underlying algorithms of `ode45`

and `ode23`

make use of Runge-Kutta-Fehlberg integration with variable step size, i.e., the algorithm increases the step size when the solution varies less. `ode23`

uses the second and third order formulas, while `ode45`

uses the fourth and fifth order formulas. The routine `ode15s`

uses another integration routine. This routine is specialized in problems, that the previous routines have problems to deal with: so-called stiff differential equations.

The mentioned routines can be applied to sets of first order differential equations of the form:

(5.5) |

Here

Throughout this Section, extensive use is made of function-files to facilitate numerical solving of differential equation. For an explanation of these, see Section 1.6, under "User defined functions".

The form in which `ode23`

is used, is:

`>> [t,y] = ode23('filename',[t0,t1],y0)`

Here `filename' is the name of the .m file in which the differential equation is defined,
`ode23`

first determines in a point the derivative
`ode45`

works with higher order formulas, less integration steps are needed with this command. As a consequence of this, `ode23`

in general gives less smooth figures than `ode45`

. The output of ode gives a vector

**Choice of solver**

For most differential equations, both `ode23`

and `ode45`

are suited. The difference between `ode23`

and `ode45`

is rather subtle: with the same accuracy, `ode23`

will need more time steps, though each time step is calculated faster.

However, for a certain class of differential equations, the stiff differential equations, the previously mentioned solvers will not be able to find an accurate solution, or may need excessive computation times for taking very small time steps. In that case, the problem might be of a class called "Stiff differential equations". For these differential equations, the `ode15s`

is a better choice.

Esteur 2010-03-22