Question or Problem | Answer |
---|---|

How do I choose the error thresholds |
Roughly
speaking, this means that you want |

I want answers that are correct to the precision of the
computer. Why can I not simply set | You can get close to machine precision, but not that
close. The solvers do not allow |

How do I tell the solver that I do not care about getting an accurate answer for one of the solution components? | You can increase the absolute error tolerance |

Question or Problem | Answer |
---|---|

How large a problem can I solve with the ODE suite? | The primary constraints are memory and time. At each
time step, the solvers for nonstiff problems allocate vectors of length If the problem is nonstiff,
or if you are using the |

I am solving a very large system, but only care about
a few of the components of | Yes. The |

What is the startup cost of the integration and how can I reduce it? | The biggest startup cost occurs as the solver attempts
to find a step size appropriate to the scale of the problem. If you
happen to know an appropriate step size, use the |

The first step size that the integrator takes is too large, and it misses important behavior. | You can specify the first step size with the |

Question or Problem | Answer |
---|---|

The solution does not look like what I expected. | If your expectations are correct, then reduce the error tolerances from their default values. A smaller relative error tolerance is needed to accurately solve problems integrated over “long” intervals, as well as problems that are moderately unstable. Check whether there are solution components that stay smaller than their absolute error tolerance for some time. If so, you are not requiring any correct digits in these components. This might be acceptable for these components, but failing to compute them accurately might degrade the accuracy of other components that depend on them. |

My plots are not smooth enough. | Increase the value of |

I am plotting the solution as it is computed and it looks fine, but the code gets stuck at some point. | First verify that the ODE function is smooth near the point where the code gets stuck. If it is not, then the solver must take small steps to deal with this. It might help to break the integration interval into pieces over which the ODE function is smooth. If
the function is smooth and the code is taking extremely small steps,
you are probably trying to solve a stiff problem with a solver not
intended for that purpose. Switch to using one of the stiff solvers |

What if I have the final and not the initial value? | All the solvers of the ODE suite allow you to solve backward
or forward in time. The syntax for the solvers is |

My integration proceeds very slowly, using too many time steps. | First, check that If the ODE function does not change
noticeably on the Finally, make sure that the ODE function is written in an efficient way. The solvers evaluate the derivatives in the ODE function many times. The cost of numerical integration depends critically on the expense of evaluating the ODE function. Rather than recomputing complicated constant parameters at each evaluation, store them in global variables, or calculate them once and pass them to nested functions. |

I know that the solution undergoes a radical change at
time | If you know that there is a sharp change at time If the differential equation has periodic coefficients or solutions, ensure the solver does not step over periods by restricting the maximum step size to the length of the period. |

Can the solvers handle partial differential equations (PDEs) that have been discretized by the method of lines? | Yes, because the discretization produces a system of
ODEs. Depending on the discretization, you might have a form involving
mass matrices, which the ODE solvers provide for. Often the system
is stiff. This is to be expected if the PDE is parabolic, or when
there are phenomena that happen on very different time scales such
as a chemical reaction in a fluid flow. In such cases, use one of
the four stiff solvers If there are many equations,
use the If
the system is not stiff, or not very stiff, then You
can solve parabolic-elliptic partial differential equations in 1-D
directly with the MATLAB |

Can I integrate a set of sampled data? | Not directly. Instead, represent the data as a function
by interpolation or some other scheme for fitting data. The smoothness
of this function is critical. A piecewise polynomial fit such as a
spline can look smooth to the eye, but rough to a solver; the solver
takes small steps where the derivatives of the fit have jumps. Either
use a smooth function to represent the data or use one of the lower-order
solvers ( |

`deval`

| `odeget`

| `odeset`

| `odextend`