In general, if (k) is any positive integer and (f) satisfies appropriate assumptions, there are numerical methods with local truncation error (O(h^{k+1})) for solving an initial value problem

[label{eq:3.3.1} y'=f(x,y),quad y(x_0)=y_0.]

Moreover, it can be shown that a method with local truncation error (O(h^{k+1})) has global truncation error (O(h^k)). In Sections 3.1 and 3.2 we studied numerical methods where (k=1) and (k=2). We’ll skip methods for which (k=3) and proceed to the *Runge*-*Kutta* method, the most widely used method, for which (k=4). The magnitude of the local truncation error is determined by the fifth derivative (y^{(5)}) of the solution of the initial value problem. Therefore the local truncation error will be larger where (|y^{(5)}|) is large, or smaller where (|y^{(5)}|) is small. The Runge-Kutta method computes approximate values (y_1), (y_2), …, (y_n) of the solution of Equation
ef{eq:3.3.1} at (x_0), (x_0+h), …, (x_0+nh) as follows: Given (y_i), compute

[egin{align*} k_{1i}&=f(x_i,y_i), k_{2i}&=f left(x_i+{hover2},y_i+{hover2}k_{1i} ight), k_{3i}&=fleft(x_i+{hover2},y_i+{hover2}k_{2i} ight), k_{4i}&=f(x_i+h,y_i+hk_{3i}),end{align*}]

and

[y_{i+1}=y_i+{hover6}(k_{1i}+2k_{2i}+2k_{3i}+k_{4i}). onumber ]

The next example, which deals with the initial value problem considered in Examples and Example (PageIndex{1}), illustrates the computational procedure indicated in the Runge-Kutta method.

Example (PageIndex{1})

Use the Runge-Kutta method with (h=0.1) to find approximate values for the solution of the initial value problem

[label{eq:3.3.2} y'+2y=x^3e^{-2x},quad y(0)=1,]

at (x=0.1,0.2).

**Solution**

Again we rewrite Equation ef{eq:3.3.2} as

[y'=-2y+x^3e^{-2x},quad y(0)=1, onumber]

which is of the form Equation ef{eq:3.3.1}, with

[f(x,y)=-2y+x^3e^{-2x}, x_0=0,mbox{ and} y_0=1. onumber]

The Runge-Kutta method yields

[egin{aligned} k_{10} & = f(x_0,y_0) = f(0,1)=-2, k_{20} & = f(x_0+h/2,y_0+hk_{10}/2)=f(.05,1+(.05)(-2)) &= f(.05,.9)=-2(.9)+(.05)^3e^{-.1}=-1.799886895, k_{30} & = f(x_0+h/2,y_0+hk_{20}/2)=f(.05,1+(.05)(-1.799886895)) &= f(.05,.910005655)=-2(.910005655)+(.05)^3e^{-.1}=-1.819898206, k_{40} & = f(x_0+h,y_0+hk_{30})=f(.1,1+(.1)(-1.819898206)) &=f(.1,.818010179)=-2(.818010179)+(.1)^3e^{-.2}=-1.635201628, y_1&=y_0+{hover6}(k_{10}+2k_{20}+2k_{30}+k_{40}), &=1+{.1over6}(-2+2(-1.799886895)+2(-1.819898206) -1.635201628)=.818753803,[4pt] k_{11} & = f(x_1,y_1) = f(.1,.818753803)=-2(.818753803))+(.1)^3e^{-.2}=-1.636688875, k_{21} & = f(x_1+h/2,y_1+hk_{11}/2)=f(.15,.818753803+(.05)(-1.636688875)) &= f(.15,.736919359)=-2(.736919359)+(.15)^3e^{-.3}=-1.471338457, k_{31} & = f(x_1+h/2,y_1+hk_{21}/2)=f(.15,.818753803+(.05)(-1.471338457)) &= f(.15,.745186880)=-2(.745186880)+(.15)^3e^{-.3}=-1.487873498, k_{41} & = f(x_1+h,y_1+hk_{31})=f(.2,.818753803+(.1)(-1.487873498)) &=f(.2,.669966453)=-2(.669966453)+(.2)^3e^{-.4}=-1.334570346, y_2&=y_1+{hover6}(k_{11}+2k_{21}+2k_{31}+k_{41}), &=.818753803+{.1over6}(-1.636688875+2(-1.471338457)+2(-1.487873498)-1.334570346) &=.670592417.end{aligned}]

The Runge-Kutta method is sufficiently accurate for most applications.

Example (PageIndex{2})

Table (PageIndex{1}) shows results of using the Runge-Kutta method with step sizes (h=0.1) and (h=0.05) to find approximate values of the solution of the initial value problem

[y'+2y=x^3e^{-2x},quad y(0)=1 onumber]

at (x=0), (0.1), (0.2), (0.3), …, (1.0). For comparison, it also shows the corresponding approximate values obtained with the improved Euler method in Example 3.2.2:

Add text here. For the automatic number to work, you need to add the “AutoNum” template (preferably at3.2.2}, and the values of the exact solution

[y={e^{-2x}over4}(x^4+4). onumber ]

The results obtained by the Runge-Kutta method are clearly better than those obtained by the improved Euler method in fact; the results obtained by the Runge-Kutta method with (h=0.1) are better than those obtained by the improved Euler method with (h=0.05).

Improved Euler | Runge-Kutta | ||||
---|---|---|---|---|---|

x | h=0.1 | h=0.05 | h=0.1 | h-0.05 | "exact" |

0.0 | 1.000000000 | 1.000000000 | 1.000000000 | 1.000000000 | 1.000000000 |

0.1 | 0.820040937 | 0.819050572 | 0.818753803 | 0.818751370 | 0.818751221 |

0.2 | 0.672734445 | 0.671086455 | 0.670592417 | 0.670588418 | 0.670588174 |

0.3 | 0.552597643 | 0.550543878 | 0.549928221 | 0.549923281 | 0.549922980 |

0.4 | 0.455160637 | 0.452890616 | 0.452210430 | 0.452205001 | 0.452204669 |

0.5 | 0.376681251 | 0.374335747 | 0.373633492 | 0.373627899 | 0.373627557 |

0.6 | 0.313970920 | 0.311652239 | 0.310958768 | 0.310953242 | 0.310952904 |

0.7 | 0.264287611 | 0.262067624 | 0.261404568 | 0.261399270 | 0.261398947 |

0.8 | 0.225267702 | 0.223194281 | 0.222575989 | 0.222571024 | 0.222570721 |

0.9 | 0.194879501 | 0.192981757 | 0.192416882 | 0.192412317 | 0.192412038 |

1.0 | 0.171388070 | 0.169680673 | 0.169173489 | 0.169169356 | 0.169169104 |

**Table (PageIndex{1})**: Numerical solution of (y'+2y=x^3e^{-2x}, y(0)=1), by the Runge-Kuttta method and the improved Euler method.

Example (PageIndex{3})

Table (PageIndex{2}) shows analogous results for the nonlinear initial value problem

[y'=-2y^2+xy+x^2, y(0)=1. onumber]

We applied the improved Euler method to this problem in Example 3.2.3.

Improved Euler | Runge-Kutta | ||||
---|---|---|---|---|---|

x | h=0.1 | h=0.05 | h=0.1 | h-0.05 | "exact" |

0.0 | 1.000000000 | 1.000000000 | 1.000000000 | 1.000000000 | 1.000000000 |

0.1 | 0.840500000 | 0.838288371 | 0.837587192 | 0.837584759 | 0.837584494 |

0.2 | 0.733430846 | 0.730556677 | 0.729644487 | 0.729642155 | 0.729641890 |

0.3 | 0.661600806 | 0.658552190 | 0.657582449 | 0.657580598 | 0.657580377 |

0.4 | 0.615961841 | 0.612884493 | 0.611903380 | 0.611901969 | 0.611901791 |

0.5 | 0.591634742 | 0.588558952 | 0.587576716 | 0.587575635 | 0.587575491 |

0.6 | 0.586006935 | 0.582927224 | 0.581943210 | 0.581942342 | 0.581942225 |

0.7 | 0.597712120 | 0.594618012 | 0.593630403 | 0.593629627 | 0.593629526 |

0.8 | 0.626008824 | 0.622898279 | 0.621908378 | 0.621907553 | 0.621907458 |

0.9 | 0.670351225 | 0.667237617 | 0.666251988 | 0.666250942 | 0.666250842 |

1.0 | 0.730069610 | 0.726985837 | 0.726017378 | 0.726015908 | 0.726015790 |

**Table (PageIndex{2}):** Numerical solution of (y'=-2y^2+xy+x^2, y(0)=1), by the Runge-Kuttta method and the improved Euler method.

Example (PageIndex{4})

Tables (PageIndex{3}) and (PageIndex{4}) show results obtained by applying the Runge-Kutta and Runge-Kutta semilinear methods to to the initial value problem

[y'-2xy=1, y(0)=3, onumber]

which we considered in Examples (PageIndex{3}) and (PageIndex{4})

(x) | (h=0.2) | (h=0.1) | (h=0.05) | "Exact" |
---|---|---|---|---|

0.0 | 3.000000000 | 3.000000000 | 3.000000000 | 3.000000000 |

0.2 | 3.327846400 | 3.327851633 | 3.327851952 | 3.327851973 |

0.4 | 3.966044973 | 3.966058535 | 3.966059300 | 3.966059348 |

0.6 | 5.066996754 | 5.067037123 | 5.067039396 | 5.067039535 |

0.8 | 6.936534178 | 6.936690679 | 6.936700320 | 6.936700945 |

1.0 | 10.184232252 | 10.184877733 | 10.184920997 | 10.184923955 |

1.2 | 16.064344805 | 16.066915583 | 16.067098699 | 16.067111677 |

1.4 | 27.278771833 | 27.288605217 | 27.289338955 | 27.289392347 |

1.6 | 49.960553660 | 49.997313966 | 50.000165744 | 50.000377775 |

1.8 | 98.834337815 | 98.971146146 | 98.982136702 | 98.982969504 |

2.0 | 211.393800152 | 211.908445283 | 211.951167637 | 211.954462214 |

(x) | (h=0.2) | (h=0.1) | (h=0.05) | "Exact" |
---|---|---|---|---|

0.0 | 3.000000000 | 3.000000000 | 3.000000000 | 3.000000000 |

0.2 | 3.327853286 | 3.327852055 | 3.327851978 | 3.327851973 |

0.4 | 3.966061755 | 3.966059497 | 3.966059357 | 3.966059348 |

0.6 | 5.067042602 | 5.067039725 | 5.067039547 | 5.067039535 |

0.8 | 6.936704019 | 6.936701137 | 6.936700957 | 6.936700945 |

1.0 | 10.184926171 | 10.184924093 | 10.184923963 | 10.184923955 |

1.2 | 16.067111961 | 16.067111696 | 16.067111678 | 16.067111677 |

1.4 | 27.289389418 | 27.289392167 | 27.289392335 | 27.289392347 |

1.6 | 50.000370152 | 50.000377302 | 50.000377745 | 50.000377775 |

1.8 | 98.982955511 | 98.982968633 | 98.982969450 | 98.982969504 |

2.0 | 211.954439983 | 211.954460825 | 211.954462127 | 211.954462214 |

**Table (PageIndex{4})**: Numerical solution of (y'-2xy=1, y(0)=3), by the Runge-Kutta semilinear method.

## The Case Where xₒ Isn’t The Left Endpoint

So far in this chapter we’ve considered numerical methods for solving an initial value problem

[label{eq:3.3.3} y'=f(x,y),quad y(x_0)=y_0]

on an interval ([x_0,b]), for which (x_0) is the left endpoint. We haven’t discussed numerical methods for solving Equation ef{eq:3.3.3} on an interval ([a,x_0]), for which (x_0) is the right endpoint. To be specific, how can we obtain approximate values (y_{-1}), (y_{-2}), …, (y_{-n}) of the solution of Equation ef{eq:3.3.3} at (x_0-h, dots,x_0-nh), where (h=(x_0-a)/n)? Here’s the answer to this question:

Question

Consider the initial value problem

[label{eq:3.3.4} z'=-f(-x,z),quad z(-x_0)=y_0,] on the interval ([-x_0,-a]), for which (-x_0) is the left endpoint. Use a numerical method to obtain approximate values (z_1), (z_2), …, (z_n) of the solution of (eqref{eq:3.3.4}) at (-x_0+h), (-x_0+2h), …, (-x_0+nh=-a). Then (y_{-1}=z_1), (y_{-2}=z_2), (dots), (y_{-n}=z_n) are approximate values of the solution of (eqref{eq:3.3.3}) at (x_0-h), (x_0-2h), …, (x_0-nh=a).

The justification for this answer is sketched in *Exercise 3.3.23*. Note how easy it is to make the change the given problem Equation
ef{eq:3.3.3} to the modified problem Equation
ef{eq:3.3.4} : first replace (f) by (-f) and then replace (x), (x_0), and (y) by (-x), (-x_0), and (z), respectively.

Example (PageIndex{5})

Use the Runge-Kutta method with step size (h=0.1) to find approximate values of the solution of

[label{eq:3.3.5} (y-1)^2y'=2x+3,quad y(1)=4]

at (x=0), (0.1), (0.2), …, (1).

**Solution**

We first rewrite Equation ef{eq:3.3.5} in the form Equation ef{eq:3.3.3} as

[label{eq:3.3.6} y'={2x+3over(y-1)^2},quad y(1)=4.]

Since the initial condition (y(1)=4) is imposed at the right endpoint of the interval ([0,1]), we apply the Runge-Kutta method to the initial value problem

[label{eq:3.3.7} z'={2x-3over(z-1)^2},quad z(-1)=4]

on the interval ([-1,0]). (You should verify that Equation ef{eq:3.3.7} is related to Equation ef{eq:3.3.6} as Equation ef{eq:3.3.4} is related to Equation ef{eq:3.3.3}.) Table [table:3.3.5} shows the results. Reversing the order of the rows in Table [table:3.3.5} and changing the signs of the values of (x) yields the first two columns of Table [table:3.3.6}. The last column of Table [table:3.3.6} shows the exact values of (y), which are given by

[y=1+(3x^2+9x+15)^{1/3}. onumber ]

(Since the differential equation in Equation ef{eq:3.3.6} is separable, this formula can be obtained by the method of Section 2.2.)

(x) | (z) |
---|---|

-1.0 | 4.000000000 |

-0.9 | 3.944536474 |

-0.8 | 3.889298649 |

-0.7 | 3.834355648 |

-0.6 | 3.779786399 |

-0.5 | 3.725680888 |

-0.4 | 3.672141529 |

-0.3 | 3.619284615 |

-0.2 | 3.567241862 |

-0.1 | 3.516161955 |

0.0 | 3.466212070 |

**Table (PageIndex{5})**: Numerical solution of (z'= {2x-3over(z-1)^2}, z(-1)=4), on ([-1,0]).

(x) | (y) | Exact |
---|---|---|

0.00 | 3.466212070 | 3.466212074 |

0.10 | 3.516161955 | 3.516161958 |

0.20 | 3.567241862 | 3.567241864 |

0.30 | 3.619284615 | 3.619284617 |

0.40 | 3.672141529 | 3.672141530 |

0.50 | 3.725680888 | 3.725680889 |

0.60 | 3.779786399 | 3.779786399 |

0.70 | 3.834355648 | 3.834355648 |

0.80 | 3.889298649 | 3.889298649 |

0.90 | 3.944536474 | 3.944536474 |

1.00 | 4.000000000 | 4.000000000 |

**Table (PageIndex{6})**: Numerical solution of ((y-1)^2y'=2x+3, y(1)=4), on ([0,1]).

We leave it to you to develop a procedure for handling the numerical solution of Equation
ef{eq:3.3.3} on an interval ([a,b]) such that (a*3.3.27*).

## 3.3: The Runge-Kutta Method - Mathematics

1 Department of Mathematics, Lagos State University, Lagos, Nigeria

2 Department of Mathematics, University of Lagos, Lagos, Nigeria

Copyright © 2013 Ashiribo Senapon Wusu et al. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

Received January 10, 2013 revised February 16, 2013 accepted March 18, 2013

**Keywords:** Multiderivative Autonomous Rung-Kutta Stability Convergence Initial Value Problems

In recent years, the derivation of Runge-Kutta methods with higher derivatives has been on the increase. In this paper, we present a new class of three stage Runge-Kutta method with first and second derivatives. The consistency and stability of the method is analyzed. Numerical examples with excellent results are shown to verify the accuracy of the proposed method compared with some existing methods.

The derivation of Runge-Kutta schemes involving higher derivatives is now on the increase. Traditionally, given an initial value problem (IVP), classical explicit RungeKutta methods are derived with the intention of performing multiple evaluations of in each internal stage for a given accuracy. Recently, Akanbi [1,2] derived multi-derivative explicit Runge-Kutta method involving up to second derivative. Goeken and Johnson [3] also derived explicit Runge-Kutta schemes of stages up to four with the first derivative of. However, the new scheme is derived with the notion of incorporating higher order derivatives of up to the second derivative. The cost of internal stage evaluations is reduced greatly and there is an appreciable improvement on the attainable order of accuracy of the method.

2. Derivation of the Proposed Scheme

The general form of a single step method for solving the Initial Value Problem (IVP)

(1)

(2)

where is obtained using the Taylor’s series expansion of an arbitrary function:

(3)

and for the autonomous case of (1), in which, becomes

(4)

The proposed scheme of this paper is of the form

(5)

(6)

Expanding and in Taylor’s series and substituting the result into (5), the coefficients of the powers of are then compared with that of (3) to obtain the following system of equations:

Solving the above system of equations, we have the set of solutions in Table 1 .

The above solution set gives rise to a family of 3-stage multi-derivative explicit Runge-Kutta schemes. The proposed scheme denoted by 3sMERK above is thus given by

3. Convergence and Stability of the Method

3.1. Existence and Uniqueness of Solution

The properties of the incremental function of the newly derived scheme are in general, very crucial to its stability and convergence characteristics [1,4-8].

Let, where, be defined and continuous for all in the region defined by, where a, b are finite, and let there exist a constant L such that

(7)

holds every, then for any, there exist a unique solution of the problem (1), where is continuous and differentiable for all.

The requirement (7) is known as the Lipschitz’s condition, and the constant is a Lipschitz’s constants [6, 7,9-11]. We shall assume that the hypothesis of this theorem is satisfied by the IVP (1). The following lemma will be useful for establishing the aforementioned characteristics.

Let be a set of real numbers. If there exist finite constants and such that

(8)

(9)

Proof. When, (9) is satisfied identically as.

Suppose (9) holds whenever so that

(10)

Then, from (8) implies that

(11)

On substituting (10) into (11), we have

(12)

Hence, (9) holds for all.

3.2. Accuracy and Stability

Usually, during the implementation of a computational scheme, errors are generated. The magnitude of the error determines how accurate and stable a scheme is. For instance, if the magnitude of the error is sufficiently small, the computational results would be accurate. However, if the magnitude of the error becomes so large, it can make the method unstable. The sources of error for these schemes and their principal error functions are discussed in Butcher [5,6], Fatunla [7] and Lambert [9, 10]. The following theorem guarantees the stability of the 3sMERK methods.

Suppose the IVP (1) satisfies the hypotheses of Theorem 3.1, then the new 3sMERK algorithm is stable.

Table 1 . Examples of three-stage MERK methods.

Proof. Let and be two sets of solutions generated recursively by the 3sMERK method with the initial condition, and

(13)

(14)

(15)

Applying triangle inequality and (13), we have

If we assume, and, then Lemma 3.2 implies that, where. This implies the stability of the 3sMERK scheme.

The proposed 3sMERK scheme (6) is applied to the two IVPs below and the results obtained are compared with the standard 3-stage methods of Runge-Kutta (Heun’s) [7,9,10] and that of Goeken and Johnson [3] stated in (16) and (17) respectively.

(16)

(17)

Table 2 . The absolute values of error of y(x) in Problem 1 using the proposed scheme and other methods, h = 0.001 0.005 0.025 0.125.

Table 3 . The absolute values of error of y(x) in Problem 2 using the proposed scheme and other methods, h = 0.001 0.005 0.025 0.125.

(18)

with the theoretical solution.

(19)

with the theoretical solution

.

The results generated by the proposed scheme in this paper when applied to the problems above, evidently proved the extent of accuracy of the scheme. Tables 2 and 3 above show the absolute error associated with the schemes for the test problems with the variation of the step length. The computations above clearly show the accuracy of the method. The standard Heun’s (third order) method grows faster in error than the method of Goeken and the newly derived scheme. However, 3sMERK performed best among the three methods.

Based on the two problems solved above, it follows that the scheme is quite efficient. We therefore conclude that the 3sMERK method proposed is reliable, stable and with high accuracy.

## 3.3: The Runge-Kutta Method - Mathematics

This method is a third order procedure for which Richardson extrapolation can be used.

### Function List

- double Runge_Kutta_v1_3( double (*f)(double, double), double y0, double x0, double h, int number_of_steps )

This function uses the above third order method to return the estimate of the solution of the initial value problem, *y' = f(x,y) y(x0) = y0*, at *x = x0 + h * n*, where *h* is the step size and *n* is *number_of_steps*.

This function uses the above third order method together with Richardson extrapolation to the limit to return the estimate of the solution of the initial value problem, *y' = f(x,y) y(x0) = y0*, at *x = x0 + h * n*, where *h* is the step size and *n* is *number_of_steps*. The argument *richardson_columns* is the number of step size halving + 1 used in Richardson extrapolation so that if *richardson_columns = 1* then no extrapolation to the limit is performed.

This function uses the above third order method to estimate the solution of the initial value problem, *y' = f(x,y) y(x0) = y0*, at *x = x0 + h * n * m*, where *h* is the step size and *n* is the interval number *0 &le n &le number_of_intervals*, and *m* is the *number_of_steps_per_interval*. The values are return in the array *y[ ]* i.e. *y[n] = y(x0 + h * m * n)*, where *m, n* are as above.

This function uses the above third order method together with Richardson extrapolation to the limit to estimate the solution of the initial value problem, *y' = f(x,y) y(x0) = y0*, at *x = x0 + h * n * m*, where *h* is the step size and *n* is the interval number *0 &le n &le number_of_intervals*, and *m* is the *number_of_steps_per_interval*. The values are return in the array *y[ ]* i.e. *y[n] = y(x0 + h * m * n)*, where *m, n* are as above. The argument *richardson_columns* is the number of step size halving + 1 used in Richardson extrapolation so that if *richardson_columns = 1* then no extrapolation to the limit is performed.

#### C Source Code

- The file, runge_kutta_v1_3.c, contains versions of Runge_Kutta_v1_3( ), Runge_Kutta_v1_3_Richardson( ), Runge_Kutta_v1_3_Integral_Curve( ), and Runge_Kutta_v1_3_Richardson_Integral_Curve( ) written in
*C*.

## Runge-Kutta Methods.

The Runge-Kutta methods are a series of numerical methods for solving differential equations and systems of differential equations.

We will see the Runge-Kutta methods in detail and its main variants in the following sections.

### One-step Linear methods

Are numerical methods whose to forward a step, only the previous step information is needed, ie step n+1 only depends on the step n. Or with more precision, are methods of the form

where (x_

Note that this problem, is really an equations system.

There are other methods called multi-step, which for to forward a step is required two or more previous steps and there are not linear methods, we will not discuss both kinds of methods here.

### Extended Theory

Runge-Kutta methods are a specialization of one-step numerical methods . Essentially, what characterizes Runge-Kutta methods is that the error is of the form

Where C is a positive real constant, the number k is called the **order of the method**

The Runge-Kutta method number of stages of is the number of times the function is evaluated at each one step i, this concept is important because evaluating the function requires a computational cost (sometimes higher) and so are preferred methods with ao minimum number of stages as possible.

Runge Kutta Methods examples

### The Euler Method (Runge-Kutta method with order 1)

The error is in the form (e le = Ch) and so **this method has order 1**

Note: The function is one-tme evaluation at each step, so the number of stages is 1.

### The middle point rule (Runge-Kutta method with order two)

The error is in the form (e le = Ch^<2>) and so **this method has order 2**

Note: function are evaluated two times at each step, so stage-number is 2.

### Standar fourth-order Runge kutta (Runge-Kutta method with order four)

$x_

Now the error is in the form (e le = Ch^<4>), so **the method has order 4**

Observation: Stage-number: 4.

### Error grahp size-step h function

We adopt the following definition as Runge-Kutta Methods:

### Runge-Kutta methods definition

A Runge-Kutta method with s-stages and order p is a method in the form

and the error holds the condition

So, to give a Runge-Kutta Method is necessarily give the s 2 + 2s numbers

An interesting feature of the Runge-Kutta methods is that it is not needed to calculate derivatives of f to forward. The price to pay for it is to evaluate more times the function f with the consequent operational cost.

### Convergence Theorem for Runge-Kutta methods

One method is more efficient if has a reduced number of stages, maintaining order, for example between a 3-stage method with order 3 and one 4-stages of order 3, is much more interesting first one because if we take a step h, the number of calculations to be done will be lower for it.

**Butcher Boards**

Given a Runge-Kutta, we construct a board as

Also it is possible to write as board Butcher

Where A ∈ M sxs , b ∈ R s , C ∈ R s

For example, the board Butcher for the Euler method is

For the midpoint rule of order 2

And for the standard Runge-Kutta of order 4

A Runge-Kutta method is said to be consistent if the truncation error tends to zero when Gloval the step size tends to zero.

It can be shown that a necessary and sufficient condition for the consistency of a Runge-Kutta is the sum of bi's equal to 1, ie if it satisfies

In addition, the method is of order 2 if it satisfies that

$ 1= 2sum_*^ a_*

*b_*$

* *

*Similar conditions can be given for methods with orderers 3, 4, . Explicit Runge-KuttaMethods In a Runge-Kutta explicit, given in the ki the definition does not appear as a function of them themselves are clear The matrix a in the Butcher board is "almost inferior triangular" because it is inferior triangular and the diagonal elements are zero too. *

It is known that there are not Runge-Kutta explicit methods with s stages with order s for s greater than or equal to 5

It is also known that there aren't Runge-Kutta explicit s-stage order s-1, for s greater than or equal that 7.

More generally we have the following table

That step size is necessary? The answer to this question is that depends on the specific problem and the desired degree of accuracy.

One thing to consider is that Runge-Kutta methods lose some precision when the derivative of the function analysis is very large or frequently changing sign, such cases requires a very small step size to obtain an acceptable degree of accuracy

At next section we will see the Fehlberg Pairs embebbed , are methods in which the step size will vary automatically depending on (among other things) of changes in the derivative of the function

If you want to see now an example of how these methods works, access to RungeKutta Calculator where you will see the default problem

## V. Method Comparison

You also may want to compare some of the different methods to see how

they perform for a specific problem.

Implicit Runge--Kutta methods have a number of desirable properties.

The Gauss--Legendre methods, for example, are self-adjoint, meaning

that they provide the same solution when integrating forward or

backward in time.

A generic framework for implicit Runge--Kutta methods has been implemented. The focus so far is on methods with interesting geometric properties and currently covers the following schemes:

"ImplicitRungeKuttaGaussCoefficients"

"ImplicitRungeKuttaLobattoIIIACoefficients"

"ImplicitRungeKuttaLobattoIIIBCoefficients"

"ImplicitRungeKuttaLobattoIIICCoefficients"

"ImplicitRungeKuttaRadauIACoefficients"

"ImplicitRungeKuttaRadauIIACoefficients"

The derivation of the method coefficients can be carried out to arbitrary order and arbitrary precision.

References on Runge--Kutta algorithms

- explicit Runge--Kutta
- Butcher, J.C., A history of Runge--Kutta methods,
*Applied Numerical Mathematics*,**20**(1996) 247--260

Return to the main page (APMA0330)

Return to the Part 1 (Plotting)

Return to the Part 2 (First Order ODEs)

Return to the Part 3 (Numerical Methods)

Return to the Part 4 (Second and Higher Order ODEs)

Return to the Part 5 (Series and Recurrences)

Return to the Part 6 (Laplace Transform)

Return to the Part 7 (Boundary Value Problems)

### 3rd Order Runge-Kutta - HP 15C

This program uses a 3rd Order Runge-Kutta method to assist in solving a first order-differential equation.

Given the initial condition (x0, y0) to the differential equation:

Find the value of y1 where h is a given step size (preferably small). The value of y1 is given by the following equations:

Where:

k1 = h * f(x0, y0)

k2 = h * f(x0 + h/3, y0 + k1/3)

k3 = h * f(x0 + (2 * h)/3, y0 + (2 * k2)/3)

Error estimated on the order of h^4

Source: Smith, Jon M. Scientific Analysis on the Pocket Calculator. John Wiley & Sons, Inc.: New York 1975 pg 174

**Memory Registers Used**

R0 = h

R1 = x

R2 = y

R3 = x1 (result)

R4 = y1 (result)

R5 = x0 (copied from R1)

R6 = y0 (copied from R2)

R7 = k1

R8 = k2

R9 = k3

Label A = Main Program

Label 0 = Program where equation is maintained

1. Store h, x0, and y0 in memory registers R0, R1, and R2 respectively.

2. Enter or edit the equation in program mode using Label 0. Use RCL 1 for x and RCL 2 for y.

3. Run Program A. The first answer is x1. Press [R/S] for y1.

4. To find (x2, y2), store x1 in R1 and y1 in R2 and run Program A again. You can do this by pressing [STO] [ 2 ] [x<>y] [STO] [ 1 ] [ f ] [ √ ] (A) immediately following program execution.

## Kansas State University

Euler's method and the improved Euler's method both try to approximate $y(x_0+h)$ by approximating the slope $m$ of the secant line from $(x_0,y(x_0))$ to $(x_0+h,y(x_0+h))$ and using the formula $y(x_0+h)=y(x_0)+mh$ (see figure 1). Euler's method approximates the slope of the secant line by the slope of the tangent line at the left endpoint $(x_0,y(x_0))$. The improved Euler's method uses the average of the slopes at the left endpoint and the approximate right endpoint (that is the right endpoint as computed by Euler's method) to approximate the slope of the secant line. We don't have to stop there either. We can keep finding slopes at different points and computing weighted averages to approximate the slope of the tangent line. Numerical methods to approximate the solution of differential equations in this fashion are called Runge-Kutta methods (after the mathematicians Runge and Kutta).

#### Third Order Runge-Kutta Method

To approximate the solution of $ frac

This method uses the improved Euler method to find an approximate midpoint of the secant line and then takes a weighted average of the slopes at the left and right endpoints and the midpoint. Note that if $f(x,y)$ is just $f(x)$, a function of $x$ alone, then solving the differential equation $displaystylefrac

#### Fourth Order Runge-Kutta method

Just as with Euler's method and the improved Euler's method, we can repeat the process to find an $x_2=x_1+h=x_0+2h$ and $y_2approx y(x_2)=y(x_0+2h)$ and so on. The fourth order Runge-Kutta method listed above is powerful enough that it was a popular technique for practical computation (and not just for educational purposes). The steps are well suited to programming into a computer, just loop through the basic algorithm as many times as needed to get to the values you are interested in. The first part of a spreadsheet for the RK4 method applied to $displaystylefrac

#### Exercises

- Use the third order Runge-Kutta method with step sizes $h=0.1$ and $h=0.05$ to approximate $y(2)$ for the initial value problem $displaystylefrac
=2xy$, $y(0)=1$. Find the error in both approximations.

### Runge-Kutta-Fehlberg Methods

#### Discussion

- The error in a single step of the improved Euler's method is about $C'h^3$ and the error in a single step of the third order Runge-Kutta method is about $C''h^4$ where $C'$ and $C''$ are constants that depend on the problem but not the step size. (The error in a single step is the error in $y(x_0+h)$ computed with a step-size of $h$. It is also called the local error.)
- $C''h^4$ is much smaller than $C'h^3$.

To see how Fehlberg used these assumptions to compute a good step-size, consider the following equations where $y_1'$ is the approximation from the improved Euler's method, $y_1''$ is the approximation from the third order Runge-Kutta method, and $y(h)$ is the true value. $egin *chicken factor*, usually taken to be 0.9. We actually use a step-size $ h_1=0.9hleft(frac

The Runge-Kutta-Fehlberg 2(3) method uses exactly this technique to pick the right step-size. Suppose the initial value problem we want to solve is $ frac

## Second Order Runge-Kutta Method (The Math)

The Second Order Runge-Kutta algorithm described above was developed in a purely ad-hoc way. It seemed reasonable that using an estimate for the derivative at the midpoint of the interval between *t₀* and *t₀+h* (i.e., at *t₀+½h*) would result in a better approximation for the function at *t₀+h*, than would using the derivative at *t₀* (i.e., Euler's Method &emdash the First Order Runge-Kutta). And, in fact, we showed that the resulting approximation was better. But, is there a way to derive the Second Order Runge-Kutta from first principles? If so, we might be able to develop even better algorithms.

##### Aside: Some Useful Math Review

In the following derivation we will use two math facts that are reviewed here. You should be familiar with this from a course in multivariable calculus.

**1)** If there is a function of two variable, *g(x,y)*, it's Taylor Series about *x₀*, *y₀* is given by:

where *&Deltax* is the increment in the first dimenstion, and *&Deltay* is the increment in the second dimension. In the last line we use a shorthand notation that removes the explicit functional notation, and also represents the partial derivative of *g* with respect to *x* as *g _{x}* (and likewise for

*g*).

_{y}**2)** If z is a function of two variables *z=g(x,y)*, where *x=r(t)* and *y=s(t)*, then by the chain rule for partial derivatives

To start, recall that we are expressing our differential equation as

Now define two approximations to the derivative

In all cases &alpha and &beta will represent fractional values between 0 and 1. These equation state that *k _{1}* is the approximation to the derivative based on the estimated value of

*y(t)*at

*t=t₀*(i.e.,

*y*(t₀)*) and the time at

*t₀*. The value of

*k*is based upon the estimated value,

_{2}*y*(t₀)*, plus some fraction of the step size,

*&betah*, times the slope k

_{1}, and the time at

*t₀+&alphah*(i.e., some time between

*t₀*and

*t₀+h*). In the method described previously

*&alpha=&beta=½*, but other choices are possible.

To update our solution with the next estimate of *y(t)* at *t₀+h* we use the equation

This equation states that we get the value of *y*(t₀+h)* from the value of *y*(t₀)* plus the time step, *h*, multiplied by a slope that is a weighted sum of *k _{1}* and

*k*. In the method described previously

_{2}*a=0*and

*b=1*, so we used only the second estimate for the slope. (Note that Euler's Method (First Order Runge-Kutta) is a special case of this method with a=1, b=0, and &alpha and &beta don't matter because k

_{2}is not used in the update equation.)

Our goal now is to determine, from first principles, how to find the values *a*, *b*, *&alpha* and *&beta* that result in low error. Starting with the update equation (above) we can substitue the previously given expressions for *k _{1}* and

*k*which yields

_{2}We can use a two-dimensional Taylor Series (where the increment in the first dimension is *&betahk _{1}*, and the increment in the second dimension is

*&alphah*) to expand the rightmost term.

$eqalign <

fleft( <

&= f +

In the last line we used the fact the *k _{1}=f* . The ellipsis denotes terms that are second order or higher. Substituting this into the previous expression for

*y*(t₀+h)*and rearranging we get

The ellipsis was multiplied by *h* between the first or second line and now represents terms that are third order or higher.

To finish we compare this approximation with the expressionfor a Taylor Expansion of the exact solution (going from the first line to the second we used the chain rule for partical derivatives). In this expression the ellipsis represents terms that are third order or higher .

Comparing this expression with our final expression for the approximation,

we see that they agree up to the error terms (third order and higher) represented by the ellipsis if we define the constants, *a*, *b*, *&alpha* and *&beta* such that

$displaylines <

a + b = 1 cr

balpha = <1 over 2>cr

beta = <1 over 2>cr> $

This system is underspecified, there are four unknowns, and only three equations, so more than one solution is possible. Clearly the choice we made *a=0* and *b=1* and *&alpha=&beta=½* is one of these solutions. Because all of the terms of the approximation are equal to the terms in the exact solution, up to the error terms, the local error of this method is therefore *O(h 3 )* (O(*h 2* ) globally, hence the term "second order" Runge-Kutta).

##### Key Concept: Error of Second Order Runge Kutta

The global error of the Second Order Runge-Kutta algorithm is *O(h 2 )*.

## Euler's Formula: A Numerical Method

Euler's Method is one of the simplest and oldest numerical methods for approximating solutions to differential equations that cannot be solved with a nice formula. Euler's Method is also called the *tangent line method*, and in essence it is an algorithmic way of plotting an approximate solution to an initial value problem through the direction field. It can also be used to get an estimated value for that solution at a given value for x . Here is how it works:

Say we have a generic initial value problem of the form dy &frasl_{dx} = f(x,y) with y(x_{0}) = y_{0} . We may not be able to find a formula for the solution y = &phi(x) , but if f(x,y) is a continuous function, we do know that such a solution exists. (See Theorem 2.8.1 in Boyce & DiPrima.) We can therefore talk about the solution y = &phi(x) and its properties. Our goal is to say as much as we can about this solution, even though we may not be able to write down a formula for it.

At any pair of values for x and y , the direction field gives us the slope of the tangent, and therefore the direction, of the solution curve y = &phi(x) passing through that point. We know that the point (x_{0} , y_{0}) lies on the solution curve, and at that point, the slope of the tangent is f(x_{0} , y_{0}) . Therefore, the equation of the tangent line to the solution at the point (x_{0} , y_{0}) is:

Since a tangent line is a good approximation to a curve near the point (x_{0} , y_{0}) , we can move a short distance along the tangent line by increasing x by some small amount h then we arrive at a new point, which we will call (x_{1} , y_{1}) . That is, we choose x_{1} = x_{0} + h , and then we obtain y_{1} by plugging x_{1} into the equation for the tangent line. Since we arrived at this new point by moving from (x_{0} , y_{0}) a small distance along the tangent line at that point, we can say that the point (x_{1} , y_{1}) is *almost* on the solution curve y = &phi(x) .

We can now find the tangent line to the solution at this new point, y = y_{1} + f(x_{1} , y_{1})(x - x_{1}) , and then increase x by the small amount h again, and come up with a new point (x_{2} , y_{2}) . Continuing with this method, we use the value of y found at each step to calculate the next value of y . This whole process can be stated more succinctly by Euler's Formula:

Another way of writing this is as follows:

A more complete description of the formula is given in the textbook. As a side remark, note that a natural variant of this algorithm changes the x equation to

which is general enough to handle first-order two-dimensional systems.

To see Euler's Method in use, let's try an example.

Consider the following initial value problem:

Suppose we want to use Euler's Method to graph an estimate for the initial value problem with f(x,y) = x 2 - 1 given above, over the interval 0 &le x &le 2 . From the initial value condition, we know that when x = 0 , the value of y is 1. Hence we will start at the initial point (x_{0} , y_{0}) = (0,1) . The tangent line at this point is y = 1 - x . If we use a "step size" of h = 1 , then our x coordinates will be x_{0} = 0 , x_{1} = 1 , and x_{2} = 2 . Euler's Method will give us estimates for the y values corresponding to each of the x values. For this step size, Euler's Method takes just two steps:

x_{0} = 0, x _{1} = 1, x _{2} = 2, | y_{0} = 1 y _{1} = 1 + f(0,1) · 1 = 0 y _{2} = 0 + f(1,0) · 1 = 0 |

So for h = 1 , Euler's Method is estimating that our solution curves goes through the three points (0,1), (1,0), and (2,0).

What if we used a smaller step size, say, h = 0.5 ? Then we would get y values corresponding to x_{0} = 0 , x_{1} = 0.5 , x_{2} = 1 , x_{3} = 1.5 , and x_{4} = 2 :

x_{0} = 0, x _{1} = 0.5, x _{2} = 1, x _{3} = 1.5, x _{4} = 2, | y_{0} = 1 y _{1} = 1 + f(0,1) · (0.5) = 0.5 y _{2} = 0.5 + f(0.5, 0.5) · (0.5) = 0.125 y _{3} = 0.125 + f(1, 0.125) · (0.5) = 0.125 y _{4} = 0.125 + f(1.5, 0.125) · (0.5) = 0.75 |

With a step size of h = 0.5 , we now get the five points (0,1), (0.5, 0.5), (1, 0.125), (1.5, 0.125), and (2, 0.75).

Keep this example in mind we will soon verify these calculations using MATLAB.

## 3.3: The Runge-Kutta Method - Mathematics

Given the IVP of Eq. 6, and a time step h , and the solution y n at the n th time step, let's say that we wish to compute y n +1 in the following fashion:

where the constants , , a and b have to be evaluated so that the resulting method has a LTE O( h 3 ) . Note that if k 2 =0 and a =1, then Eq. 13 reduces to the forward Euler method.

Now, let's write down the Taylor series expansion of y in the neighborhood of t n correct to the h 2 term i.e.,

However, we know from the IVP (Eq. 6) that dy / dt = f ( y , t ) so that

So from the above analysis, i.e., Eqs. 14 and 15, we get

However, the term k 2 in the proposed RK method of Eq. 13 can be expanded correct to O( h 3 ) as

Now, substituting for k 2 from Eq. 17 in Eq. 13, we get

Comparing the terms with identical coefficients in Eqs. 16 and 18 gives us the following system of equations to determine the constants:

There are infinitely many choices of a , b , and which satisfy Eq. 19, we can choose for instance and a = b =1/2. With this choice, we have the classical second order accurate Runge-Kutta method (RK2) which is summarized as follows.

In a similar fashion Runge-Kutta methods of higher order can be developed. One of the most widely used methods for the solution of IVPs is the fourth order Runge-Kutta (RK4) technique. The LTE of this method is order h 5 . The method is given below.

k 1 = hf ( y n , t n ) | |

k 2 = hf ( y n + k 1 /2, t n + h /2) | |

k 4 = h ( y n + k 3 , t n + h ) | |

y n +1 = y n + ( k 1 + 2 k 2 + 2 k 3 + k 4 )/6. | (20) |

Note that the RK methods are explicit techniques, hence they are only conditionally stable.