0% found this document useful (0 votes)
49 views

Ordinary Differential Equations: Runge-Kutta 2 Order Method

The document describes various Runge-Kutta 2nd order methods for numerically solving ordinary differential equations, including Heun's method, the midpoint method, and Ralston's method. It provides the general form of the Runge-Kutta 2nd order method and the equations defining each specific method. An example problem applying Heun's method to solve the cooling of a hot ball is worked out in detail. The accuracy of Heun's method is evaluated compared to the exact solution for different step sizes. Comparisons are made between the accuracy of Euler's method, Heun's method, the midpoint method, and Ralston's method.

Uploaded by

BleachByakuya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Ordinary Differential Equations: Runge-Kutta 2 Order Method

The document describes various Runge-Kutta 2nd order methods for numerically solving ordinary differential equations, including Heun's method, the midpoint method, and Ralston's method. It provides the general form of the Runge-Kutta 2nd order method and the equations defining each specific method. An example problem applying Heun's method to solve the cooling of a hot ball is worked out in detail. The accuracy of Heun's method is evaluated compared to the exact solution for different step sizes. Comparisons are made between the accuracy of Euler's method, Heun's method, the midpoint method, and Ralston's method.

Uploaded by

BleachByakuya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

1

RUNGE-KUTTA 2ND ORDER METHOD

Rokiah @ Rozita Ahmad, Assoc. Prof. Dr

Ordinary Differential Equations

12/8/201
4

Runge-Kutta 2nd Order Method


dy
f ( x, y ), y (0) y0
For
dx

Runge Kutta 2nd order method is given by


yi 1 yi a1k1 a 2 k 2 h

where

k1 f xi , yi

k2 f xi p1h, yi q11k1h
Rokiah @ Rozita Ahmad, Assoc.. Prof. Dr

12/8/2014

Heuns Method
Heuns method
1
2
p1 1

a1
.

Slope f xi h, y i k1h

Slope f xi , yi

q11 1

resulting in
1
1
yi 1 yi k1 k 2 h
2
2

Average Slope
yi

1
f xi h, yi k1h f xi , yi
2

x
xi

where
Figure 1.
k1 f x i , y i
k 2 f x i h, y i k1 h
Rokiah @ Rozita Ahmad, Assoc.. Prof. Dr

yi+1, predicted

xi+1

Runge-Kutta 2nd order method (Heuns method)


12/8/2014

Midpoint Method
Here a2 1 is chosen, giving

a1 0

1
p1
2

resulting in

1
q11
2

yi 1 yi k 2 h

where k f x , y
1
i i
1
1

k 2 f x i h , y i k1 h
2
2

Rokiah @ Rozita Ahmad, Assoc.. Prof. Dr

12/8/2014

Ralstons Method
2
is chosen, giving
3

Here a 2
1
a1
3

3
p1
4

resulting in
y i 1

where

3
q11
4

1
2
y i ( k1 k 2 ) h
3
3

k1 f xi , yi

3
3

k 2 f x i h , y i k1 h
4
4

12/8/2014

Example
A ball at 1200K is allowed to cool down in air at an ambient temperature
of 300K. Assuming heat is lost only due to radiation, the differential
equation for the temperature of the ball is given by
d
2.2067 10 12 4 81 10 8 , 0 1200 K
dt

Find the temperature at

t 480 seconds using Heuns method. Assume a step size of

h 240 seconds.
d
2.2067 10 12 4 81 10 8
dt

f t , 2.2067 10 12 4 81 10 8

1
1
i 1 i k1 k 2 h
2
2
Rokiah @ Rozita Ahmad, Dr

12/8/20
14

Solution
i 0, t0 0, 0 (0) 1200 K

Step 1:

k1 f t 0 , o f 0,1200

2.2067 10 12 1200 4 81 10 8

4.5579

k 2 f t 0 h, 0 k1 h f 0 240,1200 4.5579 240 f 240,106.09

2.2067 10 12 106.09 4 81 10 8

0.017595

1
1
1 0 k1 k 2 h
2
2
1
1

1200 4.5579 0.017595 240


2
2

1200 2.2702240
655.16 K

Rokiah @ Rozita Ahmad, Dr

12/8/20
14

Solution Cont
Step 2: i 1, t1 t 0 h 0 240 240,1 655.16 K
k1 f t1 ,1 f 240,655.16 2.2067 10 12 655.16 4 81 10 8 0.38869
k 2 f t1 h,1 k1 h f 240 240,655.16 0.38869 240 f 480,561.87

2.2067 10 12 561.87 4 81 10 8

0.20206

1
1
2 1 k1 k 2 h
2
2
1
1

655.16 0.38869 0.20206 240


2

655.16 0.29538240

584.27 K
Rokiah @ Rozita Ahmad, Dr

12/8/20
14

Solution Cont

The exact solution of the ordinary differential equation is given by the


solution of a non-linear equation as

0.92593 ln

300
1.8519 tan 1 0.0033333 0.22067 10 3 t 2.9282
300

The solution to this nonlinear equation at t=480 seconds is

(480) 647.57 K

Rokiah @ Rozita Ahmad, Dr

12/8/20
14

10

Comparison with exact results

Temperature, (K)

1200
h=120

Exact

800

h=240
400

h=480

0
0

100

200

300

400

500

-400
Time, t(sec)

Figure 2. Heuns method results for different step sizes


Rokiah @ Rozita Ahmad, Dr

12/8/20
14

11

Effect of step size


Table 1. Temperature at 480 seconds as a function of step size, h
Size
Step h
480
240
120
60
30

480

-393.87
584.27
651.35
649.91
648.21

Et
1041.4
63.304
-3.7762
-2.3406
-0.63219

(480) 647.57 K
Rokiah @ Rozita Ahmad, Dr

|t | %
160.82
9.7756
0.58313
0.36145
0.097625

(exact)
12/8/20
14

Effects of step size on


Heuns Method

12

Temperature, (480)

800
600
400
200
0
0

100

-200

200
300
Step size, h

400

500

-400

Figure 3. Effect of step size in Heuns method

Rokiah @ Rozita Ahmad, Dr

12/8/20
14

Comparison of Euler and


Runge-Kutta 2nd Order
Methods

13

Table 2. Comparison of Euler and the Runge-Kutta methods


Step size,
h

480
240
120
60
30

( 480 )
Euler

Heun

Midpoint

Ralston

-987.84
110.32
546.77
614.97
632.77

-393.87
584.27
651.35
649.91
648.21

1208.4
976.87
690.20
654.85
649.02

449.78
690.01
667.71
652.25
648.61

Rokiah @ Rozita Ahmad, Dr

(480) 647.57 K (exact)

12/8/20
14

Comparison of Euler and


Runge-Kutta 2nd Order
Methods

14

Table 2. Comparison of Euler and the Runge-Kutta methods


Step size,
h

480
240
120
60
30
Rokiah @ Rozita Ahmad, Dr

t %
Euler

Heun

Midpoint Ralston

252.54
82.964
15.566
5.0352
2.2864

160.82
9.7756
0.58313
0.36145
0.097625

86.612
50.851
6.5823
1.1239
0.22353

30.544
6.5537
3.1092
0.72299
0.15940

(480) 647.57 K (exact)

12/8/20
14

Comparison of Euler and


Runge-Kutta 2nd Order
Methods

15

1200

Temperature, (K)

1100

Midpoint

1000
900

Ralston

800

Heun

700

Analytical

600

Euler
500
0

100

200

300

400

500

600

Time, t (sec)

Figure 4. Comparison of Euler and Runge Kutta 2nd order methods with
12/8/20
exact
results.
Rokiah @ Rozita Ahmad, Dr
14

You might also like