Solving System of ODE using Runge Kutta Fehlberg Method (RK45)

by admin in , , on April 29, 2019

This code solves a multi ordinary differential equations (ODEs) using Runge Kutta Fehlberg Method (RK45), this method has an error estimator of order O(h5). Here you can use both RK4 and RK5, by default the code gives RK5 solution, to use RK4 solution uncomment the line 27 and comment 28.

Code Outputs:

  • Chart for the numerical solutions of all the given equations.
  • Error Value of Runge Kutta Fehlberg Method for all the given equations.

Error of Eq.1 = 0.0034304
Error of Eq.2 = 1.2333e-05
Error of Eq.3 = 6.4083e-08

Input Requirements:

  • ODE you want to solve.
  • Initial Conditions.
  • Initial and Final Integration Terms.
  • Number of interval divisions (Optional)

Editing the Code:

Its easy to modify the code, you need just to add your equations in the separated Fun.m file, then add the initial conditions in the main file, and finally run the code.

Note: By default the code gives RK5 solution, to use RK4 solution uncomment the line 27 and comment 28.

About the Method:

Runge–Kutta–Fehlberg method (or Fehlberg method) is an algorithm in numerical analysis for the numerical solution of ordinary differential equations. It was developed by the German mathematician Erwin Fehlberg and is based on the large class of Runge–Kutta methods.

The novelty of Fehlberg’s method is that it is an embedded method from the Runge–Kutta family, meaning that identical function evaluations are used in conjunction with each other to create methods of varying order and similar error constants. The method presented in Fehlberg’s 1969 paper has been dubbed the RKF45 method, and is a method of order O(h4) with an error estimator of order O(h5). By performing one extra calculation, the error in the solution can be estimated and controlled by using the higher-order embedded method that allows for an adaptive stepsize to be determined automatically.

Butcher Tableau for Fehlberg’s 4(5) Method:

Any Runge–Kutta method is uniquely identified by its Butcher tableau. The embedded pair proposed by Fehlberg:

1/4 1/4
3/8 3/32 9/32
12/13 1932/2197 −7200/2197 7296/2197
1 439/216 −8 3680/513 −845/4104
1/2 −8/27 2 −3544/2565 1859/4104 −11/40
16/135 0 6656/12825 28561/56430 −9/50 2/55
25/216 0 1408/2565 2197/4104 −1/5 0

The first row of coefficients at the bottom of the table gives the fifth-order accurate method, and the second row gives the fourth-order accurate method.


[1] Erwin Fehlberg (1969). Low-order classical Runge-Kutta formulas with step size control and their application to some heat transfer problems. NASA Technical Report 315.

[2] Erwin Fehlberg (1970). ‘Klassische Runge-Kutta-Formeln vierter und niedrigerer Ordnung mit Schrittweiten-Kontrolle und ihre Anwendung auf Wärmeleitungsprobleme,’ Computing (Arch. Elektron. Rechnen), vol. 6, pp. 61–71. doi:10.1007/BF02241732

[3] Ernst Hairer, Syvert Nørsett, and Gerhard Wanner (1993). Solving Ordinary Differential Equations I: Nonstiff Problems, second edition, Springer-Verlag, Berlin. ISBN 3-540-56670-8.

2 Sales

Share Now!

Release Information

  • Price


  • Released

    April 29, 2019

  • Last Updated

    May 28, 2019

Share Your Valuable Opinions