You are on page 1of 31

NUMERICAL METHODS WITH

APPLICATIONS
(MEC500)

Dr. Siti Mariam binti Abdul Rahman


Faculty of Mechanical Engineering
Office: T1-A14-01C
e-mail: mariam4528@salam.uitm.edu.my
Syllabus Content

Week Topics Contact hours


Week 1 – 2 Chapter 1: Introduction 4 hours
• Introduction to Mathematical Modeling and
Computing Environment
• Approximation and Round Off
• Truncation Errors and Taylor Series
Week 3 - 4 Chapter 2: Roots of Equations 4 hours
• Bracketing Methods
• Open Methods
• Roots of Polynomials
• Engineering Applications
WEEK 5 Intermediate Exam 1 2 hours
Week 5 – 6 Chapter 3: Linear Algebraic Equations 4 hours
• Gauss Elimination, Matrix Inversion, and Gauss-Seidel
Methods
• LU Decomposition
• Engineering Applications
Week 7 Assignment 1 Deadline
Outcomes of Chapter 2

 To determine the root of equation using graphical method


 To determine the root of equation using bracketing
method:
 Bisection Method
 False Position Method
Learning outcomes

 Understanding what roots problems are and where they occur in


engineering and science.
 Knowing how to determine a root graphically.
 Understanding the incremental search method and its
shortcomings.
 Knowing how to solve a roots problem with the bisection
method.
 Knowing how to estimate the error of bisection and why it
differs from error estimates for other types of root location
algorithms.
 Understanding false position and how it differs from bisection.
Introduction
 Years ago we have learned to use:

b  b 2  4ac
x
2a

 To solve

 f (x)  ax 2  bx  c  0

 But, functions like ax 5  bx 4  cx


or  dx  ex  f  0
3 2
sin x  x  0
analytically.
cannot be solved
 “Roots” problems occur when some function f can be written in terms of one or
 the solution to the
more dependent variables x, where the solutions to f(x)=0 yields

problem.
 These problems often occur when a design problem presents an implicit equation for
a required parameter.
Introduction
ROOTS OF
EQUATIONS

GRAPHICAL BRACKETING
OPEN METHODS
METHODS METHODS

ONE-POINT
BISECTION
ITERATION (FIXED
METHOD
POINT) METHOD

FALSE-POSITION NEWTON-RAPHSON
METHOD METHODD

SECANT METHOD

MODIFIED
NEWTON-RAPHSON
METHOD
(MULTIPLE ROOTS)
Graphical Method
 A simple method for obtaining the rough estimate of the root of the equation
f(x)=0 observe where it crosses the x-axis.
 Graphs can also indicate where roots may be and where some root-finding
methods may fail.
 In general, if xl = lower bound & xu= upper bound
 f(xl) & f(xu) have same sign
 no root or even number of roots
 f(xl) & f(xu) have different sign
 odd number of roots
Graphical Method
 Graphical method only provides rough estimates of the roots
 Useful for initial guess for NM  lack of precision!
 Alternative method–trial & error (guessing repeatedly the value of x and
evaluate whether f(x) = 0)  inefficient!
 Combine these methods + computer  NM
Example 1
Graphical Method

Use the graphical approach to determine the drag coefficient


c needed for a parachutist of mass m = 68.1 kg to have a
velocity of 40 m /s after free-falling for time t = 10 s. Note:
The acceleration due to gravity is 9.8 m /s2.
Substitute the known parameters:

c f(c)
9.8(68.1) 4 34.115
f (c)  (1 e(c / 68.1)10 )  40
c 8 17.653
Various values of c can be substituted 12 6.067
to gather: 16 -2.269

 20 -8.401
Example 1
Graphical Method
These points are plotted.
Visual inspection of the plot provides a rough
estimate of the root of 14.75.
The validity of the graphical estimate can be
checked by substituting it into Eq. before and yield:

9.8(68.1)
f (c)  (1 e(14.75 / 68.1)10 )  40  0.059
14.75
which is close to zero
Bracketing Method
 Bracketing methods are based on making two initial
guesses that “bracket” the root -that is, are on either side of
the root.
 Brackets are formed by finding two guesses xl and xu where
the sign of the function changes, that is:
f (xl )  f (xu )  0

 Then there is at least one real root between xl and xu.



 Initial guesses are determined by incremental search
method.
 The incremental search method tests the value of the
function at evenly spaced intervals and finds brackets by
identifying function sign changes between neighboring
Bracketing Method
 Used to locate all roots by observing function sign changes within
an interval.
 Method: Evaluate function as small increment across the region of
interest. If function change sign –there is a root within the
increment.
 Problems:
 Increment length –too small  time consuming
 Increment length –too big  miss closely paced roots &
multiple roots.
 Incremental search is not foolproof –always find more information
by plotting graph and understand the physical problem from which
the equation originated.
Bracketing Method
 Exceptions to these general rules:
 When the functions are tangential to the x axis
 When the functions are discontinuous.

 Example of function that is tangential to the x axis:

Point of
f (x)  (x  2)(x  2)(x  4) discontinuity

 Notice that x = 2 makes two terms in this polynomial


equal to zero.
  Mathematically, x = 2 is called a multiple root.
Bisection Method
 The bisection method is a bracketing
method in which the interval is always
divided in half.
 If a function changes sign over an
interval, the function value at the
midpoint is evaluated.
 The location of the root is then
determined as lying within the
subinterval where the sign change
occurs.
 The absolute error is reduced by a factor
of 2 for each iteration.
 Also called binary chopping, interval
halving, Bolzano’s method
Bisection Method
 Step 1: Choose lower xl and upper xu guesses for the root such that the
function changessign over the interval. This can be checked by ensuring
that f(xl).f(xu) < 0.
 Step 2: An estimate of the root xr is determined by
xl  xu
xr 
2

 Step 3: Make the following evaluations to determine in which subinterval


the root lies:

a) If f(xl).f(xr) < 0, the root lies in the lower subinterval.
SET xl = xl & xu = xr for the next iteration
b) If f(xl).f(xr) > 0, the root lies in the upper subinterval.
SET xu = xu & xl = xr for the next iteration
c) If f(xl).f(xr) = 0, the root equals xr
Bisection Method
 Repeat STEP 2 & 3 until one of the following is
reached:
 a  s
 f (xl ). f (xu ) (true
0 root)
 Allowable number of iterations.

  True error is unknown
 Approximate percent relative error is

xrnew  xrold
a  new  100%
xr

 Stop iteration when a  


(satisfy s
the pre-specified
stopping criterion)


Bisection Method
 Each succeeding iteration halves the error. Thus, the
relationship between error and number of iteration is

Ea x 0
= absolute error
Ena  n
n =2iteration number
Δx0 = zero iteration error = xu-xl

  Number of iteration, n, to obtain a particular absolute error can


be calculated based on initial guess

x 0 
n  logE2a,d= desired
 error
Ea,d 
n = iteration number
Δx0 = zero iteration error = xu-xl
Example 2
Bisection Method
From example 1, we observed that the root, c is between 12 and 16
(through visual inspection). [Note: True root = 14.7802]
The initial estimate of the root x, lies at the midpoint of the interval:

xl  xu 12  16
xr    14
2 2
14.7802  14
t   100%  5.3%
14.7802
Evaluate f(xl).f(xr)

 Root is in upper subinterval


f (xl ). f (xr )  f (12). f (14)  9.517 0

 Set xl = xr and xu = xu for next iteration


Example 2
Bisection Method
xl  xu 14  16
xr    15
2 2
14.7802  15
t   100%  1.5%
14.7802

Evaluate f(xl).f(xr) Root is in lower subinterval


 f (xl ). f (xr )  f (14). f (15)  0.666 0

 Set xl = xl and xu = xr for next iteration

 This procedure is repeated until the result is accurate enough to satisfy


your need!
 So when to stop? In this example error estimate is based on true value but
in practice this is not possible! a  s
Example 3
Stopping criteria & Error estimate

For the previous example, find the root when εs = 0.5%

Approximate percent relative error is:

xrnew  xrold
a  new  100%
xr

From previous example, from 1st and 2nd iteration:



15  14
a   100%  6.6667%
15

The approximate percent relative error is calculated for all


 iterations…
Example 3
Stopping criteria & Error estimate

The iteration stop after 6 iterations as a


= 0.422%

Iteration xl xu xr εa (%) εt (%)


1 12 16 14 - 5.279

2 14 16 15 6.667 1.487
3 14 15 14.5 3.448 1.896
4 14.5 15 14.75 1.695 0.204
5 14.75 15 14.875 0.840 0.641
6 14.74 14.875 14.8125 0.422 0.219
Bisection Method
 Pros
 Easy
 The bisection method is always convergent. Since the method brackets the
root, the method is guaranteed to converge.
 As an iteration is conducted, the interval gets halved. So one can guarantee
the error in the solution of the equation.
 Number of iterations required to attain an absolute error can be computed a
priori.
 Cons
 Slow convergent
 If one of the initial guesses is close to the root, the convergence is slower
 Multiple roots – cannot find lower & upper guesses!
 No account is taken of f(xl) and f(xu), if f(xl) is closer to zero, it is likely
that root is closer to xl.
False Position Method
 The false position method is another bracketing method. Also
known as linear interpolation method
 It determines the next guess not by splitting the bracket in half but
by connecting the endpoints with a straight line and determining
the location of the intercept of the straight line (xr).

f (xl ) f (xu )

xr  xl xr  xu


False Position Method
 The value of xr then replaces whichever of the two initial
guesses yields a function value with the same sign as f(xr).
 If a real root is bounded by xl & xu,
 approximate the solution by a linear interpolation
between xl & xu

 Using similar triangle, FALSE-POSITION FORMULA:

f (xu )(xl  xu )
xr  xu 
f (xl )  f (xu )


False Position Method
1. Choose a pair of values of xl and xu such that they always bracket the
root. (i.e. f(xl).f(xu) <0).
2. Estimate the root using

f (xu )(xl  xu )
xr  xu 
f (xl )  f (xu )

3. Evaluate the following


 a) IF f(xl).f(xr) < 0  root lies in lower sub interval
SET xl = xl & xu = xr for the next iteration
b) IF f(xl).f(xr) > 0  roots lies in upper subinterval
SET xu = xu & xl = xr for the next iteration
c) If f(xr) = 0  you have found the root! So stop!
False Position Method

root lies in lower sub


interval
SET xl = xl & xr = xu for the next iteration

roots lies in upper


SET xr = xl & xu = xu for the next iteration
subinterval
False Position Method
 Why this method?
 Faster
 Always converge for a single root

 Disadvantages
 One-sideness–one bracketing point will tend to stay
fixed
 can lead to poor convergence, especially for
functions with significant curvature.

 Note: Always check by substituting estimated root in the


original equation to determine whether f(x r) ≈ 0.
Example 3
False Position Method

As in Example 1, initiate the computation with guesses of xl


= 12 and xu = 16.

First iteration:

xl  12 f (xl )  6.0699
xu  16 f (xu )  2.2688

2.2688(12  16)
xr  16   14.9113
6.0669  (2.2688)

Which has a true relative error of 0.89 %


Example 3
False Position Method
Second iteration:

f (xl ). f (xr )  1.5426

Therefore the root lies in the first subinterval and xr becomes the
upper limit for the next iteration, xu = 14.9113:


xl  12 f (xl )  6.0699
xu  14.9113 f (xu )  0.2543
0.2543(12  14.9113)
xr  14.9113   14.7942
6.0669  (0.2543)
which has true and approximate
 relative errors of 0.09 and 0.79
percent. Additional iterations can be performed to refine the
estimate of the roots.

Bisection vs. False Position
 The error for false position decreases much
faster than bisection because of the more
efficient scheme for root location in the false-
position method.
 In the bisection method that the interval between
xl and xu grew smaller during the course of a
computation.

 For the false position method, the initial guesses


may stay fixed throughout the computation as
the other guess converges on the root. For such
cases, the interval does not shrink but rather
approaches a constant value.
Bisection vs. False Position
 Bisection does not take into account the shape of the function (only
use the sign of f(x)).
 False position does take into account the shape of the function 
this can be good or bad depending on the function!
 Bad :

f (x)  x10  1
 False position is based on the premise that:
 If f(xl) is closer to zero than f(xu), then the root is closer to xl
 than to xu.

 In this case, the opposite is true! .. Because of the shape of the


function.

You might also like