Lecture Notes 12-Runge-Kutta Method
Lecture Notes 12-Runge-Kutta Method
Runge-Kutta Methods
Outline
Outline
Outline
Outline
Outline
Runge-Kutta Methods
Runge-Kutta Methods
Runge-Kutta Methods
Runge-Kutta Methods
Runge-Kutta Methods
Suppose that f (t, y) and all its partial derivatives of order less than or
equal to n + 1 are continuous on D = { (t, y) | a t b, c y d },
and let (t0 , y0 ) D. For every (t, y) D, there exists between t and
t0 and between y and y0 with
Suppose that f (t, y) and all its partial derivatives of order less than or
equal to n + 1 are continuous on D = { (t, y) | a t b, c y d },
and let (t0 , y0 ) D. For every (t, y) D, there exists between t and
t0 and between y and y0 with
f f
Pn (t, y) = f (t0 , y0 ) + (t t0 ) (t0 , y0 ) + (y y0 ) (t0 , y0 )
t y
2
(t t0 ) f2 2f
+ (t ,
0 0y ) + (t t0 )(y y 0 ) (t0 , y0 )
2 t 2 ty
(y y0 )2 2 f
+ (t0 , y0 ) +
2 y 2
n nf
1 X n
+ (t t0 )nj (y y0 )j nj j (t0 , y0 )
n! j t y
j=0
n+1
n+1 f
1 X n+1
Rn (t, y) = (t t0 )n+1j (y y0 )j n+1j j (, )
(n + 1)! j t y
j=0
Outline
w0 =
wi+1 = wi + a1 f (ti + 1 , wi + 1 f (ti , wi ))
Method of Derivation
Method of Derivation
The first step is to determine values for a1 , 1 , and 1 with the property
that
h
a1 f (t + 1 , y + 1 ) T (2) (t, y) = f (t, y) + f (t, y),
2
with error no greater than O(h2 ), which is same as the order of the
local truncation error for the Taylor method of order two.
Method of Derivation
The first step is to determine values for a1 , 1 , and 1 with the property
that
h
a1 f (t + 1 , y + 1 ) T (2) (t, y) = f (t, y) + f (t, y),
2
with error no greater than O(h2 ), which is same as the order of the
local truncation error for the Taylor method of order two. Since
df f f
f (t, y) = (t, y) = (t, y) + (t, y) y (t) and y (t) = f (t, y),
dt t y
Method of Derivation
The first step is to determine values for a1 , 1 , and 1 with the property
that
h
a1 f (t + 1 , y + 1 ) T (2) (t, y) = f (t, y) + f (t, y),
2
with error no greater than O(h2 ), which is same as the order of the
local truncation error for the Taylor method of order two. Since
df f f
f (t, y) = (t, y) = (t, y) + (t, y) y (t) and y (t) = f (t, y),
dt t y
we have
h f h f
T (2) (t, y) = f (t, y) + (t, y) + (t, y) f (t, y)
2 t 2 y
f
a1 f (t + 1 , y + 1 ) = a1 f (t, y) + a1 1 (t, y)
t
f
+ a1 1 (t, y) + a1 R1 (t + 1 , y + 1 )
y
f
a1 f (t + 1 , y + 1 ) = a1 f (t, y) + a1 1 (t, y)
t
f
+ a1 1 (t, y) + a1 R1 (t + 1 , y + 1 )
y
where
21 2 f 2f 12 2 f
R1 (t + 1 , y + 1 ) = (, ) +
1 1 (, ) + (, )
2 t 2 ty 2 y 2
f
a1 f (t + 1 , y + 1 ) = a1 f (t, y) + a1 1 (t, y)
t
f
+ a1 1 (t, y) + a1 R1 (t + 1 , y + 1 )
y
and
h f h f
T (2) (t, y) = f (t, y) + (t, y) + (t, y) f (t, y)
2 t 2 y
f
a1 f (t + 1 , y + 1 ) = a1 f (t, y) + a1 1 (t, y)
t
f
+ a1 1 (t, y) + a1 R1 (t + 1 , y + 1 )
y
and
h f h f
T (2) (t, y) = f (t, y) + (t, y) + (t, y) f (t, y)
2 t 2 y
gives the three equations
h h
a1 = 1 a1 1 = a1 1 = f (t, y)
2 2
Numerical Analysis (Chapter 5) Runge-Kutta Methods R L Burden & J D Faires 11 / 34
Introduction Runge-Kutta 2 Example Runge-Kutta 4
h h
a1 = 1 a1 1 = a1 1 = f (t, y)
2 2
h h
a1 = 1 a1 1 = a1 1 = f (t, y)
2 2
h h
a1 = 1 1 = 1 = f (t, y)
2 2
so that
(2) h h h h
T (t, y) = f t + , y + f (t, y) R1 t + , y + f (t, y)
2 2 2 2
21 2 f 2f 12 2 f
R1 (t + 1 , y + 1 ) = (, ) + 1 1 (, ) + (, )
2 t 2 ty 2 y 2
21 2 f 2f 12 2 f
R1 (t + 1 , y + 1 ) = (, ) + 1 1 (, ) + (, )
2 t 2 ty 2 y 2
which leads to
h2 2 f h2 2f
h h
R1 t + , y + f (t, y) = (, ) + f (t, y) (, )
2 2 8 t 2 4 ty
h2 2f
+ (f (t, y))2 2 (, ).
8 y
w0 = ,
h h
wi+1 = wi + hf ti + , wi + f (ti , wi )
2 2
for i = 0, 1, . . . , N 1.
a1 f (ti + 1 , wi + 1 f (ti , wi ))
a1 f (ti + 1 , wi + 1 f (ti , wi ))
h h2
T (3) (t, y) = f (t, y) + f (t, y) + f (t, y)
2 6
h h2
T (3) (t, y) = f (t, y) + f (t, y) + f (t, y)
2 6
h h2
T (3) (t, y) = f (t, y) + f (t, y) + f (t, y)
2 6
h h2
T (3) (t, y) = f (t, y) + f (t, y) + f (t, y)
2 6
resulting from the expansion of (h2 /6)f (t, y). Consequently, the best
that can be obtained from using this form are methods with O(h2 ) local
truncation error.
Numerical Analysis (Chapter 5) Runge-Kutta Methods R L Burden & J D Faires 16 / 34
Introduction Runge-Kutta 2 Example Runge-Kutta 4
w0 =
h
wi+1 = wi + [f (ti , wi ) + f (ti+1 , wi + hf (ti , wi ))]
2
for i = 0, 1, . . . , N 1.
Outline
Example
Use the Midpoint Method and the Modified Euler Method with N = 10,
h = 0.2, ti = 0.2i, and w0 = 0.5 to approximate the solution to our
usual example,
y = y t 2 + 1, 0 t 2, y(0) = 0.5.
Example
Use the Midpoint Method and the Modified Euler Method with N = 10,
h = 0.2, ti = 0.2i, and w0 = 0.5 to approximate the solution to our
usual example,
y = y t 2 + 1, 0 t 2, y(0) = 0.5.
Note
The difference equations produced from the two formulae are
for each i = 0, 1, . . . , 9.
while the first two steps of the Modified Euler method give:
while the first two steps of the Modified Euler method give:
Outline
f (t + 1 , y + 1 f (t + 2 , y + 2 f (t, y)))
involving 4 parameters,
f (t + 1 , y + 1 f (t + 2 , y + 2 f (t, y)))
f (t + 1 , y + 1 f (t + 2 , y + 2 f (t, y)))
w0 =
h
wi+1 = wi + 4 (f (ti , wi )
2h 2h
ti + h3 , wi + h3 f (ti , wi )
+3 f ti + 3 , wi + 3 f
for i = 0, 1, . . . , N 1.
Numerical Analysis (Chapter 5) Runge-Kutta Methods R L Burden & J D Faires 23 / 34
Introduction Runge-Kutta 2 Example Runge-Kutta 4
y = y t 2 + 1, 0 t 2, y(0) = 0.5.
Note the decreased error throughout the range over the Midpoint and
Modified Euler approximations.
Heuns
ti y(ti ) Method Error
0.0 0.5000000 0.5000000 0
0.2 0.8292986 0.8292444 0.0000542
0.4 1.2140877 1.2139750 0.0001127
0.6 1.6489406 1.6487659 0.0001747
0.8 2.1272295 2.1269905 0.0002390
1.0 2.6408591 2.6405555 0.0003035
1.2 3.1799415 3.1795763 0.0003653
1.4 3.7324000 3.7319803 0.0004197
1.6 4.2834838 4.2830230 0.0004608
1.8 4.8151763 4.8146966 0.0004797
2.0 5.3054720 5.3050072 0.0004648
w0 =
k1 = hf (ti , wi )
h 1
k2 = hf ti + , wi + k1
2 2
h 1
k3 = hf ti + , wi + k2
2 2
k4 = hf (ti+1 , wi + k3 )
1
wi+1 = wi + (k1 + 2k2 + 2k3 + k4 )
6
for each i = 0, 1, . . . , N 1. This method has local truncation error
O(h4 ), provided the solution y(t) has five continuous derivatives.
Step 6 STOP
Example: Runge-Kutta 4
Use the Runge-Kutta method of order four with h = 0.2, N = 10 and
ti = 0.2i to obtain approximations to the solution of the initial-value
problem
y = y t 2 + 1, 0 t 2, y(0) = 0.5
Solution
The approximation to y(0.2) is obtained by
w0 = 0.5
Solution
The approximation to y(0.2) is obtained by
w0 = 0.5
k1 = 0.2f (0, 0.5) = 0.2(1.5) = 0.3
Solution
The approximation to y(0.2) is obtained by
w0 = 0.5
k1 = 0.2f (0, 0.5) = 0.2(1.5) = 0.3
k2 = 0.2f (0.1, 0.65) = 0.328
Solution
The approximation to y(0.2) is obtained by
w0 = 0.5
k1 = 0.2f (0, 0.5) = 0.2(1.5) = 0.3
k2 = 0.2f (0.1, 0.65) = 0.328
k3 = 0.2f (0.1, 0.664) = 0.3308
Solution
The approximation to y(0.2) is obtained by
w0 = 0.5
k1 = 0.2f (0, 0.5) = 0.2(1.5) = 0.3
k2 = 0.2f (0.1, 0.65) = 0.328
k3 = 0.2f (0.1, 0.664) = 0.3308
k4 = 0.2f (0.2, 0.8308) = 0.35816
Solution
The approximation to y(0.2) is obtained by
w0 = 0.5
k1 = 0.2f (0, 0.5) = 0.2(1.5) = 0.3
k2 = 0.2f (0.1, 0.65) = 0.328
k3 = 0.2f (0.1, 0.664) = 0.3308
k4 = 0.2f (0.2, 0.8308) = 0.35816
1
w1 = 0.5 + (0.3 + 2(0.328) + 2(0.3308) + 0.35816) = 0.8292933
6
Solution
The approximation to y(0.2) is obtained by
w0 = 0.5
k1 = 0.2f (0, 0.5) = 0.2(1.5) = 0.3
k2 = 0.2f (0.1, 0.65) = 0.328
k3 = 0.2f (0.1, 0.664) = 0.3308
k4 = 0.2f (0.2, 0.8308) = 0.35816
1
w1 = 0.5 + (0.3 + 2(0.328) + 2(0.3308) + 0.35816) = 0.8292933
6
The remaining results and their errors are listed in the following table.
Example
For the problem
y = y t 2 + 1, 0 t 2, y(0) = 0.5
Example
For the problem
y = y t 2 + 1, 0 t 2, y(0) = 0.5
Example
For the problem
y = y t 2 + 1, 0 t 2, y(0) = 0.5
Modified Runge-Kutta
Euler Euler Order Four
ti Exact h = 0.025 h = 0.05 h = 0.1
0.0 0.5000000 0.5000000 0.5000000 0.5000000
0.1 0.6574145 0.6554982 0.6573085 0.6574144
0.2 0.8292986 0.8253385 0.8290778 0.8292983
0.3 1.0150706 1.0089334 1.0147254 1.0150701
0.4 1.2140877 1.2056345 1.2136079 1.2140869
0.5 1.4256394 1.4147264 1.4250141 1.4256384