Upload
jun005
View
233
Download
0
Embed Size (px)
Citation preview
7/28/2019 Chapter 6 - Ordinary Differential Equation
1/61
MDC10103
Advanced Engineering
Mathematics
7/28/2019 Chapter 6 - Ordinary Differential Equation
2/61
Lectures Information
Saifulnizan Jamian
E5-001-06
012-3247301 07-4537334
7/28/2019 Chapter 6 - Ordinary Differential Equation
3/61
Contents
Ordinary Differential Equation
Partial Differential Equation Numerical Optimization
Statistical Methods
7/28/2019 Chapter 6 - Ordinary Differential Equation
4/61
Chapter 6
Ordinary Differential Equation
7/28/2019 Chapter 6 - Ordinary Differential Equation
5/61
Contents
Fourth-order Runge-Kutta method
Fourth-order Adams predictor-corrector method
System of differential equation by Fourth-order Runge-Kutta method
Boundary-value problem: linear shooting method and
finite-difference method
7/28/2019 Chapter 6 - Ordinary Differential Equation
6/61
Introduction
Ordinary differential equations arise in many different contextsthroughout mathematics and science (social and natural) one way
or another, because when describing changes mathematically, the
most accurate way uses differentials and derivatives (related,
though not quite the same). Since various differentials,derivatives, and functions become inevitably related to each other
via equations, a differential equation is the result, governing
dynamical phenomena, evolution and variation. Often, quantities
are defined as the rate of change of other quantities (time
derivatives), or gradients of quantities, which is how they enter
differential equations.
(Wikipedia)
7/28/2019 Chapter 6 - Ordinary Differential Equation
7/61
Example
Newton's second law of motion
t
7/28/2019 Chapter 6 - Ordinary Differential Equation
8/61
n t a - a ue ro em oFirst-Order Differential
EquationConsider an IVP of the first-order differential equation:
)1.6.()(),,(' 00 Eqyxyyxfy ==
Can be solved by:
a)Fourth-order Runge-Kutta Method (RK4)
b)Fourth-order Adam Predictor-Corrector Method
7/28/2019 Chapter 6 - Ordinary Differential Equation
9/61
Fourth-order Runge-KuttaMethod (RK4)
The solution of Eq. (6.1) by RK4 method is:
( )43211 226
1
kkkkyy ii ++++=+
( )
( )342
3
1
21
,;2
,2
2,2;,
kyhxhfkk
yh
xhfk
k
y
h
xhfkyxhfk
iiii
iiii
++=
++=
++==
where:
7/28/2019 Chapter 6 - Ordinary Differential Equation
10/61
Example 6.1
Solve the IVP y= x/y, y(0)=1 at x=0(0.2)1 using
RK4 method. If the exact solution is y=(x2+1)0.5,
find the absolute errors.
7/28/2019 Chapter 6 - Ordinary Differential Equation
11/61
Solution
( )43211
226
1kkkkyy
ii ++++=+
3
42
3
121
2.02.0;
2
1.02.0
2
1.02.0;2.0
ky
xk
ky
xk
k
y
xk
y
xk
i
i
i
i
i
i
i
i
++
=+
+=
+
+==
where:
2.0,),(' === hyxyxfy
7/28/2019 Chapter 6 - Ordinary Differential Equation
12/61
Solution
i xi yi k1 k2 k3 k4 Exact y error
0 0 1.0000 0.0000 0.0200 0.0198 0.0392 1.0000 0.E+00
1 0.2 1.0198 0.0392 0.0577 0.0572 0.0743 1.0198 6.E-07
2 0.4 1.0770 0.0743 0.0898 0.0891 0.1029 1.0770 2.E-06
3 0.6 1.1662 0.1029 0.1150 0.1144 0.1249 1.1662 3.E-06
4 0.8 1.2806 0.1249 0.1340 0.1336 0.1414 1.2806 4.E-06
5 1 1.4142 0.1414 0.1482 0.1478 0.1536 1.4142 4.E-06
7/28/2019 Chapter 6 - Ordinary Differential Equation
13/61
Example 6.2
Solve the IVP y= x2(1-3y), y(0)=1 at x=0(0.2)1
using RK4 method. Find the absolute errors if the
exact solution is
3
1
3
2 3
+=
x
ey
7/28/2019 Chapter 6 - Ordinary Differential Equation
14/61
Solution
( )43211
226
1kkkkyy
ii
++++=+
( ) ( )
( )
( ) ( )( )32
4
22
3
12
2
2
1
312.02.0
;2
311.02.0
2311.02.0;312.0
kyxk
kyxk
kyxkyxk
ii
ii
iiii
++=
++=
++==
where:
( ) 2.0,31),(' 2 === hyxyxfy
7/28/2019 Chapter 6 - Ordinary Differential Equation
15/61
Solution
i xi yi k1 k2 k3 k4 Exact y error0 0 1.0000 0.0000 -0.0040 -0.0040 -0.0159 1.0000 0.E+00
1 0.2 0.9947 -0.0159 -0.0353 -0.0348 -0.0602 0.9947 1.E-06
2 0.4 0.9587 -0.0600 -0.0893 -0.0871 -0.1163 0.9587 3.E-06
3 0.6 0.8705 -0.1160 -0.1409 -0.1372 -0.1536 0.8705 5.E-06
4 0.8 0.7329 -0.1534 -0.1569 -0.1560 -0.1461 0.7329 6.E-06
5 1 0.5786 -0.1472 -0.1247 -0.1328 -0.0972 0.5786 4.E-05
7/28/2019 Chapter 6 - Ordinary Differential Equation
16/61
Fourth-order AdamsPredictor-Corrector Method
The solution of Eq. (6.1) by this method is:
( )
( )2111
3211
519924
9375955
24
++
+
+++=
++=
iiiiP
iiC
iiiiiiP
ffffh
yy
ffffh
yy
Where superscript P and C are stands for predictor andcorrector equation, respectively.
Note: RK4 method is a single point method, where the new approximation solution is just
based on previous point, while Fourth-order Adams Predictor-corrector method is multiple
point method, where the new approximation solution is based on previous four points. To get
last three starting point we may approximate them by RK4 method.
7/28/2019 Chapter 6 - Ordinary Differential Equation
17/61
Example 6.3
Solve the IVP y= x/y, y(0)=1 at x=0(0.2)1 using
Fourth-order Adams Predictor-Corrector method.
If the exact solution is y=(x2+1)0.5, find the
absolute errors.
7/28/2019 Chapter 6 - Ordinary Differential Equation
18/61
Solution
( )43211 226
1kkkkyy ii ++++=+
3
42
3
121
2.02.0;
2
1.02.0
2
1.02.0;2.0
ky
xk
ky
xk
k
y
xk
y
xk
i
i
i
i
i
i
i
i
++
=+
+=
+
+==
where:
2.0,),(' === hy
xyxfy
Obtain y1, y2 and y3 from RK4:
7/28/2019 Chapter 6 - Ordinary Differential Equation
19/61
Solution
i xi yi k1 k2 k3 k4 Exact y error
0 0 1.0000 0.0000 0.0200 0.0198 0.0392 1.0000 0.E+00
1 0.2 1.0198 0.0392 0.0577 0.0572 0.0743 1.0198 6.E-07
2 0.4 1.0770 0.0743 0.0898 0.0891 0.1029 1.0770 2.E-06
3 0.6 1.1662 0.1029 0.1150 0.1144 0.1249 1.1662 3.E-06
Obtain y4 and y5 using Fourth-order Adams Predictor-
Corrector Method
+++=
++=
1
1
2
2
3
3
4
434
0
0
1
1
2
2
3
3
34
519924
2.0
937595524
2.0
y
x
y
x
y
x
y
xyy
y
x
y
x
y
x
y
x
yy
P
C
P
7/28/2019 Chapter 6 - Ordinary Differential Equation
20/61
Solution
i xi yp yi=yc Exact y error
0 0 1.0000 1.0000 0.E+00
1 0.2 1.0198 1.0198 4.E-06
2 0.4 1.0770 1.0770 3.E-05
3 0.6 1.1662 1.1662 1.E-05
4 0.8 1.2799 1.2807 1.2806 8.E-05
5 1 1.4139 1.4143 1.4142 1.E-04
+++=
++=
2
2
3
3
4
4
5
5
45
1
1
2
2
3
3
4
445
519924
2.0
9375955242.0
y
x
y
x
y
x
y
xyy
yx
yx
yx
yxyy
P
C
P
7/28/2019 Chapter 6 - Ordinary Differential Equation
21/61
Example 6.4
Solve the IVP y= x2(1-3y), y(0)=1 at x=0(0.2)1
using Fourth-order Adams Predictor-Corrector
method. Find the absolute errors if the exact
solution is
3
1
3
2
'
3
+=
x
ey
7/28/2019 Chapter 6 - Ordinary Differential Equation
22/61
Solution
( ) ( ) ( ) ( )( )
( ) ( ) ( ) ( )( )12
2
2
3
24
2
434
001
2
2
2
3
2
34
31315311931924
2.0
31931373159315524
2.0
123
123
yxyxyxyxyy
yxyxyxyxyy
PC
P
+++=
++=
Obtain y1, y2 and y3 from RK4.
Obtain y4 and y5 using Fourth-order Adams Predictor-
Corrector Method
( ) ( ) ( ) ( )( )
( ) ( ) ( ) ( )( )22
3
2
4
25
2
545
112
2
3
2
4
2
45
31315311931924
2.0
31931373159315524
2.0
234
234
yxyxyxyxyy
yxyxyxyxyy
PC
P
+++=
++=
7/28/2019 Chapter 6 - Ordinary Differential Equation
23/61
Solution
i xi yp yi=yc Exact y error
0 0 1.0000 1.0000 0.E+00
1 0.2 0.9947 0.9947 1.E-05
2 0.4 0.9587 0.9587 3.E-05
3 0.6 0.8705 0.8705 1.E-05
4 0.8 0.7277 0.7337 0.7329 8.E-04
5 1 0.5800 0.5782 0.5786 4.E-04
7/28/2019 Chapter 6 - Ordinary Differential Equation
24/61
System of First-OrderDifferential Equations
Consider the initial-value problem of first-order differential
equations
( )
( )yxtgdt
dy
yxtfdt
dx
,,
,,
=
=
with ( ) ( ) 0000 , ytyxtx ==
The solution of both ODEs using RK4 method will
be given by:( )
( )43211
43211
226
1
226
1
ggggyy
ffffxx
ii
ii
++++=
++++=
+
+
7/28/2019 Chapter 6 - Ordinary Differential Equation
25/61
System of First-OrderDifferential Equations
7 - 25
( )
( )
( )
( )33422
3
121
33422
3
121
,,;2
,2
,2
2
,
2
,
2
;,,
,,;2
,2
,2
2,
2,
2;,,
gyfxhthggg
yf
xh
thgg
gy
fx
hthggyxthgg
gyfxhthffgyfxhthff
gy
fx
hthffyxthff
iiiiii
ii
iiiii
iiiiii
ii
iiiii
+++=
+++=
+++==
+++=
+++=
+++==
where:
7/28/2019 Chapter 6 - Ordinary Differential Equation
26/61
Example 5
A simple RL-electrical circuit consists of electrical current i (in
ampheres), resistanceR (in ohms), inductanceL (in hengrys), and
electromotive forceE(t) (in volts), as shown in Figure below.
Given that q (in coulombs) is the charge, and R, and L are assumed
constants. Given that i = dq/dtand di/dt= d2q/dt2. According toKirchoffs second law, the current I satisfies the differential equation
Given thatR = 15,L = 3,E(t) = 120 and the initial condition q = 0 and i
= 0 when t= 0. Find i and q for 0t 2 with t= 0.25 using RK4
method. If the exact solution are q = 8(e-5t 1)/5 +8tand i = 8(1-e-5t),
find the absolute errors fori and q.
( )tEdt
dqR
dt
xdL =+
2
2
7/28/2019 Chapter 6 - Ordinary Differential Equation
27/61
SolutionGiven
hencedt
qd
dt
diand
dt
dqi
2
2
== ( )tEdt
dqR
dt
qdL =+
2
2
becomes
( )tERidt
diL =+
The second order differential becomes system of first ODE below:
( )
( ) iiiqtgL
RitEdtdi
iqtfidt
dq
540315120,,)(
,,
====
==
7/28/2019 Chapter 6 - Ordinary Differential Equation
28/61
SolutionUsing RK4 method,
( ) ( )4321143211 226
1;22
6
1ggggiiffffqq kkkk ++++=++++= ++
( )
( )
( )( )342
3
1
21
342
31
21
54025.0;2
54025.0
254025.0;54025.0
25.0;2
25.0;2
25.0;25.0
gigg
ig
g
igig
gifg
ifg
ifif
+=
+=
+==
+=
+=
+==
where:
7/28/2019 Chapter 6 - Ordinary Differential Equation
29/61
Solutionk t q i f1 g1 f2 g2 f3
0 0 0.0000 0.0000 0.0000 10.0000 1.2500 3.7500 0.4688
1 0.25 0.8919 5.5404 1.3851 3.0745 1.7694 1.1530 1.5292
2 0.5 2.5512 7.2438 1.8109 0.9453 1.9291 0.3545 1.8553
3 0.75 4.4465 7.7675 1.9419 0.2906 1.9782 0.1090 1.9555
4 1 6.4143 7.9285 1.9821 0.0894 1.9933 0.0335 1.9863
5 1.25 8.4044 7.9780 1.9945 0.0275 1.9979 0.0103 1.9958
6 1.5 10.4014 7.9932 1.9983 0.0084 1.9994 0.0032 1.9987
7 1.75 12.4004 7.9979 1.9995 0.0026 1.9998 0.0010 1.9996
8 2 14.4001 7.9994 1.9998 0.0008 1.9999 0.0003 1.9999
g3 f4 g4 exact q exact i error q error i
7.6563 1.9141 0.4297 0.0000 0.0000 0.0000 0.0000
2.3539 1.9736 0.1321 0.8584 5.7080 0.0335 0.1676
0.7237 1.9919 0.0406 2.5313 7.3433 0.0199 0.0995
0.2225 1.9975 0.0125 4.4376 7.8119 0.0089 0.04440.0684 1.9992 0.0038 6.4108 7.9461 0.0035 0.0176
0.0210 1.9998 0.0012 8.4031 7.9846 0.0013 0.0065
0.0065 1.9999 0.0004 10.4009 7.9956 0.0005 0.0023
0.0020 2.0000 0.0001 12.4003 7.9987 0.0002 0.0008
0.0006 2.0000 0.0000 14.4001 7.9996 0.0001 0.0003
oun ary a ue ro em
7/28/2019 Chapter 6 - Ordinary Differential Equation
30/61
oun ary- a ue ro em(BVP) of Second-Order
Differential EquationConsider a linear second-order differential equation)2.6.()()()()(')()(")( Eqxdxyxcxyxbxyxa =++
Can be solved by:
a)Shooting method
b)Finite-Difference Method (FDM)
With the boundary conditions (BCs)nn yxyyxy == )(;)( 00
7/28/2019 Chapter 6 - Ordinary Differential Equation
31/61
Shooting Method
Let
?)(;)()()()(')(
)(;)('
0
00
==++==
xzxdyxczxbxzxa
yxyzxy
Since so we can use it as our initial
guess of z(x0). Then, the system of IVP can be solved usingRK4 method. After the first trial, we will notice that the BC
y(xn) is not equal to yn, so we have to adjust (shoot) the initial
guess of z(x0) until it matches the BC y(xn)=yn. Therefore this
method is called shooting method.
Here Eq. (6.2) can be transformed into a system of IVP
as below:
)(')(")(' xzxythenzxy n ==
,'0
0
xx
yyyz
n
n
==
7/28/2019 Chapter 6 - Ordinary Differential Equation
32/61
Example 6
A simple RL-electrical circuit consists of electrical current i (in
ampheres), resistanceR (in ohms), inductanceL (in hengrys), and
electromotive forceE(t) (in volts), as shown in Figure below.
Given that q (in coulombs) is the charge, and R, and L are assumed
constants. Given that i = dq/dtand di/dt= d2q/dt2. According toKirchoffs second law, the current I satisfies the differential equation
Given thatR = 15,L = 3,E(t) = 120 and the BCs as follow:
q = 0 at t= 0 and q = 14.4 at t= 2
Find i and q for 0t 2 with h = 0.25 using Shooting method.
( )tEdt
dqR
dt
xdL =+
2
2
7/28/2019 Chapter 6 - Ordinary Differential Equation
33/61
Solution
7 - 33
STEP 1
Since the second initial condition i is unknown at t= 0, we can
guess this equal to 2.7
02
04.14)0( =
==dt
dqi
Solving by RK4 as in Example 5 gives the results in following
table.
7/28/2019 Chapter 6 - Ordinary Differential Equation
34/61
Solutionk t q i f1 g1 f2 g2 f3
0 0 0.0000 7.2000 1.8000 1.0000 1.9250 0.3750 1.8469
1 0.25 1.8892 7.7540 1.9385 0.3075 1.9769 0.1153 1.9529
2 0.5 3.8551 7.9244 1.9811 0.0945 1.9929 0.0354 1.9855
3 0.75 5.8447 7.9767 1.9942 0.0291 1.9978 0.0109 1.9955
4 1 7.8414 7.9929 1.9982 0.0089 1.9993 0.0034 1.9986
5 1.25 9.8404 7.9978 1.9995 0.0027 1.9998 0.0010 1.9996
6 1.5 11.8401 7.9993 1.9998 0.0008 1.9999 0.0003 1.9999
7 1.75 13.8400 7.9998 1.9999 0.0003 2.0000 0.0001 2.00008 2 15.8400 7.9999 2.0000 0.0001 2.0000 0.0000 2.0000
g3 f4 g4
0.7656 1.9914 0.0430
0.2354 1.9974 0.0132
0.0724 1.9992 0.0041
0.0223 1.9998 0.00120.0068 1.9999 0.0004
0.0021 2.0000 0.0001
0.0006 2.0000 0.0000
0.0002 2.0000 0.0000
0.0001 2.0000 0.0000
7/28/2019 Chapter 6 - Ordinary Differential Equation
35/61
Solution
7 - 35
STEP 2
Since q(2) = 15.84 is higher than the value of BC given, so we
have to reduce our initial guess ofi(0). Let try i(0) = 1 and resolve
again using RK4.
7/28/2019 Chapter 6 - Ordinary Differential Equation
36/61
Solutionk t q i f1 g1 f2 g2 f3
0 0 0.0000 1.0000 0.2500 8.7500 1.3438 3.2813 0.6602
1 0.25 1.0304 5.8478 1.4620 2.6902 1.7982 1.0088 1.5881
2 0.5 2.7323 7.3383 1.8346 0.8271 1.9380 0.3102 1.8733
3 0.75 4.6407 7.7966 1.9491 0.2543 1.9809 0.0954 1.9611
4 1 6.6125 7.9375 1.9844 0.0782 1.9941 0.0293 1.9880
5 1.25 8.6038 7.9808 1.9952 0.0240 1.9982 0.0090 1.9963
6 1.5 10.6012 7.9941 1.9985 0.0074 1.9994 0.0028 1.9989
7 1.75 12.6004 7.9982 1.9995 0.0023 1.9998 0.0009 1.99978 2 14.6001 7.9994 1.9999 0.0007 1.9999 0.0003 1.9999
g3 f4 g4
6.6992 1.9248 0.3760
2.0597 1.9769 0.1156
0.6333 1.9929 0.0355
0.1947 1.9978 0.01090.0599 1.9993 0.0034
0.0184 1.9998 0.0010
0.0057 1.9999 0.0003
0.0017 2.0000 0.0001
0.0005 2.0000 0.0000
7/28/2019 Chapter 6 - Ordinary Differential Equation
37/61
Solution
STEP 3Again this time, q(2) = 14.6 is still higher than the value of BC
given. If we try to reduce the initial guess ofi(0) slowly, we will
achieve at one stage that the result ofq(2) match the BC given.
However, a faster way rather than slowly adjusting the initial
guess is using the linear interpolation based on the data obtainedin step 1 and step 2 ( or after two trials).
j 0 1 2
q(2) 15.84 14.6 14.4
i(0) 7.2 1?
0006.0
)1(84.156.14
84.154.14)2.7(
6.1484.15
6.144.14)4.14(
)( 101
00
10
1
=
+
=
+
=
f
iqq
qqi
qqqf
7/28/2019 Chapter 6 - Ordinary Differential Equation
38/61
Solution
STEP 4So in the third trial we use the initial guess ofi(0) = -0.0006 and
resolve again using RK4. This time we will see the BCs is
fulfilled.
7/28/2019 Chapter 6 - Ordinary Differential Equation
39/61
Solutionk t q i f1 g1 f2 g2 f3
0 0 0.0000 -0.0006 -0.0002 10.0008 1.2499 3.7503 0.4686
1 0.25 0.8918 5.5402 1.3850 3.0748 1.7694 1.1530 1.5292
2 0.5 2.5511 7.2437 1.8109 0.9454 1.9291 0.3545 1.8552
3 0.75 4.4464 7.7675 1.9419 0.2907 1.9782 0.1090 1.9555
4 1 6.4142 7.9285 1.9821 0.0894 1.9933 0.0335 1.9863
5 1.25 8.4043 7.9780 1.9945 0.0275 1.9979 0.0103 1.9958
6 1.5 10.4012 7.9932 1.9983 0.0084 1.9994 0.0032 1.9987
7 1.75 12.4003 7.9979 1.9995 0.0026 1.9998 0.0010 1.99968 2 14.4000 7.9994 1.9998 0.0008 1.9999 0.0003 1.9999
g3 f4 g4
7.6568 1.9141 0.4297
2.3541 1.9736 0.1321
0.7238 1.9919 0.0406
0.2225 1.9975 0.01250.0684 1.9992 0.0038
0.0210 1.9998 0.0012
0.0065 1.9999 0.0004
0.0020 2.0000 0.0001
0.0006 2.0000 0.0000
7/28/2019 Chapter 6 - Ordinary Differential Equation
40/61
Example 7
The radial temperature distribution in a cylinder is governed by
Using shooting method to find the radial temperature distribution if the
inner radius is 5 units and outer radius is 10 units. The inner and outersurface are maintained at 120C and 60 C respectively with h = 1.
01
2
2
=+dt
dT
rdr
Td
7/28/2019 Chapter 6 - Ordinary Differential Equation
41/61
Solution
7 - 41
STEP 1
T(5) =120, T(10) =60
( )
?)5(;),,(
,,
2
2
====
==
ssTrgr
s
dr
ds
dr
Td
sTrfsdr
dT
Since we do not have the information of s(5), we can guess that
12510
12060)5( =
==dr
dTs
Solving by RK4.
7/28/2019 Chapter 6 - Ordinary Differential Equation
42/61
SolutionUsing RK4 method,
( ) ( )4321143211 226
1;22
6
1ggggssffffTT iiii ++++=++++= ++
hr
gsg
hr
gs
g
hr
gs
g
r
sg
gsfg
sfg
sfsf
+
+=
+
+=
+
+==
+=+=+==
14
2
3
1
21
3423121
;
2
2;
2
2;
;2;2;
where:
7/28/2019 Chapter 6 - Ordinary Differential Equation
43/61
Solutioni r T s f1 g1 f2 g2 f3
0 5 120.0000 -12.0000 -12.0000 2.4000 -10.8000 1.9636 -11.01821 6 109.0612 -10.0000 -10.0000 1.6667 -9.1667 1.4103 -9.2949
2 7 99.8123 -8.5714 -8.5714 1.2245 -7.9592 1.0612 -8.0408
3 8 91.8005 -7.5000 -7.5000 0.9375 -7.0313 0.8272 -7.0864
4 9 84.7336 -6.6667 -6.6667 0.7407 -6.2963 0.6628 -6.3353
5 10 78.4120 -6.0000 -6.0000 0.6000 -5.7000 0.5429 -5.7286
g3 f4 g4
2.0033 -9.9967 1.6661
1.4300 -8.5700 1.2243
1.0721 -7.4993 0.9374
0.8337 -6.6663 0.7407
0.6669 -5.9998 0.6000
0.5456 -5.4544 0.4959
7/28/2019 Chapter 6 - Ordinary Differential Equation
44/61
Solution
7 - 44
STEP 2
Since T(10) = 78.412 is higher than the value of BC given, so we
have to reduce our initial guess of s(5). Let try s(5) = -15 and
resolve again using RK4.
7/28/2019 Chapter 6 - Ordinary Differential Equation
45/61
Solutioni r T s f1 g1 f2 g2 f3
0 5 120.0000 -15.0000 -15.0000 3.0000 -13.5000 2.4545 -13.77271 6 106.3264 -12.5000 -12.5000 2.0833 -11.4583 1.7628 -11.6186
2 7 94.7654 -10.7143 -10.7143 1.5306 -9.9490 1.3265 -10.0510
3 8 84.7506 -9.3750 -9.3750 1.1719 -8.7891 1.0340 -8.8580
4 9 75.9170 -8.3333 -8.3333 0.9259 -7.8704 0.8285 -7.9191
5 10 68.0150 -7.5000 -7.5000 0.7500 -7.1250 0.6786 -7.1607
g3 f4 g4
2.5041 -12.4959 2.0826
1.7875 -10.7125 1.5304
1.3401 -9.3741 1.1718
1.0421 -8.3329 0.9259
0.8336 -7.4997 0.7500
0.6820 -6.8180 0.6198
7/28/2019 Chapter 6 - Ordinary Differential Equation
46/61
Solution
STEP 3Again this time, T(10) = 68.015 is still higher than the value of
BC given. Use a faster way rather than slowly adjusting the initial
guess, using the linear interpolation based on the data obtained in
step 1 and step 2 ( or after two trials).
j 0 1 2
T 78.412 68.015 60
s -12 -15?
3127.17
)15(412.78015.68
412.7860)12(
015.68412.78
015.6860)60(
)( 101
00
10
1
=
+
=
+
=
f
sTT
TTsTT
TTTf
7/28/2019 Chapter 6 - Ordinary Differential Equation
47/61
SolutionSTEP 4
So in the third trial we use the initial guess ofs(5) = -17.3127 and
resolve again using RK4. This time we will see the BCs is
fulfilled.
7/28/2019 Chapter 6 - Ordinary Differential Equation
48/61
Solutioni r T s f1 g1 f2 g2 f3
0 5 120.0000 -17.3127 -17.3127 3.4625 -15.5814 2.8330 -15.89621 6 104.2183 -14.4273 -14.4273 2.4045 -13.2250 2.0346 -13.4099
2 7 90.8747 -12.3662 -12.3662 1.7666 -11.4829 1.5311 -11.6007
3 8 79.3159 -10.8204 -10.8204 1.3526 -10.1442 1.1934 -10.2237
4 9 69.1203 -9.6182 -9.6182 1.0687 -9.0838 0.9562 -9.1401
5 10 59.9999 -8.6564 -8.6564 0.8656 -8.2235 0.7832 -8.2648
g3 f4 g4
2.8902 -14.4225 2.4037
2.0631 -12.3642 1.7663
1.5468 -10.8195 1.3524
1.2028 -9.6176 1.0686
0.9621 -8.6561 0.8656
0.7871 -7.8692 0.7154
7/28/2019 Chapter 6 - Ordinary Differential Equation
49/61
Example 8
Solve the BVP ofexy+xy-5(1 +x)y =x3
with the following BCs
y(0) = 2 , y(2) = 5
Atx = 0(0.5)2 using shooting method.
7/28/2019 Chapter 6 - Ordinary Differential Equation
50/61
Solution
BVP Fi it Diff
7/28/2019 Chapter 6 - Ordinary Differential Equation
51/61
BVP: Finite-DifferenceMethod
To solve Eq. (6.2) using FDM, the interval ofx is divided inton subintervals with width = h such thatxi =x0 + ih. Then
substitute
Into the Eq. (6.2) yields a tridiagonal system ofn - 2 equations
to be solved (solve for y from i = 1 to n - 10
h
yy
xyandh
yyy
xy
iiiii
2)('
2
)("
11
2
11 ++
=
+
=
7/28/2019 Chapter 6 - Ordinary Differential Equation
52/61
Example 9
Solve the BVP ofexy+xy-5(1 +x)y =x3
with the following BCs
y(0) = 2 , y(2) = 5
Atx = 0(0.5)2 using FDM.
7/28/2019 Chapter 6 - Ordinary Differential Equation
53/61
Solution
7 - 53
STEP 1
( )
( ) 3112
11
3
15
2
2
5.0,15'"
iiiii
iiiix
x
xyx
h
yyx
h
yyye
hxyxxyye
i =+
+
+==++
++
Multiply by h2 = 0.25 at both hand-side yields
( ) ( ) ( ) 31111 25.0125.125.02 iiiiiiiiix xyxyyxyyye i =+++ ++
Rearranged this equation
( ) ( )( ) ( )3
11 25.025.0125.1225.0 iiix
ii
x
ii
x xyxeyxeyxe iii =++++ +
7/28/2019 Chapter 6 - Ordinary Differential Equation
54/61
SolutionSTEP 2
Put in the BCs in the table below
l xi yi
0 0 2
1 0.5 y1
2 1.0 y2
3 1.5 y3
4 2 5There are 3 value of y to be solved. Therefore 3
simultaneous equations are required.
7/28/2019 Chapter 6 - Ordinary Differential Equation
55/61
SolutionSTEP 3
Obtain the equations by inserting value ofx based on ii (exi
0.25xi)yi-
1
+ (-2exi-1.25(1+xi)
yi + (exi
0.25xi)Yi+1 = 0.25xi
3
1 1.524 y0 + -5.172 y1 + 1.774 y2 = 0.031
2 2.468 y1 + -7.937 y2 + 2.968 y3 = 0.250
3 4.107 y2 + -12.088 y3 + 4.857 y4 = 0.844
7/28/2019 Chapter 6 - Ordinary Differential Equation
56/61
SolutionSTEP 4
Substituting BCs, y(0)=2=y0; y(2)=5=y4i (exi
0.25xi)yi-
1
+ (-2exi-1.25(1+xi)
yi + (exi
0.25xi)yi+1 = 0.25xi
3
1 1.524 2 + -5.172 y1 + 1.774 y2 = 0.031
2 2.468 y1 + -7.937 y2 + 2.968 y3 = 0.250
3 4.107 y2 + -12.088 y3 + 4.857 5 = 0.844
i (exi 0.25xi)
yi-
1
+ (-2exi-1.25(1+xi)
yi + (exi
0.25xi)yi+1 = 0.25xi
3
1 -5.172 y1 + 1.774 y2 = -3.017
2 2.468 y1 + -7.937 y2 + 2.968 y3 = 0.250
3 4.107 y2 + -12.088 y3 = -23.441
yields
7/28/2019 Chapter 6 - Ordinary Differential Equation
57/61
Solution
STEP 5
Solve by Gauss-Seidel Iteration method
=
441.23
250.0
017.3
088.12107.40
968.2937.7468.2
0774.1172.5
3
2
1
y
y
y
088.12
107.4441.23
937.7
968.2468.2250.0
172.5
774.1107.3
)1(
2)1(
3
)(
1
)1(
1)1(
2
)(
2)1(
1
=
=
=
++
++
+
kk
kkk
kk
yy
yy
y
yy
7/28/2019 Chapter 6 - Ordinary Differential Equation
58/61
Solutionk y1 y2 y3
0 0.000 0.000 0.000
1 0.583 0.150 1.990
2 0.635 0.910 2.248
3 0.895 1.088 2.309
4 0.956 1.129 2.323
5 0.971 1.139 2.326
6 0.974 1.141 2.327
Since max{|y(6) y(5)|} = max {0.003,0.002,0.001} = 0.003 < =0.005,
so the solution is y1 = 0.974, y2 = 1.141 and y3=2.327.
7/28/2019 Chapter 6 - Ordinary Differential Equation
59/61
Exercise
7 - 59
7/28/2019 Chapter 6 - Ordinary Differential Equation
60/61
SolutionSTEP 3
Obtain the equations by inserting value ofx based on ii yi-
1
+ yi + Yi+1 =
1 0.976 y0 + -1.7681 y1 + 0.888 y2 = 0.9924
2 1.0814 y1 + -1.8589 y2 + 0.8894 y3 = 0.0135
3 1.1556 y2 + -1.8711 y3 + 0.8436 y4 = 0.0112
4 1.1978 y3 + -1.8037 y4 =
-1.4902
7/28/2019 Chapter 6 - Ordinary Differential Equation
61/61
SolutionSTEP 3
Obtain the equations by inserting value ofx based on ii yi-
1
+ yi + Yi+1 =
1 y0 + -1.7681 y1 + 0.888 y2 = 0.9924
2 1.0814 y1 + -1.8589 y2 + 0.8894 y3 = 0.0135
3 1.1556 y2 + -1.8711 y3 + 0.8436 y4 = 0.0112
4 1.1978 y3 + -1.8037 y4 =
-1.4902