We first write the formulas for the general the initial value problem
dy
-- = f(x,y(x)), with y(x0) = y0
dx
The predictor-corrector method are of third order. We have the following formulas:
_ h [ ]
y = y + --- [ 23 f(x ,y ) - 16 f(x ,y ) + 5 f(x ,y ) ]
n+1 n 12 [ n n n-1 n-1 n-2 n-2 ]
h [ _ ]
y = y + --- [ 5 f(x ,y ) + 8 f(x ,y ) - f(x ,y ) ]
n+1 n 12 [ n+1 n+1 n n n-1 n-1 ]
We can only start using these formulas at n=2, when we have already
computed values at n=1 and n=2 for y (the value for n=0 is given).
To compute values at n=1 and n=2 we apply twice a Runge-Kutta method
of the same order as the predictor-corrector methods.
The formulas for this third-order Runge-Kutta method are
k1 = h f(x ,y )
n n
k2 = h f(x + h/2,y + k1/2)
n n
k3 = h f(x + 3h/2,y + 3k2/4)
n n
1
y = y + ---( 2 k1 + 3 k2 + 4 k3 )
n+1 n 9
Now we apply those formulas to the initial value problem
dy
-- = y, with y(0) = 1
dx
whose exact solution is y(x) = exp(x).
As f(x,y(x)) = y(x), the formulas take a much simpler form. The Runge-Kutta formulas we apply for this specific problem are
k1 = h y
n
k2 = h y + k1/2
n
k3 = h y + 3 k2/4
n
1
y = y + ---( 2 k1 + 3 k2 + 4 k3 )
n+1 n 9
We apply two times these Runge-Kutta formulas with h = 0.1, writing the result with seven decimal places:
+---+-----+------------+------------+------------+-----------+-----------+-------+ | | | | | | | | | | n | x | k1 | k2 | k3 | y | exp(x ) | error | | | n | | | | n | n | | +---+-----+------------+------------+------------+-----------+-----------+-------+ | 0 | 0.0 | -- | -- | -- | 1.000 000 | 1.000 000 | 0.0 | | 1 | 0.1 | .1 000 000 | .1 050 000 | .1 078 750 | 1.105 167 | 1.105 171 | 4E-6 | | 2 | 0.2 | .1 105 167 | .1 160 425 | .1 192 199 | 1.221 394 | 1.221 403 | 9E-6 | +---+-----+------------+------------+------------+-----------+-----------+-------+
The predictor-corrector formulas with f(x,y(x)) = y(x) simplify to
_ h [ ]
y = y + --- [ 23 y - 16 y + 5 y ]
n+1 n 12 [ n n-1 n-2 ]
h [ _ ]
y = y + --- [ 5 y + 8 y - y ]
n+1 n 12 [ n+1 n n-1 ]
With the values for y(n) computed by the Runge-Kutta method above, we can continue the application of the predictor-corrector methods:
+---+-----+-----------+-----------+-----------+-------+ | | | _ | | | | | n | x | y | y | exp(x ) | error | | | n | n | n | n | | +---+-----+-----------+-----------+-----------+-------+ | 0 | 0.0 | -- | 1.000 000 | 1.000 000 | 0.0 | | 1 | 0.1 | -- | 1.105 167 | 1.105 171 | 4E-6 | | 2 | 0.2 | -- | 1.221 394 | 1.221 403 | 9E-6 | | 3 | 0.3 | 1.349 806 | 1.349 852 | 1.349 859 | 7E-6 | | 4 | 0.4 | 1.491 770 | 1.491 821 | 1.491 825 | 4E-6 | | 5 | 0.5 | 1.648 665 | 1.648 721 | 1.648 721 | 7E-8 | +---+-----+-----------+-----------+-----------+-------+