10.5: Runge-Kutta Methods
( \newcommand{\kernel}{\mathrm{null}\,}\)
The three methods that we have surveyed thus far (Forward Euler, Backward Euler, and Adams-Moulton) have all involved sampling the derivative function F(y,t) at one of the discrete time steps {tn}, and the solutions at those time steps {→yn}. It is natural to ask whether we can improve the accuracy by sampling the derivative function at "intermediate" values of t and →y. This is the basic idea behind a family of numerical methods known as Runge-Kutta methods.
Here is a simple version of the method, known as second-order Runge-Kutta (RK2). Our goal is to replace the derivative term with a pair of terms, of the form
→yn+1=→yn+Ah→FA+Bh→FB,
where
→FA=→F(→yn,tn)→FB=→F(→yn+β→FA,tn+α).
The coefficients {A,B,α,β} are adjustable parameters whose values we'll shortly choose, so as to minimize the local truncation error.
During each time step, we start out knowing the solution →yn at time tn, we first calculate →FA (which is the derivative term that goes into the Forward Euler method); then we use that to calculate an "intermediate" derivative term →FB. Finally, we use a weighted average of →FA and →FB as the derivative term for calculating →yn+1. From this, it is evident that this is an explicit method: for each of the sub-equations, the "right-hand sides" contain known quantities.
We now have to determine the appropriate values of the parameters {A,B,α,β}. First, we Taylor expand →yn+1 around tn, using the chain rule:
→yn+1=→yn+hd→ydt|tn+h22d2→ydt2|tn+O(h3)=→yn+h→F(→yn,tn)+h22[ddt→F(→y(t),t)]tn+O(h3)=→yn+h→F(→yn,tn)+h22[∑j∂→F∂yjdyjdt+∂→F∂t]tn+O(h3)=→yn+h→FA+h22{∑j[∂→F∂yj]tnFAj+[∂→F∂t]tn}+O(h3)
In the same way, we Taylor expand the intermediate derivative term FB, whose formula was given above:
FB=FA+β∑jFAj[∂F∂yj]tn+α[∂F∂t]tn.
If we compare these Taylor expansions to the RK2 formula, then it can be seen that the terms can be made to match up to (and including) O(h2), if the parameters are chosen to obey the equations
A+B=1,α=β=h2B.
One possible set of solutions is A=B=1/2 and α=β=h. With these conditions met, the RK2 method has local truncation error of O(h3), one order better than the Forward Euler Method (which is likewise an explicit method), and comparable to the Adams-Moulton Method (which is an implicit method).
The local truncation error can be further reduced by taking more intermediate samples of the derivative function. The most commonly-used Runge-Kutta method is the fourth-order Runge Kutta method (RK4), which is given by
→yn+1=→yn+h6(→FA+2→FB+2→FC+→FD)→FA=→F(→yn,tn),→FB=→F(→yn+h2→FA,tn+h2),→FC=→F(→yn+h2→FB,tn+h2),→FD=→F(yn+h→FC,tn+h).
This has local truncation error of O(h5). It is an explicit method, and therefore has the disadvantage of being unstable if the problem is stiff and h is sufficiently large.