You are on page 1of 31

NUMERICAL METHODS WITH

APPLICATIONS
(MEC500)

Dr. Siti Mariam binti Abdul Rahman


Faculty of Mechanical Engineering
Office: T1-A14-12C
e-mail: mariam4528@salam.uitm.edu.my
Outcomes of Chapter 6
 To solve ordinary differential equation using numerical
technique
 To assess the reliability of the answer obtained
 To choose the ‘best’ method for any particular problem
Learning outcome
 Understanding the difference between initial value problem
and boundary value problem
 Knowing how to implement the following methods with
boundary value problem:
◦ The shooting method
◦ Finite-difference method
◦ Polynomial method
◦ Power method
◦ Knowing how to iterate using Power Method
Auxiliary conditions
 nth order differential equation
dn y
n = f(x, y, y ′ , y ′′ ,..., y n −1
)
dx
 nth order differential equation requires n conditions.
 If all conditions are specified at the same value of the
independent
€ variable, then we have an initial-value problem
(IVP).

y(x 0 ) = y 0
y ′ (x 0 ) = y ′0
M
y n −1(x 0 ) = y n0 −1
Auxiliary conditions
 If the conditions are specified at different values of the
independent variable, usually at extreme points or boundaries
of a system, then we have a boundary-value problem (BVP).

y(x 0 ) = α
y(xn ) = β


 The BVP arises in many fields in engineering. For example in
the study of heat transfer.
General Method
 A non-insulated uniform rod positioned between two bodies of
constant but different temperature. For this case T1 > T2 and T2 >
Ta

 The resulting equation is:


d2T
2 + h ′ (T a − T ) = 0
dx
 Where h’ is the heat transfer coefficient (m -2) and Ta is the
temperature of the surrounding air.

General Method
 To obtain a solution there must be appropriate boundary
conditions
d2T
2 + h ′ (T a − T ) = 0
dx

Ta = 20 T (0) = T1 = 40 Boundary
L = 10 m T (L) = T2 = 200 conditions

h ′ = 0.01 m −2 (Heat transfer coefficient)

 Analytical solution:


T = 73.4523e0.1x − 53.4523e−0.1x + 20
The Shooting Method
 This method is a trial-and-error which solves an equivalent
IVP after converting the original BVP.

BVP IVP Then solve with trial and error

 Example:
d2T For example, the 2nd order
2 + h ′ (T a − T ) = 0 equation can be expressed
dx
as two first order ODEs:
Ta = 20 dT
=z
L = 10 m dx

h ′ = 0.01 m −2 dz
= h ′(T − Ta )
dx
T (0) = T1 = 40
T (L) = T2 = 200


The Shooting Method
 An initial value is guessed, say z(0)=10.

 The solution is then obtained by integrating the two 1st order


ODEs simultaneously.
dT
=z
dx
dz
= h ′(T − Ta )
dx
 Using a 4th order RK method with a step size of 2 we obtain
the value at the end of the interval T(10) = 168.3797.

z(0) = 10 → T(10) = 168.3797
The Shooting Method
 This differs from T(10) = 200. Therefore a new guess is
made, z(0) = 20 and the computation is performed again.

z(0) = 20 → T(10) = 285.8980

 Since the two sets of points, (z, T)1 and (z, T)2, are linearly
related, a linear interpolation formula is used to compute the
value of z(0) as 12.6907 to determine the correct solution.

20 − 10
z(0) = 10 + (200 − 168.3797)
285.8980 − 168.3797
z(0) = 12.6907


The Shooting Method

a) First shoot
b) Second shoot
c) Exact hit
The Shooting Method
 Remark:

◦ The shooting method can be very time-consuming if each


solution of the associated IVP uses a small step size h.
Consequently, a reasonably large step size is used initially
until the error is small and then reduce h to acquire the
desired accuracy.
◦ For nonlinear differential equation, the higher-order
interpolation (quadratic or cubic) may be employed for the
new guess. However, the shooting method for such
problems is usually not used in most cases.
The Shooting Method
Nonlinear Two-Point Problem
 Suppose for a non-linear ODE simulating the temperature of
the bar.
d2T 4
2 + h ′ (T a − T ) =0
dx
 where h ′ = 5x10 −8 m −2 . Two first order ODEs:

dT
€ =z
dx
€ dz
= h ′(T − Ta ) 4
dx
 Now, these equations can be integrated using any of the
methods described before.

The Shooting Method
Nonlinear Two-Point Problem
 We used the constant step-size version of the fourth-order
RK approach.
 The function integrated the equations based on an initial
guess for z(0) and returned the temperature at x = 10.
 The difference between this value and the goal of 200 was
used to adjust the value of z(0) until the difference was driven
to zero.
Finite-Difference Method
 The most common alternatives to the shooting method.
 Finite differences are substituted for the derivatives in the
original equation.

d2T Ta = 20
2 + h ′ (T a − T ) = 0
dx L = 10 m
d 2T Ti +1 − 2T + Ti −1 h ′ = 0.01 m −2
2 =
dx Δx 2
Ti +1 − 2T + Ti −1
2 − h ′ (Ti − T a ) = 0 T (0) = 40
Δx
T (L) = 200
−Ti +1 + (2 + h ′ Δx 2 )Ti − Ti −1 = h ′ Δx 2T a



Finite-Difference Method

 Finite differences equation applies for each of the interior nodes.


The first and last interior nodes, Ti-1 and Ti+1, respectively, are
specified by the boundary conditions.
 Thus, a linear equation transformed into a set of simultaneous
algebraic equations can be solved efficiently
 Using the same example with Δx = 2m results in the following
equation.
⎡2.04 −1 0 0 ⎤⎧T1 ⎫ ⎧40.8 ⎫
⎢ −1 2.04 −1 0 ⎥⎪ T2 ⎪ ⎪ 0.8 ⎪
⎢ ⎥⎨ ⎬= ⎪
⎪ ⎪



⎢ 0 −1 2.04 −1 T
⎥⎪ 3 ⎪ ⎪ 0.8 ⎪
⎢ 0 ⎥
−1 2.04 ⎦⎪
⎣ 0 ⎩T 4 ⎪
⎭ ⎪
⎩200.8⎪

T
{T } = [65.9698 93.7785 124.5382 159.4795]
Eigenvalue Problems
 Special class of boundary-value problems that are common in
engineering involving vibrations, elasticity, and other oscillating
systems.
 Solving sets of linear algebraic equations of the general form:
[A ]{x} = {B}
 Systems are called nonhomogeneous because of the presence
of the vector B.
 A homogeneous€ linear algebraic system has the general form:
[A ]{x}= {0}
 A solution {X} for such a system is referred to as a eigenvector.
The above set of equations may also be expressed concisely as
€ [[A ]−λ [I]]{x}= {0}
Eigenvalue Problems
 Eigenvalue problems are of the general form:
(a11 − λ )x1 + a12 x 2 + L + a1n xn = 0
a21x1 + (a22 − λ )x 2 + L + a2n xn = 0
M M M M
an1x1 + an 2 x 2 + L + (ann − λ )xn = 0

[[A ]−λ [I]]{x}= {0}

€ λ is the unknown parameter called the eigenvalue or


characteristic value.
 The eigenvalue
€ describes the dynamic behaviours of many
engineering systems including mechanical, electrical, etc. In
other words, it determines how the system performs.
Example 1
Eigenvalue Problems
Determine the eigenvalues and the corresponding eigenvectors
of the following matrix:
⎡4 2 ⎤
A =⎢ ⎥
⎣−5 −3 ⎦
Solution:
(4 − λ ) 2
det(A − λ I) =
€ −5 (−3 − λ )
The characteristic equation is then:
p(λ ) = (4 − λ )(−3 − λ ) + 10 = 0
€ λ2 − λ − 2 = 0
Which yield λ1 = 2 and λ2 = -1.


Example 1
Eigenvalue Problems
To get the corresponding eigenvectors for each of the λs, we
have to solve (A-λI)x = 0. For λ1 = 2,
(A − λ I) = 0
⎛(4 − 2) 2 ⎞⎧x1 ⎫ ⎡0 ⎤
⎜ ⎟⎨ ⎬= ⎢ ⎥
⎝ −5 (−3 − 2)⎠⎩x 2 ⎭ ⎣0 ⎦

⎡1 ⎤
From which we obtain x2 = -x1, if we let x1 = α ⎢ ⎥ = α (1,−1)T
⎣−1⎦

So x1 has an infinite number of solutions or we say that a unique
solution, other than the trivial solution x1 = 0, does not exist.
Similar result is obtained for λ2 =€-1.
Polynomial Method
 When dealing with complicated systems or systems with
heterogeneous properties, analytical solutions are often
difficult or impossible to obtain.
 Numerical solutions to such equations may be the only
practical alternatives.
 These equations can be solved by substituting a central
finite-divided difference approximation for the derivatives.
d2 y 2
2 + p y =0
dx
y i +1 − 2y 1 + y i −1 2
+ p yi = 0
h2
y i −1 − (2 − h 2 p 2 )y i + y i +1 = 0
Polynomial Method
 Writing this equation for a series of nodes yields a
homogeneous system of equations.
 For example, if the column is divided into five segments (that
is, four interior nodes), the result is:

⎡(2 − h 2 p 2 ) −1 0 0 ⎤⎧y1 ⎫
⎢ 2 2 ⎥⎪y ⎪
⎢ −1 (2 − h p ) −1 0 ⎥⎪ 2⎪
2 2 ⎨ ⎬= 0
⎢ 0 −1 (2 − h p ) −1 ⎥⎪y 3 ⎪
⎢ 2 2 ⎥
⎣ 0 0 −1 (2 − h p ) ⎦⎪
⎩y 4 ⎪

 Expansion of the determinant of the system yields a


polynomial, the roots of which are the eigenvalues.
€  Refer to textbook pg 792-794
Example 2
Polynomial Method
Employ the polynomial method to determine the eigenvalues for
yi−1 − (2 − h 2 p 2 )y i + y i +1 = 0

using (a) one, (b) two and (c) three interior nodes.


Solution:
(a) Writing for one interior node yields (h = 3/2)

−(2 − 2.25p 2 )y i = 0
Thus, for this simple case, the eigenvalue is analyzed by setting
the determinant equal to zero
€ −2 − 2.25p 2 = 0
and solving for p = ± 0.9428.


Example 2
Polynomial Method
b) Writing for two interior node yields (h = 3/3)
⎡(2 − p 2 ) −1 ⎤⎧y1 ⎫
⎢ 2 ⎥⎨ ⎬
=0
⎣ −1 (2 − p ) ⎦⎩y 2 ⎭
Expansion of the determinant gives
(2 − p 2 ) 2 − 1 = 0
€ be solved for p=±1 and ±1.73205.
which can

c) Writing for three interior node yields (h = 3/4)



⎡2 − 0.5625p 2 −1 0 ⎤⎧y 1 ⎫
⎢ ⎥⎪ ⎪
⎢ −1 2 − 0.5625p 2 −1 ⎥⎨y 2 ⎬= 0
⎢⎣ 0 −1 2 − 0.5625p 2 ⎥⎦⎪y
⎩ ⎭3

which can be solved for p=±1.0205, ±1.8856 and ±2.4637.


Power Method
 The power method is an iterative approach that can be
employed to determine the largest eigenvalue. It must be
expressed in the form:
[A ]{X } = λ {X }
 With slight modification, it can also be employed to
determine the smallest and the intermediate values.
 It has the additional
€ benefit that the corresponding
eigenvector is obtained as a by-product of the method.
Power Method
 Steps:
1. Assume a trial value x(0) for the eigenvector x. Select one
component of x be unity and call it a unity component.

2. Compute y(1) where y(1) =Ax(0)

3. Obtain x(1) by factoring (or scaling) y(1) so that the unity


component remains unity. Then the largest eigenvalue is
given by y(1) = λ(1) x(1) and x=x(1)

4. Repeat step 2.

5. General form y(k + 1) = Ax (k ) = λ (k +1)x (k +1)


Example 3
Power Method – Numerical Example
⎡3 7 9 ⎤⎧x1 ⎫ ⎡x1 ⎤
⎢9 4 3⎥⎪x ⎪= λ ⎢x ⎥
⎢ ⎥⎨ 2 ⎬ ⎢ 2 ⎥
⎢ ⎪ ⎪
⎣9 3 8 ⎥
⎦⎩x 3 ⎭ ⎢
⎣x 3 ⎥

T
Find the maximum eigenvector. Initial guess: {y} = {1 1 1}

€ ⎡3 7 9⎤⎧1⎫ ⎡19 ⎤ ⎧0.95⎫


⎢ ⎥⎪ ⎪ ⎢ ⎥ ⎪ ⎪
[A ]{y} = ⎢9 4 3⎥⎨1⎬= ⎢16 ⎥ ⇒ 20€ ⎨0.80⎬
⎢9 3 8 ⎥⎪1⎪ ⎢20 ⎥ ⎪1.00 ⎪
⎣ ⎦⎩ ⎭ ⎣ ⎦ ⎩ ⎭
Approx. Eigen-
Eigen- vector
value

Example 3
Power Method – Numerical Example
2nd iteration
⎡3 7 9⎤⎧0.95⎫ ⎡17.45 ⎤ ⎧0.92084 ⎫
2 ⎢ ⎥⎪ ⎪ ⎢ ⎥ ⎪ ⎪
[A ] {y } = ⎢9 4 3⎥⎨0.80⎬= ⎢14.75 ⎥ ⇒ 18.95 ⎨0.77836 ⎬
⎢ ⎪ ⎪ 18.95 ⎥ ⎪ 1.00 ⎪
⎣9 3 8⎥
⎦⎩1.00 ⎭ ⎢
⎣ ⎦ ⎩ ⎭
Approximate error, εa:
(ei , j − ei −1, j ) 0.92084 − 0.95
€ max *100 = *100% = 3.2%
j ei , j 0.92084

3rd iteration
⎡3 7 9⎤⎧0.92084 ⎫ ⎧0.92420⎫
€ 3 ⎢ ⎥⎪ ⎪ ⎪ ⎪ ε a = 0.36%
[A ] {y } = ⎢9 4 3⎥⎨0.77836⎬= 18.623⎨0.77331⎬
⎢ ⎪ ⎪ ⎪ 1.00 ⎪
⎣9 3 8⎥ ⎦⎩ 1.00 ⎭ ⎩ ⎭
[A ] {x} λ {x}
Reading material
 http://mathforcollege.com/nm/topics/textbo
ok_index.html
Chapter 6

One-step methods/ Adaptive step-size Boundary & Eigen


Initial-value problems control Value problems

Adaptive Runge-Kutta
Euler’s Method Multistep Method Shooting Method
Method

Finite Difference
Heun’s Method
Method

Mid-point Power Method

Runge-Kutta
Polynomial Method
Method
Next Lecture
Example on ODE Application
Roots of Equations

You might also like