11—Numerical Analysis 330
You can now iterate this procedure using this newly found value ofyas a new starting condition to go from
x 0 +htox 0 + 2h.
Runge-Kutta
Euler’s method is not very accurate. For an improvement, change from a straight line extrapolation to a parabolic
one. Takex 0 = 0for this derivation and try a solution near 0 of the formy(x) =α+βx+γx^2 ; evaluateα,β,
andγso that the differential equation is satisfied nearx= 0,
y′=β+ 2γx=f(x,α+βx+γx^2 ).
Recall the Taylor series expansion for a function of two variables, section2.5:
f(x,y) =f(x 0 ,y 0 ) + (x−x 0 )D 1 f(x 0 ,y 0 )+(y−y 0 )D 2 f(x 0 ,y 0 ) +
1
2
(x−x 0 )^2 D 1 D 1 f(x 0 ,y 0 )
+
1
2
(y−y 0 )^2 D 2 D 2 f(x 0 ,y 0 ) + (x−x 0 )(y−y 0 )D 1 D 2 f(x 0 ,y 0 ) +··· (31)
β+ 2γx=f(0,α) +xD 1 f(0,α) + (βx+γx^2 )D 2 f(0,α) +···. (32)
The initial condition is atx= 0,y=y 0 , soα=y 0. Equate coefficients of powers ofxas high as is possible
(here throughx^1 ).
β=f(0,α) 2γ=D 1 f(0,α) +βD 2 f(0,α).
(If you setγ= 0, this is Euler’s method.)
y(h) =y 0 +hf(0,y 0 ) +
h^2
2
[
D 1 f(0,y 0 ) +f(0,y 0 )D 2 f(0,y 0 )
]
. (33)
The next problem is to evaluate these derivatives. Since they appear in a term that is multiplied byh^2 , it
is enough to use the simplest approximation for the numerical derivative,
D 1 f(0,y 0 ) =
[
f(h,y 0 )−f(0,y 0 )
]
/h. (34)
You cannot expect to use the same interval,h, for theyvariable — it might not even have the same dimensions,
D 2 f(0,y 0 ) =
[
f(j,y 0 +k)−f(j,y 0 )
]
/k. (35)