RKMethods.mw
Runge-Kutta Methods
An IVP in Standard Form
The standard form for an IVP is the system of -order ODEs, with initial conditions:
> |
|
> |
|
|
|
(1) |
where is a vector of functions and is a vector function of the scalar and the vector .
A 4th-order IVP
Let us use the following problem to test our numerical methods.
> |
|
|
(2) |
with initial conditions
> |
|
|
(3) |
The above inital value problem can be converted to a first-order system as follows. Introduce a new set of dependent variables:
> |
|
In terms of the new functions the original -order ODE becomes the following first-order system.
> |
|
with initial conditions
> |
|
|
(6) |
This now takes the form of a standard first-order system:
> |
|
|
|
(7) |
where is a vector of dimension 4 and is a vector function of dimension 4 taking as arguments and the vector . Specifically,
> |
|
> |
|
|
(8) |
> |
|
> |
|
|
(9) |
The initial conditions are specified by the vector :
> |
|
> |
|
|
(10) |
Comparison Values
For comparison values when testing our numerical methods, apply the high-order method dverk78 to the original -order ODE.
> |
|
|
(11) |
> |
|
|
(12) |
> |
|
|
(13) |
For example:
> |
|
|
(14) |
> |
|
|
(15) |
> |
|
|
(16) |
> |
|
Runge-Kutta Method of Order 1
We have already seen a basic numerical time-stepping method of order 1, namely the Forward Euler Method:
> |
|
|
(17) |
In the class of Runge-Kutta methods discussed below, the Forward Euler Method is a Runge-Kutta method of order 1.
Recall that the above formula is derived from the Taylor series expansion
> |
|
|
(18) |
and by dropping the term we arrive at the Forward Euler Method.
It follows that this method has local truncation error which leads to a global truncation error . Hence the method is order 1.
Test Order of Accuracy: RK1
The following procedure defines the method RK1 (otherwise known as the Forward Euler Method).
The IVP to be solved is
> |
|
|
(19) |
> |
|
|
(20) |
Compute the solution a number of times specified by , dividing the stepsize by 2 each time.
For each stepsize , compare the computed result at of the component of (which corresponds to the original ), with the value .
> |
|
|
(21) |
> |
|
|
(22) |
> |
|
|
(23) |
> |
|
> |
|
|
(24) |
> |
|
|
(25) |
> |
|
|
(26) |
Compute successive ratios
> |
|
The ratio is approximately .
Conclusion: Since with we conclude that RK1 is of order 1.
A Runge-Kutta Method of Order 2
We have previously developed a numerical time-stepping formula with a higher order, namely the Modified Euler Method which has order 2.
The Modified Euler Method can be stated in the following form, which is a common form for presenting Runge-Kutta formulas.
> |
|
> |
|
Recall that the above formula is based on the Taylor series expansion
> |
|
|
(29) |
by dropping the term
It follows that this method has local truncation error which leads to a global truncation error . Hence the method is order 2.
Test Order of Accuracy: RK2
The following procedure defines the method RK2 (otherwise known as the Modified Euler Method).
Compute the solution a number of times specified by , dividing the stepsize by 2 each time.
For each stepsize , compare the computed result at of the component of (which corresponds to the original ), with the value .
> |
|
|
(30) |
> |
|
|
(31) |
> |
|
|
(32) |
> |
|
> |
|
|
(33) |
> |
|
|
(34) |
> |
|
|
(35) |
Compute successive ratios
> |
|
The ratio is approximately .
Conclusion: Since with we conclude that RK2 is of order 2.
A Runge-Kutta Method of Order 3
For each order greater than there is more than one possible Runge-Kutta method of the specified order.
The following is a Runge-Kutta method of order 3.
> |
|
> |
|
Note that for this particular choice of parameters, the value does not appear in the final formula although it is used in defining .
The parameters have been chosen to ensure that the local truncation error is and therefore the global truncation error is .
Test Order of Accuracy: RK3
The following procedure defines the method RK3.
Compute the solution a number of times specified by , dividing the stepsize by 2 each time.
For each stepsize , compare the computed result at of the component of (which corresponds to the original ), with the value .
> |
|
|
(38) |
> |
|
|
(39) |
> |
|
|
(40) |
> |
|
> |
|
|
(41) |
> |
|
|
(42) |
> |
|
|
(43) |
Compute successive ratios
> |
|
The ratio is approximately .
(Note that with a higher order method, the computed results stop improving because we reach the maximum accuracy for the given precision of the floating point arithmetic.)
Conclusion: Since with we conclude that RK3 is of order 3.
A Runge-Kutta Method of Order 4
The following is the most common Runge-Kutta method of order 4, as stated in the CS 370 Course Notes.
> |
|
> |
|
The parameters have been chosen to ensure that the local truncation error is and therefore the global truncation error is .
Test Order of Accuracy: RK4
The following procedure defines the method RK4.
Compute the solution a number of times specified by , dividing the stepsize by 2 each time.
For each stepsize , compare the computed result at of the component of (which corresponds to the original ), with the value .
> |
|
|
(46) |
> |
|
|
(47) |
Start with a larger value of because the errors get very small quickly with this -order method.
> |
|
|
(48) |
> |
|
> |
|
|
(49) |
> |
|
|
(50) |
> |
|
|
(51) |
Compute successive ratios
> |
|
The ratio is converging to approximately .
(Note that to get a better measure of the ratios, one would need to compute with higher-precision floating point.)
Conclusion: Since with we conclude that RK4 is of order 4.