Mathematics |
Initial Value Problem Solvers
The ODE solver functions implement numerical integration methods for solving IVPs for ODEs (Equation 14-1). Beginning at the initial time with initial conditions, they step through the time interval, computing a solution at each time step. If the solution for a time step satisfies the solver's error tolerance criteria, it is a successful step. Otherwise, it is a failed attempt; the solver shrinks the step size and tries again.
Mass Matrix and DAE Properties explains how to solve more general problems.
Solvers for Nonstiff Problems
There are three solvers designed for nonstiff problems:
ode45 |
Based on an explicit Runge-Kutta (4,5) formula, the Dormand-Prince pair. It is a one-step solver - in computing , it needs only the solution at the immediately preceding time point, . In general, ode45 is the best function to apply as a "first try" for most problems. |
ode23 |
Based on an explicit Runge-Kutta (2,3) pair of Bogacki and Shampine. It may be more efficient than ode45 at crude tolerances and in the presence of mild stiffness. Like ode45 , ode23 is a one-step solver. |
ode113 |
Variable order Adams-Bashforth-Moulton PECE solver. It may be more efficient than ode45 at stringent tolerances and when the ODE function is particularly expensive to evaluate. ode113 is a multistep solver - it normally needs the solutions at several preceding time points to compute the current solution. |
Solvers for Stiff Problems
Not all difficult problems are stiff, but all stiff problems are difficult for solvers not specifically designed for them. Solvers for stiff problems can be used exactly like the other solvers. However, you can often significantly improve the efficiency of these solvers by providing them with additional information about the problem. (See Changing ODE Integration Properties.)
There are four solvers designed for stiff problems:
ode15s |
Variable-order solver based on the numerical differentiation formulas (NDFs). Optionally it uses the backward differentiation formulas, BDFs, (also known as Gear's method). Like ode113 , ode15s is a multistep solver. If you suspect that a problem is stiff or if ode45 failed or was very inefficient, try ode15s . |
ode23s |
Based on a modified Rosenbrock formula of order 2. Because it is a one-step solver, it may be more efficient than ode15s at crude tolerances. It can solve some kinds of stiff problems for which ode15s is not effective. |
ode23t |
An implementation of the trapezoidal rule using a "free" interpolant. Use this solver if the problem is only moderately stiff and you need a solution without numerical damping. |
ode23tb |
An implementation of TR-BDF2, an implicit Runge-Kutta formula with a first stage that is a trapezoidal rule step and a second stage that is a backward differentiation formula of order 2. Like ode23s , this solver may be more efficient than ode15s at crude tolerances. |
ODE Solver Basic Syntax
All of the ODE solver functions share a syntax that makes it easy to try any of the different numerical methods if it is not apparent which is the most appropriate. To apply a different method to the same problem, simply change the ODE solver function name. The simplest syntax, common to all the solver functions, is
where solver
is one of the ODE solver functions listed previously.
The basic input arguments are:
odefun |
Function that evaluates the system of ODEs. It has the form where t is a scalar, and dydt and y are column vectors. |
tspan |
Vector specifying the interval of integration. The solver imposes the initial conditions at tspan(1) , and integrates from tspan(1) to tspan(end) .For tspan vectors with two elements [t0 tf] , the solver returns the solution evaluated at every integration step. For tspan vectors with more than two elements, the solver returns solutions evaluated at the given time points. The time values must be in order, either increasing or decreasing. |
Specifying tspan with more than two elements does not affect the internal time steps that the solver uses to traverse the interval from tspan(1) to tspan(end) . All solvers in the ODE suite obtain output values by means of continuous extensions of the basic formulas. Although a solver does not necessarily step precisely to a time point specified in tspan , the solutions produced at the specified time points are of the same order of accuracy as the solutions computed at the internal time points. Specifying tspan with more than two elements has little effect on the efficiency of computation, but for large systems, affects memory management. |
|
y0 |
Vector of initial conditions for the problem See also Introduction to Initial Value ODE Problems. |
t |
Column vector of time points |
y |
Solution array. Each row in y corresponds to the solution at a time returned in the corresponding row of t . |
Additional ODE Solver Arguments
For more advanced applications, you can also specify as input arguments solver options and additional problem parameters.
|
Structure of optional parameters that change the default integration properties. This is the fourth input argument. Changing ODE Integration Properties tells you how to create the structure and describes the properties you can specify. |
p1,p2... |
Parameters that the solver passes to odefun . The solver passes any input parameters that follow the options argument to odefun and any functions you specify in options . Use options = [] as a placeholder if you set no options. The function odefun must have the formSee Passing Additional Parameters to an ODE Function for an example. |
Introduction to Initial Value ODE Problems | Solving ODE Problems |