









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










SUMMARY (so far) To solve dy dx
= f (x, y) starting from (x 0 , y 0 ).
Euler:
yn+1 = yn + hf (xn, yn) Explicit but not very accurate.
Trapezoidal:
yn+1 = yn + h 2
[ f (xn, yn) + f (xn+1, yn+1)
]
More accurate but implicit.
Yes, Runge-Kutta methods.
Consider Euler-trapezoidal predictor-corrector method with just one correction step:
yn+1 = yn + h^1 2
[ f (xn, yn) + f
( xn+1, yn + hf (xn, yn)
)]
x (^) n x +hn
n n
(x +h,y +hf(x ,y ))n n n n
slope = f(x ,y )n n
slope = f(x +h,y +hf(x ,y ))n n n n
slope = 0.5*(f(x ,y ) + f(x +h,y +hf(x ,y )))
(x ,y )
n n n n n n
2nd order Runge-Kutta method
Step 1: Take an Euler step from xn to a second point in the interval xn+αh (α ≤ 1).
Euler gives approximate value of y at this point as
yn + αhf (xn, yn)
Step 2: Take a weighted average of the slopes at the initial point and the point given by the Euler method estimate:
yn+1 = yn + h [w 1 f (xn, yn) + w 2 f (xn + αh, yn + αhf (xn, yn))]
Choose α, w 1 and w 2 to make the local error as small as possible.
[Improved Euler method corresponds to α = 1, w 1 = w 2 = 12 .]
To calculate the local error we must substitute in the analytic expression and Taylor expand:
Error = y(xn+1)−y(xn)−w 1 hf (xn, y(xn))−w 2 hf (xn + αh, y(xn) + αhf (xn, y(xn)))
First note, (Taylor series)
y(xn+1) = y(xn) + hy′(xn) + h
2 2
y′′(xn) + 0(h^3 ) We know y′(x) = f (x, y(x)) (†) so y′(xn) = f (xn, y(xn)) ≡ fn for short. To find y′′(x) differentiate (†):
y′′(x) = d dx
f (x, y(x)) = ∂f ∂x
dy dx
= ∂f ∂x
f
So, in the obvious notation,
y(xn+1) = y(xn) + hfn + h
2 2
[ ∂fn ∂x +^
∂fn ∂y fn
]
Examples Write k = hf (xn, yn)
i) α = 1 ⇒ w 2 = 12 ⇒ w 1 = (^12)
yn+1 = yn + h 2
[f (xn, yn) + f (xn + h, yn + k)] This is our previous improved Euler method.
ii) α = 12 ⇒ w 2 = 1 ⇒ w 1 = 0
yn+1 = yn + hf (xn + 12 h, yn + 12 k) This is sometimes called the modified Euler method.
iii) α = 23 ⇒ w 2 = 34 ⇒ w 1 = (^14)
yn+1 = yn + 4 h
[ f (xn, yn) + 3f (xn + 23 h, yn + 23 k)
]
These methods will, in general, give different answers but they will have comparable errors.
Geometrical interpretation of the modified Euler method
x x +h
slope = f(x ,y )
slope = f(x +0.5h,y +0.5hf(x ,y ))) (x ,y )n n
n n n n
n n
n (^) n
⇒ y 1 = y 0 + hf (0. 1 , y 0 + 12 hf (0, y 0 )) = 1 + 0. 2 × (− 0 .9) = 0. 82 ⇒ y 2 = y 1 + h · f (0. 3 , y 1 + 12 hf (0. 2 , y 1 )) = 0 .82 + 0. 2 × (− 0 .738) = 0. 6724
⇒ Error = 0. 6703 − 0 .6724 = − 0. 0021
Conclusion: Euler → 2% accuracy Second order RK → 0 .3% accuracy
with the same computational effort.
Fourth order Runge-Kutta
Often called the Runge-Kutta method. In calculating yn+1 starting from (xn, yn) the function f is evaluated four times.
i.e. four “slopes” are calculated and combined to give a “mean slope”,
yn+1 = yn + h × “mean slope”, in such a way that the error is O(h^5 ).
There are many ways of doing this (just like the second order case) but one has been adopted as standard.
Geometrical interpretation of the standard 4th order Runge-Kutta method
A
B
C
D
slope=f(A)
slope=f(B)^ slope=f(C)
slope=(f(A)+2f(B)+2f(C)+f(D))/