Post on 18-Dec-2015
04/18/23http://
numericalmethods.eng.usf.edu 1
Runge 2nd Order Method
Mechanical Engineering Majors
Authors: Autar Kaw, Charlie Barker
http://numericalmethods.eng.usf.eduTransforming Numerical Methods Education for STEM
Undergraduates
Runge-Kutta 2nd Order Method
http://numericalmethods.eng.usf.edu
http://numericalmethods.eng.usf.edu3
Runge-Kutta 2nd Order Method
Runge Kutta 2nd order method is given by
hkakayy ii 22111
where
ii yxfk ,1
hkqyhpxfk ii 11112 ,
For0)0(),,( yyyxf
dx
dy
http://numericalmethods.eng.usf.edu4
Heun’s Method
x
y
xi xi+1
yi+1, predicted
yi
Figure 1 Runge-Kutta 2nd order method (Heun’s method)
hkyhxfSlope ii 1,
iiii yxfhkyhxfSlopeAverage ,,2
1 1
ii yxfSlope ,
Heun’s method
2
11 a
11 p
111 q
resulting in
hkkyy ii
211 2
1
2
1
where
ii yxfk ,1
hkyhxfk ii 12 ,
Here a2=1/2 is chosen
http://numericalmethods.eng.usf.edu5
Midpoint MethodHere 12 a is chosen, giving
01 a
2
11 p
2
111 q
resulting in
hkyy ii 21
where
ii yxfk ,1
hkyhxfk ii 12 2
1,
2
1
http://numericalmethods.eng.usf.edu6
Ralston’s MethodHere
3
22 a is chosen, giving
3
11 a
4
31 p
4
311 q
resulting in
hkkyy ii
211 3
2
3
1
where ii yxfk ,1
hkyhxfk ii 12 4
3,
4
3
http://numericalmethods.eng.usf.edu7
How to write Ordinary Differential Equation
Example
50,3.12 yeydx
dy x
is rewritten as
50,23.1 yyedx
dy x
In this case
yeyxf x 23.1,
How does one write a first order differential equation in the form of
yxfdx
dy,
http://numericalmethods.eng.usf.edu8
ExampleA solid steel shaft at room temperature of 27°C is needed to be contracted so it can be shrunk-fit into a hollow hub. It is placed in a refrigerated chamber that is maintained at −33°C. The rate of change of temperature of the solid shaft is given by
C270
33588510425
1035110332106931033.5
2
2335466
θ.θ.
θ.θ.θ.
dt
dθ
Find the temperature of the steel shaft after 24 hours. Take a step size of h = 43200 seconds.
335885104251035110332106931033.5 22335466 θ.θ.θ.θ.θ.dt
dθ
335885104251035110332106931033.5 22335466 θ.θ.θ.θ.θ.t,θf
hkkii
211 2
1
2
1
http://numericalmethods.eng.usf.edu9
SolutionStep 1: For 27,0,0 00 ti
0020893.0
3327588.5271042.5271035.1
271033.2271069.31033.527,0,
223
35466
01
ftfk o
0092607.0
33278.63588.5278.631042.5278.631035.1
278.631033.2278.631069.31033.5
278.63,43200432000020893.027,432000,
223
35466
1002
ffhkhtfk
C
hkk
16.218432000056750.027
432000092607.02
10020893.0
2
127
2
1
2
12101
http://numericalmethods.eng.usf.edu10
Solution ContStep 2: Cti 16.218,43200,1 11
4304.8
3316.218588.516.2181042.516.2181035.1
16.2181033.216.2181069.31033.5
16.218,43200,
223
35466
111
ftfk
17
223
35466
1112
102638.1
33364410588.53644101042.53644101035.1
)364410(1033.2)364410(1069.31033.5
364410,86400432004304.816.218,4320043200,
ffhkhtfk
C107298.243200103190.616.218
43200102638.12
14304.8
2
116.218
2
1
2
1
2116
172112
hkk
http://numericalmethods.eng.usf.edu11
Solution Cont
The solution to this nonlinear equation at t=86400s is
C 099.2686400
http://numericalmethods.eng.usf.edu12
Comparison with exact results
Figure 2. Heun’s method results for different step sizes
Step size,
864004320021600108005400
−58466−2.7298×1021
−24.537−25.785−26.027
584402.7298×1021
−1.5619−0.31368−0.072214
2239201.0460×1011
5.98451.2019
0.27670
http://numericalmethods.eng.usf.edu13
Effect of step size
h tE %|| t
(exact) C 099.2686400
Table 1. Effect of step size for Heun’s method
86400
http://numericalmethods.eng.usf.edu14
Effects of step size on Heun’s Method
Figure 3. Effect of step size in Heun’s method
Step size,h Euler Heun Midpoint Ralston
864004320021600108005400
−153.52−464.32−29.541−27.795−26.958
−58466−2.7298×1021
−24.537−25.785−26.027
−774.64−0.33691−24.069−25.808−26.039
−12163−19.776−24.268−25.777−26.032
http://numericalmethods.eng.usf.edu15
Comparison of Euler and Runge-Kutta 2nd Order
MethodsTable 2. Comparison of Euler and the Runge-Kutta methods
(exact) C 099.2686400
)86400(
Stepsize,
h Euler Heun Midpoint Ralston
864004320021600108005400
448.34737.9714.4267.09573.5755
122160
5.72921.1993
0.27435
1027.676.3607.05081.0707
0.22604
2384442.5716.63051.2135
0.25776
http://numericalmethods.eng.usf.edu16
Comparison of Euler and Runge-Kutta 2nd Order
Methods
C 217.25)86400(
Table 2. Comparison of Euler and the Runge-Kutta methods
(exact)
%t
11109064.7
http://numericalmethods.eng.usf.edu17
Comparison of Euler and Runge-Kutta 2nd Order
Methods
Figure 4. Comparison of Euler and Runge Kutta 2nd order methods with exact results.
Additional ResourcesFor all resources on this topic such as digital audiovisual lectures, primers, textbook chapters, multiple-choice tests, worksheets in MATLAB, MATHEMATICA, MathCad and MAPLE, blogs, related physical problems, please visit
http://numericalmethods.eng.usf.edu/topics/runge_kutta_2nd_method.html