Explicit Runge-Kutta Methods

This module provides explicit Runge-Kutta methods for ODEs.

Given an initial value problem specified as:

\[\frac{dy}{dt}=f(t,y),\quad y(t_{0})=y_{0}.\]

Let the step-size \(h > 0\).

Then, the general schema of explicit Runge–Kutta methods is [1]_:

\[y_{n+1}=y_{n}+h\sum _{i=1}^{s}b_{i}k_{i},\]

where

\[\begin{split}\begin{aligned} k_{1}&=f(t_{n},y_{n}),\\ k_{2}&=f(t_{n}+c_{2}h,y_{n}+h(a_{21}k_{1})),\\ k_{3}&=f(t_{n}+c_{3}h,y_{n}+h(a_{31}k_{1}+a_{32}k_{2})),\\ &\\ \vdots \\ k_{s}&=f(t_{n}+c_{s}h,y_{n}+h(a_{s1}k_{1}+a_{s2}k_{2}+\cdots +a_{s,s-1}k_{s-1})). \end{aligned}\end{split}\]

To specify a particular method, one needs to provide the integer \(s\) (the number of stages), and the coefficients \(a_{ij}\) (for \(1 \le j < i \le s\)), \(b_i\) (for \(i = 1, 2, \cdots, s\)) and \(c_i\) (for \(i = 2, 3, \cdots, s\)).

The matrix \([a_{ij}]\) is called the Runge–Kutta matrix, while the \(b_i\) and \(c_i\) are known as the weights and the nodes. These data are usually arranged in a mnemonic device, known as a Butcher tableau (named after John C. Butcher):

\[\begin{split}\begin{array}{c|llll} 0 & & & & & \\ c_{2} & a_{21} & & & & \\ c_{3} & a_{31} & a_{32} & & & \\ \vdots & \vdots & & \ddots & \\ c_{s} & a_{s 1} & a_{s 2} & \cdots & a_{s, s-1} \\ \hline & b_{1} & b_{2} & \cdots & b_{s-1} & b_{s} \end{array}\end{split}\]

A Taylor series expansion shows that the Runge–Kutta method is consistent if and only if

\[\sum _{i=1}^{s}b_{i}=1.\]

Another popular condition for determining coefficients is:

\[\sum_{j=1}^{i-1}a_{ij}=c_{i}{\text{ for }}i=2,\ldots ,s.\]

More details please see references [2]_ 3 4.

1

Press, W. H., B. P. Flannery, S. A. Teukolsky, and W. T. Vetterling. “Section 17.1 Runge-Kutta Method.” Numerical Recipes: The Art of Scientific Computing (2007).

2

https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods

3

Butcher, John Charles. Numerical methods for ordinary differential equations. John Wiley & Sons, 2016.

4

Iserles, A., 2009. A first course in the numerical analysis of differential equations (No. 44). Cambridge university press.

ExplicitRKIntegrator(f[, var_type, dt, ...])

Explicit Runge–Kutta methods for ordinary differential equation.

Euler(f[, var_type, dt, name, show_code])

The Euler method for ODEs.

MidPoint(f[, var_type, dt, name, show_code])

Explicit midpoint method for ODEs.

Heun2(f[, var_type, dt, name, show_code])

Heun's method for ODEs.

Ralston2(f[, var_type, dt, name, show_code])

Ralston's method for ODEs.

RK2(f[, beta, var_type, dt, name, show_code])

Generic second order Runge-Kutta method for ODEs.

RK3(f[, var_type, dt, name, show_code])

Classical third-order Runge-Kutta method for ODEs.

Heun3(f[, var_type, dt, name, show_code])

Heun's third-order method for ODEs.

Ralston3(f[, var_type, dt, name, show_code])

Ralston's third-order method for ODEs.

SSPRK3(f[, var_type, dt, name, show_code])

Third-order Strong Stability Preserving Runge-Kutta (SSPRK3).

RK4(f[, var_type, dt, name, show_code])

Classical fourth-order Runge-Kutta method for ODEs.

Ralston4(f[, var_type, dt, name, show_code])

Ralston's fourth-order method for ODEs.

RK4Rule38(f[, var_type, dt, name, show_code])

3/8-rule fourth-order method for ODEs.

class brainpy.integrators.ode.explicit_rk.ExplicitRKIntegrator(f, var_type=None, dt=None, name=None, show_code=False)[source]

Explicit Runge–Kutta methods for ordinary differential equation.

For the system,

\[\frac{d y}{d t}=f(t, y)\]

Explicit Runge-Kutta methods take the form

\[\begin{split}k_{i}=f\left(t_{n}+c_{i}h,y_{n}+h\sum _{j=1}^{s}a_{ij}k_{j}\right) \\ y_{n+1}=y_{n}+h \sum_{i=1}^{s} b_{i} k_{i}\end{split}\]

Each method listed on this page is defined by its Butcher tableau, which puts the coefficients of the method in a table as follows:

\[\begin{split}\begin{array}{c|cccc} c_{1} & a_{11} & a_{12} & \ldots & a_{1 s} \\ c_{2} & a_{21} & a_{22} & \ldots & a_{2 s} \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ c_{s} & a_{s 1} & a_{s 2} & \ldots & a_{s s} \\ \hline & b_{1} & b_{2} & \ldots & b_{s} \end{array}\end{split}\]
Parameters
  • f (callable) – The derivative function.

  • show_code (bool) – Whether show the formatted code.

  • dt (float) – The numerical precision.

class brainpy.integrators.ode.explicit_rk.Euler(f, var_type=None, dt=None, name=None, show_code=False)[source]

The Euler method for ODEs.

Also named as Forward Euler method, or Explicit Euler method.

Given an ODE system,

\[y'(t)=f(t,y(t)),\qquad y(t_{0})=y_{0},\]

by using Euler method [1]_, we should choose a value \(h\) for the size of every step and set \(t_{n}=t_{0}+nh\). Now, one step of the Euler method from \(t_{n}\) to \(t_{n+1}=t_{n}+h\) is:

\[y_{n+1}=y_{n}+hf(t_{n},y_{n}).\]

Note that the method increments a solution through an interval \(h\) while using derivative information from only the beginning of the interval. As a result, the step’s error is \(O(h^2)\).

Geometric interpretation

Illustration of the Euler method. The unknown curve is in blue, and its polygonal approximation is in red [2]_:

../_static/ode_Euler_method.svg

Derivation

There are several ways to get Euler method [2]_.

The first is to consider the Taylor expansion of the function \(y\) around \(t_{0}\):

\[y(t_{0}+h)=y(t_{0})+hy'(t_{0})+{\frac {1}{2}}h^{2}y''(t_{0})+O(h^{3}).\]

where \(y'(t_0)=f(t_0,y)\). We ignore the quadratic and higher-order terms, then we get Euler method. The Taylor expansion is used below to analyze the error committed by the Euler method, and it can be extended to produce Runge–Kutta methods.

The second way is to replace the derivative with the forward finite difference formula:

\[y'(t_{0})\approx {\frac {y(t_{0}+h)-y(t_{0})}{h}}.\]

The third method is integrate the differential equation from \(t_{0}\) to \(t_{0}+h\) and apply the fundamental theorem of calculus to get:

\[y(t_{0}+h)-y(t_{0})=\int _{t_{0}}^{t_{0}+h}f(t,y(t))\,\mathrm {d} t \approx hf(t_{0},y(t_{0})).\]

Note

Euler method is a first order numerical procedure for solving ODEs with a given initial value. The lack of stability and accuracy limits its popularity mainly to use as a simple introductory example of a numeric solution method.

References

1

W. H.; Flannery, B. P.; Teukolsky, S. A.; and Vetterling, W. T. Numerical Recipes in FORTRAN: The Art of Scientific Computing, 2nd ed. Cambridge, England: Cambridge University Press, p. 710, 1992.

2

https://en.wikipedia.org/wiki/Euler_method

class brainpy.integrators.ode.explicit_rk.MidPoint(f, var_type=None, dt=None, name=None, show_code=False)[source]

Explicit midpoint method for ODEs.

Also known as the modified Euler method [1]_.

The midpoint method is a one-step method for numerically solving the differential equation given by:

\[y'(t) = f(t, y(t)), \quad y(t_0) = y_0 .\]

The formula of the explicit midpoint method is:

\[y_{n+1} = y_n + hf\left(t_n+\frac{h}{2},y_n+\frac{h}{2}f(t_n, y_n)\right).\]

Therefore, the Butcher tableau of the midpoint method is:

\[\begin{split}\begin{array}{c|cc} 0 & 0 & 0 \\ 1 / 2 & 1 / 2 & 0 \\ \hline & 0 & 1 \end{array}\end{split}\]

Derivation

Compared to the slope formula of Euler method \(y'(t) \approx \frac{y(t+h) - y(t)}{h}\), the midpoint method use

\[y'\left(t+\frac{h}{2}\right) \approx \frac{y(t+h) - y(t)}{h},\]

The reason why we use this, please see the following geometric interpretation. Then, we get

\[y(t+h) \approx y(t) + hf\left(t+\frac{h}{2},y\left(t+\frac{h}{2}\right)\right).\]

However, we do not know \(y(t+h/2)\). The solution is then to use a Taylor series expansion exactly as the Euler method to solve:

\[y\left(t + \frac{h}{2}\right) \approx y(t) + \frac{h}{2}y'(t)=y(t) + \frac{h}{2}f(t, y(t)),\]

Finally, we can get the final step function:

\[y(t + h) \approx y(t) + hf\left(t + \frac{h}{2}, y(t) + \frac{h}{2}f(t, y(t))\right).\]

Geometric interpretation

In the basic Euler’s method, the tangent of the curve at \((t_{n},y_{n})\) is computed using \(f(t_{n},y_{n})\). The next value \(y_{n+1}\) is found where the tangent intersects the vertical line \(t=t_{n+1}\). However, if the second derivative is only positive between \(t_{n}\) and \(t_{n+1}\), or only negative, the curve will increasingly veer away from the tangent, leading to larger errors as \(h\) increases.

Compared with the Euler method, midpoint method use the tangent at the midpoint (upper, green line segment in the following figure [2]_), which would most likely give a more accurate approximation of the curve in that interval.

../_static/ode_Midpoint_method_illustration.png

Although this midpoint tangent could not be accurately calculated, we can estimate midpoint value of \(y(t)\) by using the original Euler’s method. Finally, the improved tangent is used to calculate the value of \(y_{n+1}\) from \(y_{n}\). This last step is represented by the red chord in the diagram.

Note

Note that the red chord is not exactly parallel to the green segment (the true tangent), due to the error in estimating the value of \(y(t)\) at the midpoint.

References

1

Süli, Endre, and David F. Mayers. An Introduction to Numerical Analysis. no. 1, 2003.

2

https://en.wikipedia.org/wiki/Midpoint_method

class brainpy.integrators.ode.explicit_rk.Heun2(f, var_type=None, dt=None, name=None, show_code=False)[source]

Heun’s method for ODEs.

This method is named after Karl Heun [1]_. It is also known as the explicit trapezoid rule, improved Euler’s method, or modified Euler’s method.

Given ODEs with a given initial value,

\[y'(t) = f(t,y(t)), \qquad y(t_0)=y_0,\]

the two-stage Heun’s method is formulated as:

\[\tilde{y}_{n+1} = y_n + h f(t_n,y_n)\]
\[y_{n+1} = y_n + \frac{h}{2}[f(t_n, y_n) + f(t_{n+1},\tilde{y}_{n+1})],\]

where \(h\) is the step size and \(t_{n+1}=t_n+h\).

Therefore, the Butcher tableau of the two-stage Heun’s method is:

\[\begin{split}\begin{array}{c|cc} 0.0 & 0.0 & 0.0 \\ 1.0 & 1.0 & 0.0 \\ \hline & 0.5 & 0.5 \end{array}\end{split}\]

Geometric interpretation

In the brainpy.integrators.ode.midpoint(), we have already known Euler method has big estimation error because it uses the line tangent to the function at the beginning of the interval \(t_n\) as an estimate of the slope of the function over the interval \((t_n, t_{n+1})\).

In order to address this problem, Heun’s Method considers the tangent lines to the solution curve at both ends of the interval (\(t_n\) and \(t_{n+1}\)), one (\(f(t_n, y_n)\)) which underestimates, and one (\(f(t_{n+1},\tilde{y}_{n+1})\), approximated using Euler’s Method) which overestimates the ideal vertical coordinates. The ideal point lies approximately halfway between the erroneous overestimation and underestimation, the average of the two slopes.

../_static/ode_Heun2_Method_Diagram.jpg
\[\begin{split}\begin{aligned} {\text{Slope}}_{\text{left}}=&f(t_{n},y_{n}) \\ {\text{Slope}}_{\text{right}}=&f(t_{n}+h,y_{n}+hf(t_{n},y_{n})) \\ {\text{Slope}}_{\text{ideal}}=&{\frac {1}{2}}({\text{Slope}}_{\text{left}}+{\text{Slope}}_{\text{right}}) \end{aligned}\end{split}\]

References

1

Süli, Endre, and David F. Mayers. An Introduction to Numerical Analysis. no. 1, 2003.

class brainpy.integrators.ode.explicit_rk.Ralston2(f, var_type=None, dt=None, name=None, show_code=False)[source]

Ralston’s method for ODEs.

Ralston’s method is a second-order method with two stages and a minimum local error bound.

Given ODEs with a given initial value,

\[y'(t) = f(t,y(t)), \qquad y(t_0)=y_0,\]

the Ralston’s second order method is given by

\[y_{n+1}=y_{n}+\frac{h}{4} f\left(t_{n}, y_{n}\right)+ \frac{3 h}{4} f\left(t_{n}+\frac{2 h}{3}, y_{n}+\frac{2 h}{3} f\left(t_{n}, y_{n}\right)\right)\]

Therefore, the corresponding Butcher tableau is:

\[\begin{split}\begin{array}{c|cc} 0 & 0 & 0 \\ 2 / 3 & 2 / 3 & 0 \\ \hline & 1 / 4 & 3 / 4 \end{array}\end{split}\]
class brainpy.integrators.ode.explicit_rk.RK2(f, beta=0.6666666666666666, var_type=None, dt=None, name=None, show_code=False)[source]

Generic second order Runge-Kutta method for ODEs.

Derivation

In the brainpy.integrators.ode.midpoint(), brainpy.integrators.ode.heun2(), and brainpy.integrators.ode.ralston2(), we have already known first-order Euler method brainpy.integrators.ode.euler() has big estimation error.

Here, we seek to derive a generic second order Runge-Kutta method [1]_ for the given ODE system with a given initial value,

\[y'(t) = f(t,y(t)), \qquad y(t_0)=y_0,\]

we want to get a generic solution:

\[\begin{align} y_{n+1} &= y_{n} + h \left ( a_1 K_1 + a_2 K_2 \right ) \tag{1} \end{align}\]

where \(a_1\) and \(a_2\) are some weights to be determined, and \(K_1\) and \(K_2\) are derivatives on the form:

\[\begin{align} K_1 & = f(t_n,y_n) \qquad \text{and} \qquad K_2 = f(t_n + p_1 h,y_n + p_2 K_1 h ) \tag{2} \end{align}\]

By substitution of (2) in (1) we get:

\[\begin{align} y_{n+1} &= y_{n} + a_1 h f(t_n,y_n) + a_2 h f(t_n + p_1 h,y_n + p_2 K_1 h) \tag{3} \end{align}\]

Now, we may find a Taylor-expansion of \(f(t_n + p_1 h, y_n + p_2 K_1 h )\)

\[\begin{split}\begin{align} f(t_n + p_1 h, y_n + p_2 K_1 h ) &= f + p_1 h f_t + p_2 K_1 h f_y + \text{h.o.t.} \nonumber \\ & = f + p_1 h f_t + p_2 h f f_y + \text{h.o.t.} \tag{4} \end{align}\end{split}\]

where \(f_t \equiv \frac{\partial f}{\partial t}\) and \(f_y \equiv \frac{\partial f}{\partial y}\).

By substitution of (4) in (3) we eliminate the implicit dependency of \(y_{n+1}\)

\[\begin{split}\begin{align} y_{n+1} &= y_{n} + a_1 h f(t_n,y_n) + a_2 h \left (f + p_1 h f_t + p_2 h f f_y \right ) \nonumber \\ &= y_{n} + (a_1 + a_2) h f + \left (a_2 p_1 f_t + a_2 p_2 f f_y \right) h^2 \tag{5} \end{align}\end{split}\]

In the next, we try to get the second order Taylor expansion of the solution:

\[\begin{align} y(t_n+h) = y_n + h y' + \frac{h^2}{2} y'' + O(h^3) \tag{6} \end{align}\]

where the second order derivative is given by

\[\begin{align} y'' = \frac{d^2 y}{dt^2} = \frac{df}{dt} = \frac{\partial{f}}{\partial{t}} \frac{dt}{dt} + \frac{\partial{f}}{\partial{y}} \frac{dy}{dt} = f_t + f f_y \tag{7} \end{align}\]

Substitution of (7) into (6) yields:

\[\begin{align} y(t_n+h) = y_n + h f + \frac{h^2}{2} \left (f_t + f f_y \right ) + O(h^3) \tag{8} \end{align}\]

Finally, in order to approximate (8) by using (5), we get the generic second order Runge-Kutta method, where

\[\begin{split}\begin{aligned} a_1 + a_2 = 1 \\ a_2 p_1 = \frac{1}{2} \\ a_2 p_2 = \frac{1}{2}. \end{aligned}\end{split}\]

Furthermore, let \(p_1=\beta\), we get

\[\begin{split}\begin{aligned} p_1 = & \beta \\ p_2 = & \beta \\ a_2 = &\frac{1}{2\beta} \\ a_1 = &1 - \frac{1}{2\beta} . \end{aligned}\end{split}\]

Therefore, the corresponding Butcher tableau is:

\[\begin{split}\begin{array}{c|cc} 0 & 0 & 0 \\ \beta & \beta & 0 \\ \hline & 1 - {1 \over 2 * \beta} & {1 \over 2 * \beta} \end{array}\end{split}\]

References

1

Chapra, Steven C., and Raymond P. Canale. Numerical methods for engineers. Vol. 1221. New York: Mcgraw-hill, 2011.

class brainpy.integrators.ode.explicit_rk.RK3(f, var_type=None, dt=None, name=None, show_code=False)[source]

Classical third-order Runge-Kutta method for ODEs.

For the given initial value problem \(y'(x) = f(t,y);\, y(t_0) = y_0\), the third order Runge-Kutta method is given by:

\[y_{n+1} = y_n + 1/6 ( k_1 + 4 k_2 + k_3),\]

where

\[\begin{split}k_1 = h f(t_n, y_n), \\ k_2 = h f(t_n + h / 2, y_n + k_1 / 2), \\ k_3 = h f(t_n + h, y_n - k_1 + 2 k_2 ),\end{split}\]

where \(t_n = t_0 + n h.\)

Error term \(O(h^4)\), correct up to the third order term in Taylor series expansion.

The Taylor series expansion is \(y(t+h)=y(t)+\frac{k}{6}+\frac{2 k_{2}}{3}+\frac{k_{3}}{6}+O\left(h^{4}\right)\).

The corresponding Butcher tableau is:

\[\begin{split}\begin{array}{c|ccc} 0 & 0 & 0 & 0 \\ 1 / 2 & 1 / 2 & 0 & 0 \\ 1 & -1 & 2 & 0 \\ \hline & 1 / 6 & 2 / 3 & 1 / 6 \end{array}\end{split}\]
class brainpy.integrators.ode.explicit_rk.Heun3(f, var_type=None, dt=None, name=None, show_code=False)[source]

Heun’s third-order method for ODEs.

It has the characteristics of:

  • method stage = 3

  • method order = 3

  • Butcher Tables:

\[\begin{split}\begin{array}{c|ccc} 0 & 0 & 0 & 0 \\ 1 / 3 & 1 / 3 & 0 & 0 \\ 2 / 3 & 0 & 2 / 3 & 0 \\ \hline & 1 / 4 & 0 & 3 / 4 \end{array}\end{split}\]
class brainpy.integrators.ode.explicit_rk.Ralston3(f, var_type=None, dt=None, name=None, show_code=False)[source]

Ralston’s third-order method for ODEs.

It has the characteristics of:

  • method stage = 3

  • method order = 3

  • Butcher Tables:

\[\begin{split}\begin{array}{c|ccc} 0 & 0 & 0 & 0 \\ 1 / 2 & 1 / 2 & 0 & 0 \\ 3 / 4 & 0 & 3 / 4 & 0 \\ \hline & 2 / 9 & 1 / 3 & 4 / 9 \end{array}\end{split}\]

References

1

Ralston, Anthony (1962). “Runge-Kutta Methods with Minimum Error Bounds”. Math. Comput. 16 (80): 431–437. doi:10.1090/S0025-5718-1962-0150954-0

class brainpy.integrators.ode.explicit_rk.SSPRK3(f, var_type=None, dt=None, name=None, show_code=False)[source]

Third-order Strong Stability Preserving Runge-Kutta (SSPRK3).

It has the characteristics of:

  • method stage = 3

  • method order = 3

  • Butcher Tables:

\[\begin{split}\begin{array}{c|ccc} 0 & 0 & 0 & 0 \\ 1 & 1 & 0 & 0 \\ 1 / 2 & 1 / 4 & 1 / 4 & 0 \\ \hline & 1 / 6 & 1 / 6 & 2 / 3 \end{array}\end{split}\]
class brainpy.integrators.ode.explicit_rk.RK4(f, var_type=None, dt=None, name=None, show_code=False)[source]

Classical fourth-order Runge-Kutta method for ODEs.

For the given initial value problem of

\[{\frac {dy}{dt}}=f(t,y),\quad y(t_{0})=y_{0}.\]

The fourth-order RK method is formulated as:

\[\begin{split}\begin{aligned} y_{n+1}&=y_{n}+{\frac {1}{6}}h\left(k_{1}+2k_{2}+2k_{3}+k_{4}\right),\\ t_{n+1}&=t_{n}+h\\ \end{aligned}\end{split}\]

for \(n = 0, 1, 2, 3, \cdot\), using

\[\begin{split}\begin{aligned} k_{1}&=\ f(t_{n},y_{n}),\\ k_{2}&=\ f\left(t_{n}+{\frac {h}{2}},y_{n}+h{\frac {k_{1}}{2}}\right),\\ k_{3}&=\ f\left(t_{n}+{\frac {h}{2}},y_{n}+h{\frac {k_{2}}{2}}\right),\\ k_{4}&=\ f\left(t_{n}+h,y_{n}+hk_{3}\right). \end{aligned}\end{split}\]

Here \(y_{n+1}\) is the RK4 approximation of \(y(t_{n+1})\), and the next value (\(y_{n+1}\)) is determined by the present value (\(y_{n}\)) plus the weighted average of four increments, where each increment is the product of the size of the interval, \(h\), and an estimated slope specified by function \(f\) on the right-hand side of the differential equation.

  • \(k_{1}\) is the slope at the beginning of the interval, using \(y\) (Euler’s method);

  • \(k_{2}\) is the slope at the midpoint of the interval, using \(y\) and \(k_{1}\);

  • \(k_{3}\) is again the slope at the midpoint, but now using \(y\) and \(k_{2}\);

  • \(k_{4}\) is the slope at the end of the interval, using \(y\) and \(k_{3}\).

The RK4 method is a fourth-order method, meaning that the local truncation error is on the order of (\(O(h^{5}\)), while the total accumulated error is on the order of (\(O(h^{4}\)).

The corresponding Butcher tableau is:

\[\begin{split}\begin{array}{c|cccc} 0 & 0 & 0 & 0 & 0 \\ 1 / 2 & 1 / 2 & 0 & 0 & 0 \\ 1 / 2 & 0 & 1 / 2 & 0 & 0 \\ 1 & 0 & 0 & 1 & 0 \\ \hline & 1 / 6 & 1 / 3 & 1 / 3 & 1 / 6 \end{array}\end{split}\]

References

1

Lambert, J. D. and Lambert, D. Ch. 5 in Numerical Methods for Ordinary Differential Systems: The Initial Value Problem. New York: Wiley, 1991.

2

Press, W. H.; Flannery, B. P.; Teukolsky, S. A.; and Vetterling, W. T. “Runge-Kutta Method” and “Adaptive Step Size Control for Runge-Kutta.” §16.1 and 16.2 in Numerical Recipes in FORTRAN: The Art of Scientific Computing, 2nd ed. Cambridge, England: Cambridge University Press, pp. 704-716, 1992.

class brainpy.integrators.ode.explicit_rk.Ralston4(f, var_type=None, dt=None, name=None, show_code=False)[source]

Ralston’s fourth-order method for ODEs.

It has the characteristics of:

  • method stage = 4

  • method order = 4

  • Butcher Tables:

\[\begin{split}\begin{array}{c|cccc} 0 & 0 & 0 & 0 & 0 \\ .4 & .4 & 0 & 0 & 0 \\ .45573725 & .29697761 & .15875964 & 0 & 0 \\ 1 & .21810040 & -3.05096516 & 3.83286476 & 0 \\ \hline & .17476028 & -.55148066 & 1.20553560 & .17118478 \end{array}\end{split}\]

References

1

Ralston, Anthony (1962). “Runge-Kutta Methods with Minimum Error Bounds”. Math. Comput. 16 (80): 431–437. doi:10.1090/S0025-5718-1962-0150954-0

class brainpy.integrators.ode.explicit_rk.RK4Rule38(f, var_type=None, dt=None, name=None, show_code=False)[source]

3/8-rule fourth-order method for ODEs.

A slight variation of “the” Runge–Kutta method is also due to Kutta in 1901 [1]_ and is called the 3/8-rule. The primary advantage this method has is that almost all of the error coefficients are smaller than in the popular method, but it requires slightly more FLOPs (floating-point operations) per time step.

It has the characteristics of:

  • method stage = 4

  • method order = 4

  • Butcher Tables:

\[\begin{split}\begin{array}{c|cccc} 0 & 0 & 0 & 0 & 0 \\ 1 / 3 & 1 / 3 & 0 & 0 & 0 \\ 2 / 3 & -1 / 3 & 1 & 0 & 0 \\ 1 & 1 & -1 & 1 & 0 \\ \hline & 1 / 8 & 3 / 8 & 3 / 8 & 1 / 8 \end{array}\end{split}\]

References

1

Hairer, Ernst; Nørsett, Syvert Paul; Wanner, Gerhard (1993), Solving ordinary differential equations I: Nonstiff problems, Berlin, New York: Springer-Verlag, ISBN 978-3-540-56670-0.