11—Numerical Analysis 279
k 1 =hf
(
0 ,y 0
)
k 3 =hf
(
h/ 2 ,y 0 +k 2 / 2
)
k 2 =hf
(
h/ 2 ,y 0 +k 1 / 2
)
k 4 =hf
(
h,y 0 +k 3
)
.
You can look up a fancier version of this called the Runge-Kutta-Fehlberg method. It’s one of the
better techniques around.
Higher Order Equations
How can you use either the Euler or the Runge-Kutta method to solve a second order differential
equation? Answer: Turn it into a pair of first order equations.
y′′=f(x,y,y′) −→ y′=v, and v′=f(x,y,v) (11.43)
The Euler method, Eq. (11.32) becomes
y(x 0 +h) =y(x 0 ) +hv(x 0 ), and v(x 0 +h) =v(x 0 ) +hf
(
x 0 ,y(x 0 ),v(x 0 )
)
The construction for Runge-Kutta is essentially the same.
Adams Methods
The Runge-Kutta algorithm has the advantage that it is self-starting; it requires only the initial condition
to go on to the next step. It has the disadvantage that it is inefficient. In going from one step to the
next, it ignores all the information available from any previous steps. The opposite approach leads to
the Adams methods, though these are not as commonly used any more. I’m going to develop a little
of the subject mostly to show that the methods that I’ve used so far can lead to disaster if you’re not
careful.
Shift the origin to be the point at which you want the new value ofy. Assume that you already
knowyat−h,− 2 h,...,−Nh. Because of the differential equationy′=f(x,y), you also knowy′
at these points.
Assume
y(0) =
∑N
1
αky(−kh) +
∑N
1
βky′(−kh) (11.44)
With 2 Nparameters, you can get this accurate to orderh^2 N−^1 ,
y(−kh) =
∑∞
0
(−kh)n
y(n)(0)
n!
Substitute this into the equation fory(0):
y(0) =
∑N
k=1
αk
∑∞
n=0
(−kh)n
y(n)(0)
n!
+h
∑N
k=1
βk
∑∞
n=0
(−kh)n
y(n+1)(0)
n!
This should be an identity to as high an order as possible. The coefficient ofh^0 gives
1 =
∑N
k=1