0% found this document useful (0 votes)
30 views28 pages

Applied Numerical Methods: Dr. Khaled Ahmida Al-Ashouri The Libyan Academy - Tripoli

The document discusses root finding methods for numerical analysis. It covers the bisection method and false position method. The bisection method uses bracketing to iteratively narrow the range containing a root of a function by dividing it in half. The false position method approximates the function locally with a straight line to estimate each new root. Both methods start with an initial range where the function changes sign and iteratively converge on the root.

Uploaded by

taha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views28 pages

Applied Numerical Methods: Dr. Khaled Ahmida Al-Ashouri The Libyan Academy - Tripoli

The document discusses root finding methods for numerical analysis. It covers the bisection method and false position method. The bisection method uses bracketing to iteratively narrow the range containing a root of a function by dividing it in half. The false position method approximates the function locally with a straight line to estimate each new root. Both methods start with an initial range where the function changes sign and iteratively converge on the root.

Uploaded by

taha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

APPLIED NUMERICAL METHODS

Dr. Khaled Ahmida Al-Ashouri


The Libyan Academy - Tripoli
Numerical Analysis Course
Dr. Khaled Ahmida

ROOT FINDING
 Almost all root-finding methods are iterative
 Start from an initial guess and improve solution until
convergence satisfied
 Initial guess can be improved by plotting equation
 Simplest: Bracketing methods Bisection & False-
Position
Numerical Analysis Course
Dr. Khaled Ahmida

ROOT FINDING
ELEMENTARY
 Bisection Method
 False Position Method
PRACTICAL
 Newton-Raphson’s Method, Brent’s algorithm, Laguerre’s method
Numerical Analysis Course
Dr. Khaled Ahmida

BISECTION METHOD
 An equation f(x)=0, where f(x) is a real continuous function, has at least
one root between xl and xu if f(xl) f(xu) < 0.

f(x)

x
x
xu

Figure 1 Function may change sign between two points


Numerical Analysis Course
Dr. Khaled Ahmida

BISECTION METHOD
f(x)

x x
xu

Figure 2 Function does not change sign between two points but roots exist
Numerical Analysis Course
Dr. Khaled Ahmida

BISECTION METHOD
f(x)

xu
x
x

Figure 3 If the function changes sign between two points, at least one root exists
Numerical Analysis Course
Dr. Khaled Ahmida

BISECTION METHOD: ALGORITHM


 Step 1:
Choose xl and xu as guesses for root search such that f(xl )*f(xu) < 0, or in
other words, f(x) changes sign between xl and xu

Step 2:
Estimate the root xm of the equation f(x)=0 as the mid-point between xl
and xu as
x  xu
xm =
2
Numerical Analysis Course
Dr. Khaled Ahmida

BISECTION METHOD
 Step 3:
check the following
a) If f xl  f  xm   0 then the root lies between xl and xm; then
xl = xl ; xu = xm  Continue process (step 4)

b) If f xl  f  xm   0 then the root lies between xm and xu; then


xl = xm; xu = xu  Continue process (step 4)

c) If f xl  f  xm   0 then the root is xm. Stop.


Numerical Analysis Course
Dr. Khaled Ahmida

BISECTION METHOD
 Step 4:
 Find the new estimate of the root
x  xu
xm =
2
Find absolute relative approximate error (criteria to stop)

xmnew  xmold
a  new
100
xm
Or check if f ( xm ) s
Numerical Analysis Course
Dr. Khaled Ahmida

BISECTION METHOD
 Step 5:
 Compare the absolute relative approximate error a with the pre-
specified error tolerance s (usually ~10-6)
Go to Step 2 using new
No upper and lower
Is a s ? guesses.

 yes Stop the algorithm


 Should have maximum number of iterations to run
Numerical Analysis Course
Dr. Khaled Ahmida

Input xl,xu,f, s
BISECTION METHOD
 xm=(xl+xu)/2

yes
f(xm)=<s Root=xm

no

xu=xm No (solution [xl, xm]) Yes (solution [xm, xu]) xl=xm


f(xm)*f(xu)<0
f(xu)=f(xm) f(xl)=f(xm)
Numerical Analysis Course
Dr. Khaled Ahmida

BISECTION METHOD
 Advantages:
 always converges
 brackets halved in every step f(x)=1/x
1

 Drawbacks: 0.9

 slow to converge, compared to other advanced 0.8

methods 0.7

0.6
 if one initial guess is close to root, it converges 0.5
slowly 0.4

 Special cases: function may have no root at 0.3

all 1
0.2

f x   0.1

x 0
0 10 20 30 40 50 60 70 80 90 100
Numerical Analysis Course
Dr. Khaled Ahmida

BISECTION METHOD
 Example 1: solve the following equation using Bisection
method
f  x   e  x sin( x)  2.1
x 2
1
Graph of the function f(x)

0.8

 plot function between [0,1]


0.6

0.4

0.2

f(x)
0

-0.2

-0.4

-0.6

-0.8

-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x
Numerical Analysis Course
Dr. Khaled Ahmida

BISECTION METHOD

Approximate Root is 0.6260962


Numerical Analysis Course
Dr. Khaled Ahmida

False-Position Method
Numerical Analysis Course
Dr. Khaled Ahmida

FALSE-POSITION METHOD
f(xu)
f(x)

Equal angles

xl xr xu
x
x*
f(xr)
f(xl)
Numerical Analysis Course
Dr. Khaled Ahmida

FALSE-POSITION METHOD
 Start with [xl,xu] with f(xl)*f(xu) < 0
 Draw a straight line to approximate the root
f ( xu ) xl  f ( xl ) xu
f ( xr )  0  xr 
f ( xu )  f ( xl )
 Check signs of f(xl)*f(xr) and f(xr)*f(xu) so that [xl , xu ]
always bracket the root
Numerical Analysis Course
Dr. Khaled Ahmida

FALSE-POSITION METHOD
 Step 1: Choose xl and xu
 Step 2 : Estimate the root by finding the intersection of the
line connecting the two points (xl,f(xl)), and (xu,f(xu)) and the x-
axis
f ( xu ) xl  f ( xl ) xu
xr 
f ( xu )  f ( xl )
Numerical Analysis Course
Dr. Khaled Ahmida

FALSE-POSITION METHOD
 Step 3: Determine the new bracket
If f(xr)*f(xl) >0 then xl= xr else xu= xr

 Step 4: check whether to repeat iteration or stop by checking


if f(xr)<=tol, or if a  tol
x new  x old

a  100
m m
new
x m
Numerical Analysis Course
Dr. Khaled Ahmida

FALSE-POSITION METHOD
f(x)
xu,f(xu)
 Second iteration

xr,0

o x

xl,f(xl)
Numerical Analysis Course
Dr. Khaled Ahmida

FALSE-POSITION METHOD
input data

 Algorithm
check if
f(xl)*f(xu) < 0
otherwise choose another limits

xr=(f(xu)*xl - f(xl)*xu)/(f(xu) - f(xl))

If f(xr) <= tol

no yes
If f(xr)f(xl) < 0 Solution
then xu = xr obtaind
else xl = xr xr

end
Numerical Analysis Course
Dr. Khaled Ahmida

FALSE-POSITION METHOD
 Example: Solving the previous equation solved before by
Bisection method in the range of x=[0,1]

f  x   e x  x 2 sin( x)  2.1

Approximate Root is 0.62610


Numerical Analysis Course
Dr. Khaled Ahmida

BISECTION f  x   e x  x 2 sin( x)  2.1 x=[0,1]

FALSE-POSITION
Numerical Analysis Course
Dr. Khaled Ahmida

COMPARISON OF METHODS
 Usually False-Position converges faster
than Bisection
 Errors usually converge in a zigzag
manner, like in Bisection Method
 There are cases when False-Position
converges slowly. An example is

f x   x10  1
Numerical Analysis Course
Dr. Khaled Ahmida

COMPARISON OF METHODS 14

12

f x   x  1
10
10
8

 Solve between x=0 and x=1.3 4

-2
0 0.2 0.4 0.6 0.8 1 1.2 1.4
This example shows a drawback
of False-Position method
Numerical Analysis Course
Dr. Khaled Ahmida

COMPARISON OF METHODS
 Slow convergence of f x   x10  1
by False-Position method
 One solution is to use Modified
False-Position. Determine which bound
stays fixed (stuck) and divide it by half.
Modified False-Position is not covered in
this course.
Numerical Analysis Course
Dr. Khaled Ahmida

COMPARISON OF METHODS
f  x   x10  1
using
Bisection
Numerical Analysis Course
Dr. Khaled Ahmida

COMPARISON OF METHODS
f  x   x10  1
using
False-position

…….

You might also like