Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
1
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Roots of Equations
Easy
ax 2 bx c 0 b b 2 4ac x 2a
2
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
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 used to obtain rough estimates for roots These estimates can be used as initial guesses for numerical methods that well study here.
3
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Fig 5.2
Different cases: Odd and even number of roots
Fig 5.3
exceptions
4
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Bisection Method
xrnew xrold x
new r
100 %
6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
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 initial guesses 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
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
8
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Fig 5.11 Minimize function evaluations in the code. Why? Because they are costly (takes more time)
9
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Fig. 5.12
xl f u xu f l xr fu fl
10
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Interesting!
11
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
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
12
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
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 local
minima/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 xl and xu accordingly to start the iterations.
13
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.