0% found this document useful (0 votes)
42 views11 pages

Roots of Equations Bracketing Methods: Credit: Prof. Lale Yurttas, Chemical Eng., Texas A&M University

chapter 5 solution

Uploaded by

kal
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
Download as ppt, pdf, or txt
0% found this document useful (0 votes)
42 views11 pages

Roots of Equations Bracketing Methods: Credit: Prof. Lale Yurttas, Chemical Eng., Texas A&M University

chapter 5 solution

Uploaded by

kal
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1/ 11

~ Roots of Equations ~

Bracketing Methods
Chapter 5

Credit: Prof. Lale Yurttas, Chemical Eng., Texas A&M University 1


Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Roots of Equations

• Easy
 b  b 2
 4ac
ax  bx  c  0  x 
2

2a

• But, not easy


ax5  bx 4  cx3  dx 2  ex  f  0  x?

• How about these?


sin x  x  0  x?
cos(10 x)  sin( 3 x)  0  x  ?
2
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Graphical Approach
• Make a plot of the Using MATLAB, plot f(x)=sin(10x)+cos(3x)
function f(x) and
observe where it
crosses the x-axis,
i.e. f(x) = 0

• Not very practical


but can be used to
obtain rough
estimates for roots
Two distinct
• These estimates can roots between
be used as initial
x= 4.2 and 4.3
guesses for
numerical methods need to be careful
that we’ll study here.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Bracketing:
exceptions

Odd and even


number of roots

4
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Bisection Method

xu  xl
Relative error estimate: e 100%
Min{xl ; xu }

Termination criteria: e < etol OR Max.Iteration is reached


Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
% Bisection Method
% function is available in another file e.g. func1.m
MATLAB code % A sample call: bisection2(@func1, -2, 4, 0.001, 500)

function root = bisection(fx, xl, xu, es, imax);


Bisection
Method if fx(xl)*fx(xu) > 0 % if guesses do not bracket
disp('no bracket')
return
end

for i=1:1:imax
xr=(xu+xl)/2
ea = abs((xu-xl)/xl);

test= fx(xl)*fx(xr);
if test < 0
• Minimize function xu=xr;
end
evaluations in the if test > 0
code. xl=xr;
end
Why? if test == 0
ea=0;
end
• Because they are if ea < es
costly (takes more break;
end
time) 6

end Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
How Many Iterations will It Take?
• Length of the first Interval Lo= xu- xl
• After 1 iteration L1=Lo/2
• After 2 iterations L2=Lo/4
….. …..
• After k iterations Lk=Lo/2k

• Then we can write:

Lk
 error _ tolerance wher e xr  Min{ xl , xu }
xr
L0
k
 xr * e tol
2
L0  L0 
2 
k
 k  log 2 
xr * e tol  x r * e tol 
7
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Bisection Method

Pros Cons

• Easy • Slow
• Always finds a root • Need to find initial
• Number of iterations guesses for xl and xu
required to attain an • No account is taken
absolute error can be of the fact that if f(xl)
computed a priori. is closer to zero, it is
likely that root is
closer to xl .

8
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
The False-Position Method (Regula-Falsi)

• We can approximate the


solution by doing a
linear interpolation
between f(xu) and f(xl)

• Find xr such that


l(xr)=0, where l(x) is the
linear approximation of
f(x) between xl and xu

• Derive xr using similar


triangles

xl f u  xu f l
xr 
fu  fl
9
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
The False-Position Method
Works well, but not always!
 Here is a pitfall 

Modified False-Position
One way to mitigate the “one-sided”
nature of the false position (i.e. the
pitfall case) is to have the algorithm
pick the smallest bracket (between
the Bisection Method & this one)

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
How to find good initial guesses?
• Start at one end of the region of interest (xa) and evaluate
f(xa), f(xa+Dx), f(xa+2Dx), f(xa+3Dx), ........

• Continue until the sign of the result changes.


If that happens between f(xa+k*Dx) and f(xa+(k+1)*Dx)

then pick xl= xa+k*Dx and xu= xa+(k+1)*Dx

Problem:
if Dx is too small  search is very time consuming
if Dx is too large  could jump over two closely spaced roots

Suggestions:
• Generate random x values and evaluate f(x) each time until you find two values that
satisfy f(x1)*f(x2) < 0
• Know the application and plot the function to see the location of the roots, and pick xl
and xu accordingly to start the iterations.
11
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

You might also like