09 chap-2a
TRANSCRIPT
7/28/2019 09 CHAP-2a
http://slidepdf.com/reader/full/09-chap-2a 1/13
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
1
~ Roots of Equations ~
Bracketing Methods
7/28/2019 09 CHAP-2a
http://slidepdf.com/reader/full/09-chap-2a 2/13
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
2
• Easy
• But, not easy
a
acbb xcbxax
2
40
22
? 0)3sin()10cos(? 0sin
? 02345
x x x x x x
x f exdxcxbxax
Roots of Equations
7/28/2019 09 CHAP-2a
http://slidepdf.com/reader/full/09-chap-2a 3/13
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
3
Graphical Approach
• Make a plot of the function f(x)and observe where it crosses the
x-axis, i.e. f(x) = 0
• Not very practical but can be usedto obtain rough estimates for roots
• These estimates can be used as
initial guesses for numericalmethods that we’ll study here.
7/28/2019 09 CHAP-2a
http://slidepdf.com/reader/full/09-chap-2a 4/13
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
4
Fig 5.2
Different cases:
Odd and evennumber of roots
Fig 5.3
exceptions
7/28/2019 09 CHAP-2a
http://slidepdf.com/reader/full/09-chap-2a 5/13
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
5
Bisection Method
Termination criteria: e < Epsilon OR Max.Iteration is reached
%100 :estimateerror Relativenew
r
old
r
new
r
x
x x
e
7/28/2019 09 CHAP-2a
http://slidepdf.com/reader/full/09-chap-2a 6/13
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
6
Fig 5.10:
Pseudocode toimplement the
Bisection Method
7/28/2019 09 CHAP-2a
http://slidepdf.com/reader/full/09-chap-2a 7/13Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
7
Bisection Method
Pros
• Easy
• Always finds a root• Number of iterations
required to attain an
absolute error can be
computed a priori.
How?
Cons
• Slow
• Need to find initialguesses for xl and xu
• Multiple roots
• No account is taken
of the fact that if f(xl)is closer to zero, it is
likely that root is
closer to xl .
7/28/2019 09 CHAP-2a
http://slidepdf.com/reader/full/09-chap-2a 8/13Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
8
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
• If the root (solution) is close to xl then we can write
k error relativedesired x L
error relativedesired
x
L
l
l
k
k
for solve ) _ _ (*2
_ _
0
7/28/2019 09 CHAP-2a
http://slidepdf.com/reader/full/09-chap-2a 9/13Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
9
Fig 5.11
Minimize functionevaluations in the code.
Why?
Because they are costly
(takes more time)
7/28/2019 09 CHAP-2a
http://slidepdf.com/reader/full/09-chap-2a 10/13Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
10
The False-Position Method(Regula-Falsi)
• If the root is between xland xu, then we canapproximate the solution
by doing a linear interpolation betweenthe points [xl, f(xl)] and
[xu, f(xu)] to find the xr value such that l(xr )=0,where l(x) is the linear approximation of f(x).
• Derive xr
using similar triangles (Box 5.1):
Fig. 5.12
l u
l uul r
f f
f x f x x
7/28/2019 09 CHAP-2a
http://slidepdf.com/reader/full/09-chap-2a 11/13Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
11
The False-Position Method
Good! but be careful Here is a pitfall
Interesting!
7/28/2019 09 CHAP-2a
http://slidepdf.com/reader/full/09-chap-2a 12/13Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
12
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
detect when one of the bounds is
stuck.
If this occurs, the function value at
the stagnant bound can be divided in
half (original Bisection method).
The resultant code
7/28/2019 09 CHAP-2a
http://slidepdf.com/reader/full/09-chap-2a 13/13C i ht © 2006 Th M G Hill C i I P i i i d f d ti di l
13
How to find good initial guesses?
• Start at one end of the region of interest (xa) and evaluate
f(xa), f(x
a+Dx), f(x
a+2Dx), f(x
a+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 miss two closely spaced roots
even worse, if there is a multiple root .
partial solution: if the 1.derivative, f’(.), changes sign in an interval, it suggests a localminima/maxima and the vicinity should be examined more carefully for closely spaced roots.
Ultimate solution:
Know the application and plot the function to see the location of the roots
And pick x l and x u accordingly to start the iterations.