Runge-Kutta 4th Order ODE Solver

RK4 is a Python library which implements a simple Runge-Kutta solver for an initial value problem.

The rk4() function does not include any error estimator. It takes a single step at a time, requiring the user to control the step size.


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


RK4 is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version.

Related Data and Programs:

LORENZ_ODE, a Python program which approximates solutions to the Lorenz system, creating graphics output using matplotlib.

RKF45, a Python library which implements the Runge-Kutta-Fehlberg ODE solver.


  1. Erwin Fehlberg,
    Low-order Classical Runge-Kutta Formulas with Stepsize Control,
    NASA Technical Report R-315, 1969.
  2. Lawrence Shampine, Herman Watts, S Davenport,
    Solving Non-stiff Ordinary Differential Equations - The State of the Art,
    SIAM Review,
    Volume 18, pages 376-411, 1976.

Source Code:

You can go up one level to the Python source codes.

Last revised on 23 October 2016.