Sie sind auf Seite 1von 61

MDC10103

Advanced Engineering
Mathematics

Lectures Information

Saifulnizan Jamian
E5-001-06
012-3247301
07-4537334
saifulnz@uthm.edu.my

Contents

Ordinary Differential Equation


Partial Differential Equation
Numerical Optimization
Statistical Methods

Chapter 6
Ordinary Differential Equation

Contents
Fourth-order Runge-Kutta method
Fourth-order Adams predictor-corrector method
System of differential equation by Fourth-order RungeKutta method
Boundary-value problem: linear shooting method and
finite-difference method

Introduction
Ordinary differential equations arise in many different contexts
throughout 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)

Example
Newton's second law of motion

Initial-Value Problem of
First-Order Differential
Equation
Consider an IVP of the first-order differential equation:

y ' = f ( x, y ), y ( x0 ) = y0

Eq.(6.1)

Can be solved by:


a)Fourth-order Runge-Kutta Method (RK4)
b)Fourth-order Adam Predictor-Corrector Method

Fourth-order Runge-Kutta
Method (RK4)
The solution of Eq. (6.1) by RK4 method is:

1
yi +1 = yi + ( k1 + 2k 2 + 2k3 + k 4 )
6

where:

h
k1

k1 = hf ( xi , yi ) ; k 2 = hf xi + , yi +
2
2

h
k2

k3 = hf xi + , yi + ; k 4 = hf ( xi + h, yi + k3 )
2
2

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.

Solution
x
y ' = f ( x, y ) = , h = 0.2
y
1
yi +1 = yi + ( k1 + 2k 2 + 2k3 + k 4 )
6
where:

xi
xi + 0.1
k1 = 0.2 ; k 2 = 0.2
k1
yi
yi +
2
xi + 0.1
xi + 0.2
k3 = 0.2
; k 4 = 0.2
k2
yi + k 3
yi +
2

Solution
i

xi
0
1
2
3
4
5

yi
0
0.2
0.4
0.6
0.8
1

k1
1.0000
1.0198
1.0770
1.1662
1.2806
1.4142

k2
0.0000
0.0392
0.0743
0.1029
0.1249
0.1414

k3
0.0200
0.0577
0.0898
0.1150
0.1340
0.1482

k4
0.0198
0.0572
0.0891
0.1144
0.1336
0.1478

Exact y error
0.0392 1.0000 0.E+00
0.0743 1.0198
6.E-07
0.1029 1.0770
2.E-06
0.1249 1.1662
3.E-06
0.1414 1.2806
4.E-06
0.1536 1.4142
4.E-06

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

2 x 3
1
y= e
+
3
3

Solution
y ' = f ( x, y ) = x (1 3 y ) , h = 0.2
2

1
yi +1 = yi + ( k1 + 2k 2 + 2k3 + k 4 )
6

where:

k1

k1 = 0.2 xi (1 3 yi ) ; k 2 = 0.2( xi + 0.1) 1 3 yi +


2

k2

k3 = 0.2( xi + 0.1) 1 3 yi + ;
2

k 4 = 0.2( xi + 0.2 ) (1 3( yi + k3 ) )
2

Solution
i

xi
0
1
2
3
4
5

yi
0
0.2
0.4
0.6
0.8
1

k1
1.0000
0.9947
0.9587
0.8705
0.7329
0.5786

k2
k3
k4
Exact y error
0.0000 -0.0040 -0.0040 -0.0159 1.0000 0.E+00
-0.0159 -0.0353 -0.0348 -0.0602 0.9947
1.E-06
-0.0600 -0.0893 -0.0871 -0.1163 0.9587
3.E-06
-0.1160 -0.1409 -0.1372 -0.1536 0.8705
5.E-06
-0.1534 -0.1569 -0.1560 -0.1461 0.7329
6.E-06
-0.1472 -0.1247 -0.1328 -0.0972 0.5786
4.E-05

Fourth-order Adams
Predictor-Corrector Method
The solution of Eq. (6.1) by this method is:

h
y i +1 = yi + ( 55 f i 59 f i 1 + 37 f i 2 9 f i 3 )
24
h
C
y i +1 = yi +
9 f P i +1 + 19 f i 5 f i 1 + f i 2
24
P

Where superscript P and C are stands for predictor and


corrector 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.

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.

Solution
Obtain y1, y2 and y3 from RK4:

x
y ' = f ( x, y ) = , h = 0.2
y
1
yi +1 = yi + ( k1 + 2k 2 + 2k3 + k 4 )
6

where:

xi
xi + 0.1
k1 = 0.2 ; k 2 = 0.2
k1
yi
yi +
2
xi + 0.1
xi + 0.2
k3 = 0.2
; k 4 = 0.2
k2
yi + k 3
yi +
2

Solution
i

xi

yi

0
1
2
3

0
0.2
0.4
0.6

k1
1.0000
1.0198
1.0770
1.1662

k2
0.0000
0.0392
0.0743
0.1029

k3
0.0200
0.0577
0.0898
0.1150

k4
0.0198
0.0572
0.0891
0.1144

Exact y error
0.0392 1.0000 0.E+00
0.0743 1.0198
6.E-07
0.1029 1.0770
2.E-06
0.1249 1.1662
3.E-06

Obtain y4 and y5 using Fourth-order Adams PredictorCorrector Method


x0
x2
x1
0.2 x3
P
55 59
y 4 = y3 +
+ 37 9
24 y 3
y2
y1
y0
y

x3
x 2 x1
0.2 x 4
9 P + 19 5 +
= y3 +
24 y 4
y3
y 2 y1

Solution
y

yC5

x3
x2
x1
0 .2 x 4

= y4 +
55 59 + 37
9

24 y 4
y3
y2
y1
x3 x 2
x4
0 .2 x 5
9 P + 19
= y4 +
5 +
24 y 5
y4
y3 y 2

xi
0
1
2
3
4
5

yp
0
0.2
0.4
0.6
0.8
1

yi=yc
Exact y error
1.0000
1.0000 0.E+00
1.0198
1.0198
4.E-06
1.0770
1.0770
3.E-05
1.1662
1.1662
1.E-05
1.2799
1.2807
1.2806
8.E-05
1.4139
1.4143
1.4142
1.E-04

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
2
1

y' =

Solution
Obtain y1, y2 and y3 from RK4.

yP4 =
yC 4 =
y P5 =
yC5 =

Obtain y4 and y5 using Fourth-order Adams PredictorCorrector Method


0.2
y3 +
55 x 32 (1 3 y 3 ) 59 x 22 (1 3 y 2 ) + 37 x 12 (1 3 y1 ) 9 x0 (1 3 y 0 )
24
0.2
y3 +
9 x 42 (1 3 y P 4 ) + 19 x 32 (1 3 y 3 ) 5 x 22 (1 3 y 2 ) + x 12 (1 3 y1 )
24
0.2
y4 +
55 x 24 (1 3 y 4 ) 59 x 32 (1 3 y 3 ) + 37 x 22 (1 3 y 2 ) 9 x1 (1 3 y1 )
24
0.2
y4 +
9 x52 (1 3 y P 5 ) + 19 x 24 (1 3 y 4 ) 5 x 32 (1 3 y 3 ) + x 22 (1 3 y 2 )
24

Solution
i

xi
0
1
2
3
4
5

yp
0
0.2
0.4
0.6
0.8
1

yi=yc
Exact y error
1.0000 1.0000 0.E+00
0.9947 0.9947
1.E-05
0.9587 0.9587
3.E-05
0.8705 0.8705
1.E-05
0.7277 0.7337 0.7329
8.E-04
0.5800 0.5782 0.5786
4.E-04

System of First-Order
Differential Equations
Consider the initial-value problem of first-order differential
equations
dx
= f ( t , x, y )
dt
dy
= g ( t , x, y )
dt
with x( t0 ) = x0 , y ( t0 ) = y0
The solution of both ODEs using RK4 method will
be given by:
1

xi +1 = xi +

( f1 + 2 f 2 + 2 f 3 + f 4 )

6
1
yi +1 = yi + ( g1 + 2 g 2 + 2 g 3 + g 4 )
6

System of First-Order
Differential Equations

where:

fi
h
g1

f1 = hf ( ti , xi , yi ) ; f 2 = hf ti + , xi + , yi +
2
2
2

h
f2
g2

f 3 = hf ti + , xi + , yi + ; f 4 = hf ( ti + h, xi + f 3 , yi + g 3 )
2
2
2

fi
h
g1

g1 = hg ( ti , xi , yi ) ; g 2 = hg ti + , xi + , yi +
2
2
2

h
f2
g2

g 3 = hg ti + , xi + , yi + ; g 4 = hg ( ti + h, xi + f 3 , yi + g 3 )
2
2
2

7 - 25

Example 5
A simple RL-electrical circuit consists of electrical current i (in
ampheres), resistance R (in ohms), inductance L (in hengrys), and
electromotive force E(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/dt and di/dt = d2q/dt2. According to
Kirchoffs second law, the current I satisfies the differential equation

d 2x
dq
L 2 +R
= E(t )
dt
dt
Given that R = 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 +8t and i = 8(1-e-5t),
find the absolute errors for i and q.

Given

becomes

Solution
dq
di d 2 q
d 2q
dq
i=
and
= 2 hence L 2 + R
= E(t )
dt
dt dt
dt
dt

di
L + Ri = E ( t )
dt
The second order differential becomes system of first ODE below:
dq
= i = f ( t , q, i )
dt
di E (t ) Ri
120 15i
=
= g ( t , q, i ) =
= 40 5i
dt
L
3

Solution
Using RK4 method,
1
1
qk +1 = qk + ( f1 + 2 f 2 + 2 f 3 + f 4 ) ; ik +1 = ik + ( g1 + 2 g 2 + 2 g 3 + g 4 )
6
6
where:

g1
g2
f1 = 0.25i; f 2 = 0.25 i + ; f 3 = 0.25 i + ; f 4 = 0.25( i + g 3 )
2
2

g1
g1 = 0.25( 40 5i ) ; g 2 = 0.25 40 5 i +
2

g2
g 3 = 0.25 40 5 i + ; g 4 = 0.25( 40 5( i + g 3 ) )
2

t
0
1
2
3
4
5
6
7
8

g3

q
0
0.25
0.5
0.75
1
1.25
1.5
1.75
2

f4
7.6563
2.3539
0.7237
0.2225
0.0684
0.0210
0.0065
0.0020
0.0006

Solution
i
0.0000
0.8919
2.5512
4.4465
6.4143
8.4044
10.4014
12.4004
14.4001

g4
1.9141
1.9736
1.9919
1.9975
1.9992
1.9998
1.9999
2.0000
2.0000

f1

0.0000
5.5404
7.2438
7.7675
7.9285
7.9780
7.9932
7.9979
7.9994

g1
f2
0.0000 10.0000
1.3851 3.0745
1.8109 0.9453
1.9419 0.2906
1.9821 0.0894
1.9945 0.0275
1.9983 0.0084
1.9995 0.0026
1.9998 0.0008

g2
1.2500
1.7694
1.9291
1.9782
1.9933
1.9979
1.9994
1.9998
1.9999

exact q exact i
error q error i
0.4297 0.0000 0.0000 0.0000
0.0000
0.1321 0.8584 5.7080 0.0335
0.1676
0.0406 2.5313 7.3433 0.0199
0.0995
0.0125 4.4376 7.8119 0.0089
0.0444
0.0038 6.4108 7.9461 0.0035
0.0176
0.0012 8.4031 7.9846 0.0013
0.0065
0.0004 10.4009 7.9956 0.0005
0.0023
0.0001 12.4003 7.9987 0.0002
0.0008
0.0000 14.4001 7.9996 0.0001
0.0003

f3
3.7500
1.1530
0.3545
0.1090
0.0335
0.0103
0.0032
0.0010
0.0003

0.4688
1.5292
1.8553
1.9555
1.9863
1.9958
1.9987
1.9996
1.9999

Boundary-Value Problem
(BVP) of Second-Order
Differential Equation
Consider a linear second-order differential equation

a ( x) y" ( x) + b( x) y ' ( x) + c( x) y ( x) = d ( x) Eq.(6.2)


With the boundary conditions (BCs)

y ( x0 ) = y0 ; y ( xn ) = yn
Can be solved by:
a)Shooting method
b)Finite-Difference Method (FDM)

Shooting Method
Let

y ' ( x) = z then y" ( xn ) = z ' ( x)

Here Eq. (6.2) can be transformed into a system of IVP


as below:

y ' ( x) = z ; y ( x0 ) = y0

a ( x) z ' ( x) + b( x) z + c( x) y = d ( x) ; z ( x0 ) = ?
y n y0
Since z = y ' =
, so we can use it as our initial
xn x0
guess of z(x0). Then, the system of IVP can be solved using
RK4 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.

Example 6
A simple RL-electrical circuit consists of electrical current i (in
ampheres), resistance R (in ohms), inductance L (in hengrys), and
electromotive force E(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/dt and di/dt = d2q/dt2. According to
Kirchoffs second law, the current I satisfies the differential equation

d 2x
dq
L 2 +R
= E(t )
dt
dt
Given that R = 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.

Solution
STEP 1
Since the second initial condition i is unknown at t = 0, we can
dq 14.4 0
=
= 7 .2
guess this equal to i (0) =
dt
20
Solving by RK4 as in Example 5 gives the results in following
table.

7 - 33

t
0
1
2
3
4
5
6
7
8

g3

q
0
0.25
0.5
0.75
1
1.25
1.5
1.75
2

f4
0.7656
0.2354
0.0724
0.0223
0.0068
0.0021
0.0006
0.0002
0.0001

Solution

i
0.0000
1.8892
3.8551
5.8447
7.8414
9.8404
11.8401
13.8400
15.8400

g4
1.9914
1.9974
1.9992
1.9998
1.9999
2.0000
2.0000
2.0000
2.0000

0.0430
0.0132
0.0041
0.0012
0.0004
0.0001
0.0000
0.0000
0.0000

f1

7.2000
7.7540
7.9244
7.9767
7.9929
7.9978
7.9993
7.9998
7.9999

g1

1.8000
1.9385
1.9811
1.9942
1.9982
1.9995
1.9998
1.9999
2.0000

f2

1.0000
0.3075
0.0945
0.0291
0.0089
0.0027
0.0008
0.0003
0.0001

g2
1.9250
1.9769
1.9929
1.9978
1.9993
1.9998
1.9999
2.0000
2.0000

f3
0.3750
0.1153
0.0354
0.0109
0.0034
0.0010
0.0003
0.0001
0.0000

1.8469
1.9529
1.9855
1.9955
1.9986
1.9996
1.9999
2.0000
2.0000

Solution
STEP 2
Since q(2) = 15.84 is higher than the value of BC given, so we
have to reduce our initial guess of i(0). Let try i(0) = 1 and resolve
again using RK4.

7 - 35

t
0
1
2
3
4
5
6
7
8

g3

q
0
0.25
0.5
0.75
1
1.25
1.5
1.75
2

f4
6.6992
2.0597
0.6333
0.1947
0.0599
0.0184
0.0057
0.0017
0.0005

Solution

i
0.0000
1.0304
2.7323
4.6407
6.6125
8.6038
10.6012
12.6004
14.6001

g4
1.9248
1.9769
1.9929
1.9978
1.9993
1.9998
1.9999
2.0000
2.0000

0.3760
0.1156
0.0355
0.0109
0.0034
0.0010
0.0003
0.0001
0.0000

f1

1.0000
5.8478
7.3383
7.7966
7.9375
7.9808
7.9941
7.9982
7.9994

g1

0.2500
1.4620
1.8346
1.9491
1.9844
1.9952
1.9985
1.9995
1.9999

f2

8.7500
2.6902
0.8271
0.2543
0.0782
0.0240
0.0074
0.0023
0.0007

g2
1.3438
1.7982
1.9380
1.9809
1.9941
1.9982
1.9994
1.9998
1.9999

f3
3.2813
1.0088
0.3102
0.0954
0.0293
0.0090
0.0028
0.0009
0.0003

0.6602
1.5881
1.8733
1.9611
1.9880
1.9963
1.9989
1.9997
1.9999

Solution
STEP 3
Again this time, q(2) = 14.6 is still higher than the value of BC
given. If we try to reduce the initial guess of i(0) slowly, we will
achieve at one stage that the result of q(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 obtained
in step 1 and step 2 ( or after two trials).
j
q(2)
i(0)

f (q) =

0
15.84
7.2

1
14.6
1?

2
14.4

q q0
q q1
i0 +
i1
q0 q1
q1 q0

14.4 14.6
14.4 15.84
f (14.4) =
(7.2) +
(1)
15.84 14.6
14.6 15.84
= 0.0006

Solution
STEP 4
So in the third trial we use the initial guess of i(0) = -0.0006 and
resolve again using RK4. This time we will see the BCs is
fulfilled.

t
0
1
2
3
4
5
6
7
8

g3

q
0
0.25
0.5
0.75
1
1.25
1.5
1.75
2

f4
7.6568
2.3541
0.7238
0.2225
0.0684
0.0210
0.0065
0.0020
0.0006

Solution

i
0.0000
0.8918
2.5511
4.4464
6.4142
8.4043
10.4012
12.4003
14.4000

g4
1.9141
1.9736
1.9919
1.9975
1.9992
1.9998
1.9999
2.0000
2.0000

0.4297
0.1321
0.0406
0.0125
0.0038
0.0012
0.0004
0.0001
0.0000

f1

-0.0006
5.5402
7.2437
7.7675
7.9285
7.9780
7.9932
7.9979
7.9994

g1
f2
-0.0002 10.0008
1.3850 3.0748
1.8109 0.9454
1.9419 0.2907
1.9821 0.0894
1.9945 0.0275
1.9983 0.0084
1.9995 0.0026
1.9998 0.0008

g2
1.2499
1.7694
1.9291
1.9782
1.9933
1.9979
1.9994
1.9998
1.9999

f3
3.7503
1.1530
0.3545
0.1090
0.0335
0.0103
0.0032
0.0010
0.0003

0.4686
1.5292
1.8552
1.9555
1.9863
1.9958
1.9987
1.9996
1.9999

Example 7
The radial temperature distribution in a cylinder is governed by

d 2T 1 dT
+
=0
2
dr
r dt
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 outer
surface are maintained at 120C and 60 C respectively with h = 1.

Solution
STEP 1
T(5) =120, T(10) =60
dT
= s = f ( r,T , s)
dr
d 2T ds
s
=
= = g (r , T , s ) ; s (5) = ?
2
dr
dr
r
Since we do not have the information of s(5), we can guess that
dT 60 120
s (5) =
=
= 12
dr
10 5
Solving by RK4.
7 - 41

Solution
Using RK4 method,
1
1
Ti +1 = Ti + ( f1 + 2 f 2 + 2 f 3 + f 4 ) ; si +1 = si + ( g1 + 2 g 2 + 2 g 3 + g 4 )
6
6
where:

g1
g2
f1 = s ; f 2 = s + ; f 3 = s + ; f 4 = s + g 3
2
2
g1
g2
s+
s+
s
s + g1
2
2
g1 = ; g 2 =
; g3 =
; g4 =
h
h
r
r
+
h
r+
r+
2
2

Solution
i

r
0
1
2
3
4
5

g3

T
s
f1
g1
f2
g2
f3
5 120.0000 -12.0000 -12.0000 2.4000 -10.8000 1.9636 -11.0182
6 109.0612 -10.0000 -10.0000 1.6667 -9.1667 1.4103 -9.2949
7 99.8123 -8.5714 -8.5714 1.2245 -7.9592 1.0612 -8.0408
8 91.8005 -7.5000 -7.5000 0.9375 -7.0313 0.8272 -7.0864
9 84.7336 -6.6667 -6.6667 0.7407 -6.2963 0.6628 -6.3353
10 78.4120 -6.0000 -6.0000 0.6000 -5.7000 0.5429 -5.7286

f4
2.0033
1.4300
1.0721
0.8337
0.6669
0.5456

g4
-9.9967
-8.5700
-7.4993
-6.6663
-5.9998
-5.4544

1.6661
1.2243
0.9374
0.7407
0.6000
0.4959

Solution
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 - 44

Solution
i

r
0
1
2
3
4
5

g3

T
s
f1
g1
f2
g2
f3
5 120.0000 -15.0000 -15.0000 3.0000 -13.5000 2.4545 -13.7727
6 106.3264 -12.5000 -12.5000 2.0833 -11.4583 1.7628 -11.6186
7 94.7654 -10.7143 -10.7143 1.5306 -9.9490 1.3265 -10.0510
8 84.7506 -9.3750 -9.3750 1.1719 -8.7891 1.0340 -8.8580
9 75.9170 -8.3333 -8.3333 0.9259 -7.8704 0.8285 -7.9191
10 68.0150 -7.5000 -7.5000 0.7500 -7.1250 0.6786 -7.1607

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

Solution
STEP 3
Again 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
T
s

f (T ) =

0
78.412
-12

1
68.015
-15 ?

2
60

T T0
T T1
s0 +
s1
T0 T1
T1 T0

60 68.015
60 78.412
f (60) =
( 12) +
(15)
78.412 68.015
68.015 78.412
= 17.3127

Solution
STEP 4
So in the third trial we use the initial guess of s(5) = -17.3127 and
resolve again using RK4. This time we will see the BCs is
fulfilled.

Solution
i

r
0
1
2
3
4
5

g3

T
s
f1
g1
f2
g2
f3
5 120.0000 -17.3127 -17.3127 3.4625 -15.5814 2.8330 -15.8962
6 104.2183 -14.4273 -14.4273 2.4045 -13.2250 2.0346 -13.4099
7 90.8747 -12.3662 -12.3662 1.7666 -11.4829 1.5311 -11.6007
8 79.3159 -10.8204 -10.8204 1.3526 -10.1442 1.1934 -10.2237
9 69.1203 -9.6182 -9.6182 1.0687 -9.0838 0.9562 -9.1401
10 59.9999 -8.6564 -8.6564 0.8656 -8.2235 0.7832 -8.2648

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

Example 8
Solve the BVP of exy+xy-5(1 + x)y = x3
with the following BCs
y(0) = 2 , y(2) = 5
At x = 0(0.5)2 using shooting method.

Solution

BVP: Finite-Difference
Method

To solve Eq. (6.2) using FDM, the interval of x is divided into


n subintervals with width = h such that xi =x0 + ih. Then
substitute

yi +1 2 yi + yi 1
yi +1 yi 1
y" ( x) =
and y ' ( x) =
2
h
2h

Into the Eq. (6.2) yields a tridiagonal system of n - 2 equations


to be solved (solve for y from i = 1 to n - 10

Example 9
Solve the BVP of exy+xy-5(1 + x)y = x3
with the following BCs
y(0) = 2 , y(2) = 5
At x = 0(0.5)2 using FDM.

Solution
STEP 1

e x y"+ xy '5(1 + x ) y = x 3 , h = 0.5


yi +1 2 yi + yi 1
yi +1 yi 1
3
(
)
e
+
x

5
1
+
x
y
=
x

i
i
i
i
2
h
2
h

xi

Multiply by h2 = 0.25 at both hand-side yields


e xi ( yi +1 2 yi + yi 1 ) + 0.25 xi ( yi +1 yi 1 ) 1.25(1 + xi ) yi = 0.25 xi3

Rearranged this equation


(e xi 0.25xi ) yi 1 + ( 2e xi 1.25(1 + xi ) ) yi + (e xi + 0.25xi ) yi+1 = 0.25xi3

7 - 53

Solution
STEP 2
Put in the BCs in the table below
l

xi

yi

0.5

y1

1.0

y2

1.5

y3

There are 3 value of y to be solved. Therefore 3


simultaneous equations are required.

Solution
STEP 3
Obtain the equations by inserting value of x based on i
i

(exi
0.25xi)

yi- +
1

(-2exi1.25(1+xi)

yi

(exi
0.25xi)

Yi+1

0.25xi3

1.524

y0

-5.172

y1 +

1.774

y2

0.031

2.468

y1

-7.937

y2 +

2.968

y3

0.250

4.107

y2

-12.088

y3 +

4.857

y4

0.844

Solution

STEP 4
Substituting BCs, y(0)=2=y0; y(2)=5=y4
i

(exi
0.25xi)

yi- +
1

(-2exi1.25(1+xi)

yi

(exi
0.25xi)

yi+1

0.25xi3

1.524

-5.172

y1 +

1.774

y2

0.031

2.468

y1

-7.937

y2 +

2.968

y3

0.250

4.107

y2

-12.088

y3 +

4.857

0.844

(exi
0.25xi)

(exi
0.25xi)

yi+1

0.25xi3

yields

yi- +
1

(-2exi1.25(1+xi)

yi

-5.172

y1 +

1.774

y2

-3.017

y2 +

2.968

y3

0.250

-23.441

2.468

y1 +

-7.937

4.107

y2 +

-12.088

y3

Solution
0 y1 3.017
5.172 1.774
2.468 7.937
y = 0.250
2
.
968

0
4.107 12.088 y 3 23.441

STEP 5
Solve by Gauss-Seidel Iteration method
( k +1)
1

y 2( k +1)
y 3( k +1)

3.107 1.774 y 2( k )
=
5.172
0.250 2.468 y1( k +1) 2.968 y1( k )
=
7.937
23.441 4.107 y 2( k +1)
=
12.088

Solution
k

y1
0
1
2
3
4
5
6

y2
0.000
0.583
0.635
0.895
0.956
0.971
0.974

y3
0.000
0.150
0.910
1.088
1.129
1.139
1.141

0.000
1.990
2.248
2.309
2.323
2.326
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.

Exercise

7 - 59

Solution
STEP 3
Obtain the equations by inserting value of x based on i
i

yi- +

yi

Yi+1

0.976

y0

-1.7681

y1 +

0.888

y2

0.9924

1.0814

y1

-1.8589

y2 +

0.8894

y3

0.0135

1.1556

y2

-1.8711

y3 +

0.8436

y4

0.0112

1.1978

y3

-1.8037

y4

-1.4902

Solution
STEP 3
Obtain the equations by inserting value of x based on i
i

yi- +

yi

Yi+1

y0

-1.7681

y1 +

0.888

y2

0.9924

1.0814

y1

-1.8589

y2 +

0.8894

y3

0.0135

1.1556

y2

-1.8711

y3 +

0.8436

y4

0.0112

1.1978

y3

-1.8037

y4

-1.4902

Das könnte Ihnen auch gefallen