This repository contains an algorithm for solving initial value problems (IVPs) using any explicit Runge—Kutta method of any order and for systems of arbitrary dimensionality. Unlike conventional implementations, this approach allows for a more compact and flexible code structure by eliminating the need to manually derive and write out lengthy expressions for each specific IVP. Instead, the user simply provides the Butcher tableau corresponding to the desired Runge—Kutta method, making the implementation both general and efficient.
- Explicit Runge—Kutta methods. Butcher tableau. Stability Function & Stability Region
- Description of the implemented algorithm
- Example
- Notes
- References
Let an initial value problem be specified as follows:
where
The
where
Method coefficients are conveniently set in the form of a Butcher tableau:
In the program implementation other elements of the matrix
In the context of stability analysis of explicit Runge—Kutta methods, the stability region is defined as
is stability function. For explicit Runge—Kutta methods in which the number of stages equals the order (i.e.
Stability regions for such methods are presented below:
For the method with
Of course, you can implement the algorithm described in the previous section as well, and it will work the same way as the algorithm I will describe below.
So, the algorithm is based on the application of general matrix algebra:
To begin with, we need to initialize the matrix
and the matrix
Then the formulas for filling the matrix
The ExampleOfUse.mlx file shows the obtaining of the Tamari attractor
with initial conditions
using the 6th order Runge-Kutta-Butcher method.
[t, zsol, dzdt_eval] = odeExplicitGeneral(c_vector, A_matrix, b_vector, odefun, tspan, tau, incond)
-
c_vector: vector of coefficients$\mathbf{c}$ of Butcher tableau for the selected method; -
A_matrix: matrix of coefficients$\mathbf{A}$ of Butcher tableau for the selected method; -
b_vector: vector of coefficients$\mathbf{b}$ of Butcher tableau for the selected method; -
odefun: functions to solve, specified as a function handle that defines the functions to be integrated; -
tspan: interval of integration, specified as a two-element vector; -
tau: time discretization step; -
incond: vector of initial conditions.
-
t: vector of evaluation points used to perform the integration; -
zsol: solution matrix in which each row corresponds to a solution at the value returned in the corresponding row oft; -
dzdt_eval: matrix of derivatives$\dfrac{\mathrm{d}\mathbf{z}}{\mathrm{d}t}$ evaluated at the times int; each row contains the derivative of the solution corresponding to the matching row oft.
- Butcher, J. (2016). Numerical methods for ordinary differential equations. https://doi.org/10.1002/9781119121534
- Tamari, B. (1997). Conservation and symmetry laws and stabilization programs in economics. https://www.bentamari.com/PicturesEcometry/Book3-Conservation.pdf
