Professional Documents
Culture Documents
Lecture Notes Chapter 7
Lecture Notes Chapter 7
Norhayati Rosli
Faculty of Industrial Sciences & Technology
norhayati@ump.edu.my
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
Description
AIMS
This chapter is aimed to solve boundary value problems of second order ODEs by using two
different types of methods involving shooting method and finite difference method.
EXPECTED OUTCOMES
Students should be able to solve boundary value problems using shooting method and finite
difference method.
REFERENCES
1. Norhayati Rosli, Nadirah Mohd Nasir, Mohd Zuki Salleh, Rozieana Khairuddin,
Nurfatihah Mohamad Hanafi, Noraziah Adzhar. Numerical Methods, Second Edition,
UMP, 2017 (Internal use)
2. Chapra, C. S. & Canale, R. P. Numerical Methods for Engineers, Sixth Edition, McGraw–
Hill, 2010.
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
Content
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
INTRODUCTION
In initial value problem, the condition is specified at the same value of the
independent variable.
However, for boundary value problem (BVP), the conditions are specified at
different values of the independent variables.
In a nutshell, a BVP is a problem, typically ODE which has values assigned
on the physical boundary of the domain.
2
d y
2
f ( x, y, y '), x [a, b]
dx
y (a) , y (b)
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
INTRODUCTION (Cont.)
Most of ODEs (BVP) cannot be solved analytically.
Its due to the complexity form of the equations.
Numerical methods offer a viable option to solve ODEs (BVP).
Two Types
of Methods
2 1
Finite Difference Method Shooting Method
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
SHOOTING METHOD
Introduction
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
SHOOTING METHOD (Cont.)
Shooting Method Procedures
Reduce the second order ODE (BVP) of equation to
Step 1 a system of first order ODE (IVP). The second order
ODE is transformed into a system of two first order
ODEs as
dy
f1 ( x, y, z ) z , y ( x0 ) y0 or y (a )
dx
dz d 2 y
f 2 ( x, y , z ) 2 , z ( x0 ) z0
dx dx
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
SHOOTING METHOD (Cont.)
Shooting Method Procedures (Cont.)
The equivalent system of initial value problem is then solved via Euler’s method.
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
SHOOTING METHOD (Cont.)
Example 1
Use the Shooting method to approximate the solution of the boundary value problem
y ''( x) 2 y ( x) 0, y (0) 1.2, y (1.0) 0.9, h 0.25
Let the first guess, 𝑧0 = −1.5 and the second guess, 𝑧0 = −1.0
Solution
Step 1 Reduce the second order ODE (BVP) to a system of first order ODE (IVP).
dy
f1 ( x, y, z ) z
dx
dz
f 2 ( x, y , z ) 2y
dx
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
SHOOTING METHOD (Cont.)
Solution (Cont.)
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
SHOOTING METHOD (Cont.)
Solution (Cont.)
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
SHOOTING METHOD (Cont.)
Solution (Cont.)
1.0 (1.5)
z (0) 1.5 (0.9 0.4312)
0.9938 0.4312
1.0834
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
SHOOTING METHOD (Cont.)
Solution (Cont.)
Step 5 The equivalent system of initial value problem is then solved via
Euler’s method
Since, 𝑦4 = 𝑦(1.0) = 0.9 (same with boundary condition), the solutions that
were obtained in Step 5 is acceptable.
y ''( x) p ( x) y '( x) q ( x) y ( x) r ( x)
y (a) , y (b)
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
FINITE DIFFERENCE METHOD
(Cont.)
Boundary values 𝑦0 and 𝑦𝑛 are known.
The approximate values of 𝑦𝑖 for 𝑖 = 1,2, … , 𝑛 − 1 is computed.
In finite difference method, a general form of second order ODE at the
interior mesh points 𝑥 = 𝑥𝑖 for 𝑖 = 1,2, … , 𝑛 − 1.
y ''( xi ) p( xi ) y '( xi ) q( xi ) y ( xi ) r ( xi )
General Form Second
Order ODEs or
y ''i pi y 'i qi yi ri .
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
FINITE DIFFERENCE METHOD
(Cont.)
Finite Difference Method: Formula
d 2 y yi 1 2 yi yi 1
dx 2
x 2
dy yi 1 yi 1
dx 2x
Substituting the first and second derivatives in general form of second
order ODEs (BVP)
yi 1 2 yi yi 1 yi 1 yi 1
pi qi yi ri .
x 2
2x
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
FINITE DIFFERENCE METHOD
(Cont.)
Finite Difference Method: Formula (Cont.)
x
yi 1 2 yi yi 1 pi yi 1 yi 1 x 2 qi yi x 2 ri
2
Finite or rearrange
Difference
x x
Formula
1
2
p i i 1
y 2 x 2
qi yi
1 pi i 1
2
y x 2
ri
for i 1, 2,3,..., n 1.
Applying finite difference formula for each interior nodes leads to a set of
simultaneous algebraic equations.
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
FINITE DIFFERENCE METHOD
(Cont.)
Finite Difference Method: Tridiagonal System
d1 e1 0 0 y1 b1
c d2 e2 0 y2 b2
2
0 0 cn 1 d n 1 yn 1 bn 1
where 𝑑𝑖 , 𝑒𝑖 and 𝑐𝑖 for 𝑖 = 1,2, … , 𝑛 − 1 are the coefficients of 𝑦1 , … , 𝑦𝑛−1 .
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
FINITE DIFFERENCE METHOD
(Cont.)
Finite Difference Method: Thomas Algorithm
𝑥 −𝑥
Compute the step size, ∆𝑥 = 𝑛𝑛 0 by performing the
Step 3 discretization process. Substitute 𝑝, 𝑞 and 𝑟 and ∆𝑥 into
equation.
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
FINITE DIFFERENCE METHOD
(Cont.)
Finite Difference Method Procedures
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
FINITE DIFFERENCE METHOD
(Cont.)
Example 2
Use the Finite Difference method to approximate the solution of the boundary value
problem
𝑦′′ − 2𝑦 = 0
Step 2 pi 0, qi 2, ri 0
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
FINITE DIFFERENCE METHOD
(Cont.)
Solution (Cont.)
0.25 0.25
i 1
1 (0) yi 1 0.252 (0)
2
1 (0) y 2 0.25 ( 2) yi
2 2
The finite difference formula is
yi 1 2.125 yi yi 1 0, i 1, 2,3
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
FINITE DIFFERENCE METHOD
(Cont.)
Solution (Cont.)
Discretization process
Step 4
1 0
n 4
0.25
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
FINITE DIFFERENCE METHOD
(Cont.)
Solution (Cont.)
y0 2.125 y1 y2 0
y2 2.125 y3 y4 0
2.125 y1 y2 1.2
y2 2.125 y4 0.9
For 𝑖 = 2, 𝑥2 = 0.5
y1 2.125 y2 y3 0
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
FINITE DIFFERENCE METHOD
(Cont.)
Solution (Cont.)
2.125 1 0 y1 b1
1 2.125 1 y b
2 2
0 1 2.125 y3 b3
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
FINITE DIFFERENCE METHOD
(Cont.)
Solution (Cont.)
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449
Author Information
Numerical Methods
by Norhayati Rosli
http://ocw.ump.edu.my/course/view.php?id=449