We come now to one of the major and most-used types of methods for initial-value problems: Runge–Kutta (RK) methods.[1] They are one-step methods in the sense of (6.2.7), though they are not often written in that form. RK methods boost the accuracy past first order by evaluating the ODE function more than once per time step.
6.4.1A second-order method¶
Consider a series expansion of the exact solution to ,
If we replace by and keep only the first two terms on the right-hand side, we would obtain the Euler method. To get more accuracy we will need to compute or estimate the third term as well. Note that
where we have applied the multidimensional chain rule to the derivative, because both of the arguments of depend on . Using this expression in (6.4.1), we obtain
We have no desire to calculate and then code those partial derivatives of directly; an approximate approximation is called for. Observe that
Matching this expression to the term in brackets in (6.4.3), it seems natural to select and . Doing so, we find
Truncation of the series here results in a new one-step method.
Thanks to the definitions above of α and β, the omitted terms are of size
Therefore, , and the order of accuracy of improved Euler is two.
6.4.2Implementation¶
Runge–Kutta methods are called multistage methods. We can see why if we interpret (6.4.6) from the inside out. In the first stage, the method takes an Euler half-step to time :
The second stage employs an Euler-style strategy over the whole time step, but using the value from the first stage to get the slope:
Our implementation of IE2 is shown in Function 6.4.1.
6.4.3More Runge–Kutta methods¶
While it is interesting to interpret IE2 as a pair of Euler-like steps, the Taylor series derivation is the only way to see that it will be more accurate than Euler, and it is also the path to deriving other methods. Moving to higher orders of accuracy requires introducing additional stages, each having free parameters so that more terms in the series may be matched. The amount of algebra grows rapidly in size and complexity, though there is a sophisticated theory for keeping track of it. We do not give the derivation details.
A generic -stage RK method takes the form
This recipe is completely determined by the number of stages and the constants , , and . Often an RK method is presented as just a table of these numbers, as in
For example, IE2 is given by
Here are two more two-stage, second-order methods, modified Euler and Heun’s method, respectively:
The most commonly used RK method, and perhaps the most popular IVP method of all, is the fourth-order one given by
This formula is often referred to as the fourth-order RK method, even though there are many others, and we refer to it as RK4. Written out, the recipe is as follows.
Our implementation is given in Function 6.4.2.
6.4.4Efficiency¶
As with rootfinding and integration, the usual point of view is that evaluations of are the only significant computations and are therefore to be minimized in number. One of the most important characteristics of a multistage method is that each stage requires an evaluation of ; that is, a single time step of an -stage method requires evaluations of .
The error decreases geometrically as is incremented, so trading a stage for an increase in order is a good deal. But , 6, or 7 gives a maximal order of accuracy of ; this decreases to for and , etc. Fourth order is considered adequate and the sweet spot for many applications.
6.4.5Exercises¶
Americans tend to pronounce these German names as “run-ghuh kut-tah.”