Video and Webinar Series

Solving ODEs in MATLAB

Cleve Moler introduces computation for differential equations and explains the MATLAB ODE suite and its mathematical background. The video series starts with Euler method and builds up to Runge Kutta and includes hands-on MATLAB exercises.

Euler, ODE1 ODE1 implements Euler's method. It provides an introduction to numerical methods for ODEs and to the MATLAB suite of ODE solvers. Exponential growth and compound interest are used as examples.

Midpoint Method, ODE2 ODE2 implements a midpoint method with two function evaluations per step. This method is twice as accurate as Euler's method. A nonlinear equation defining the sine function provides an example. An exercise involves implementing a trapezoid method.

Classical Runge-Kutta, ODE4 ODE4 implements the classic Runge-Kutta method, the most widely used numerical method for ODEs over the past 100 years. Its major shortcoming is the lack of an error estimate. A simple model of the growth of a flame is an example that is used.

Order, Naming Conventions The digits in the name of a MATLAB ODE solver reflect its order and resulting accuracy. A method is said to have order p if cutting the step size in half reduces the error in one step by a factor of two to the power p+1.

Estimating Error, ODE23 ODE23 compares 2nd and 3rd order methods to automatically choose the step size and maintain accuracy. It is the simplest MATLAB solver that has automatic error estimate and continuous interpolant. ODE23 is suitable for coarse accuracy requirements.

ODE45 ODE45 is usually the function of choice among the ODE solvers. It compares 4th and 5th order methods to estimate error and determine step size.

Stiffness, ODE23s, ODE15s A problem is said to be stiff if the solution being sought varies slowly, but there are nearby solutions that vary rapidly, so the numerical method must take small steps to obtain satisfactory results. The flame model demonstrates stiffness.

Systems of Equations An ODE involving higher order derivatives is rewritten as a vector system involving only first order derivatives. The classic Van der Pol nonlinear oscillator is provided as an example. The VdP equation becomes stiff as the parameter is increased.

The MATLAB ODE Suite The MATLAB documentation provides two charts summarizing the features of each of the seven functions in the MATLAB ODE suite.

Tumbling Box Throw a rectangular box with sides of three different lengths into the air. You can get the box to tumble stably about its longest axis or its shortest axis. But if you try to make it tumble about it middle axis, you will find the motion is unstable.

Predator-Prey Equations The classic Lotka-Volterra model of predator-prey competition is a nonlinear system of two equations, where one species grows exponentially and the other decays exponentially in the absence of the other. The program "predprey" studies this model.

Lorenz Attractor and Chaos The Lorenz chaotic attractor was discovered by Edward Lorenz in 1963 when he was investigating a simplified model of atmospheric convection. It is a nonlinear system of three differential equations. The program "lorenzgui" studies this model.