ODE_Solvers

ODE Solvers for Octave and Matlab

In 1999 I assembled a group of numerical integrators for solving Ordinary Differential Equations (ODEs) inOctave, which is an open-source computing environment similar to Matlab. They are simple and easy to read and work well in both Octave and Matlab.

These integrators are freely available through the the Gnu Public License (GPL2). A simple pendulum example that solves the equations of motion using 7 different integration methods compares the solutions and solution time. Download and unzip either the zipfile or tar.gz. Change directories in Octave or Matlab to the ode_solvers/ folder and run pendulum.m. This will run each integrator on a small 2-state dynamic system of ODEs that models the oscillatory damped motion of a pendulum. The total number of function evaluations is reported to the console for each integrator and execution timing results are displayed in a bar chart, assuming you've got Octave plotting setup properly. The different integrators allow comparison between the different orders, step sizes, and local tolerances. The ode45.m solver contains both a Dormand-Prince 4(5) pair along with a Runge-Kutta-Fehlberg 4(5) pair. Fehlberg was an equation solving genius. He derived several embedded integrator pairs by hand. If you saw his development of the 7(8) solver pair encoded in ode78.m you would be amazed. He generated all the coefficients by hand using equation trees. The 7(8) pair was developed in the 1960s for NASA's space program to accurately simulate trajectories orbiting the moon.

Download the individual files here:

  • Readme.txt

  • rk2fixed.m

  • rk4fixed.m

  • rk8fixed.m

  • ode23.m

  • ode45.m

  • ode78.m

  • pendulum.m

  • penddot.m

Download the entire group of them here:

  • ode_v1.15.zip

  • ode_v1.15.tar.gz

Results from Octave 3.6.4 in Cygwin using the X-based gnuplot:

Results from Matlab R2010a:

modified: 26 Jan 2014