/8/18 Couse Instucto D. Raymond C. Rumpf Office: A 337 Phone: (915) 747 6958 E Mail: cumpf@utep.edu Topic 4a Intoduction to Root Finding & Backeting Methods EE 4386/531 Computational Methods in EE Outline Intoduction Backeting Methods The Bisection Method False Position Method Multiple Roots 1
/8/18 Intoduction 3 What is Root Finding? What values of does f() =? et f a b c We can figue this out algebaically b b 4ac a But what if f e This cannot be solved analytically. We need to use a numeical method. 4
/8/18 Root Finding Methods Backeting Methods Finding a single oot that falls within a known ange. Vey obust Must know something ahead of time. Open Methods Tial and eo iteative methods Do not need bounds, only an initial guess. Moe efficient than backeting methods Can be unstable and not find a solution Roots of Polynomials Algoithm specific to polynomials Physics of you poblem must be fit to a polynomial Able to find all oots. Requies initial bounds U Requies an initial guess 1 Requies multiple points, y,, y,,, y 1 1 N N 5 Genealizing Root Finding Algoithms Root finding algoithms find all values of such that f() =. What if we wish to find all values of such that f() = a? Genealization f a f a et g f a Now pefom standad oot finding on g(). 6 3
/8/18 Peliminay Root ocation The basic oot finding algoithms all equie that a oot be oughly located. The oot finding algoithm only efines the ough location. This means we must detemine at least appoimate locations of the oots. This infomation can come fom one of seveal things. 1. Something is known about the physics of the poblem being solved that gives you infomation about whee the oots should be.. If nothing else is known, plot the function to identify the location of the oots and feed each of those ough locations into a ootfinding algoithm. You may have to geneate a numbe of plots and play with ais scaling to find the oots. Slide 7 Need fo Optimized Algoithms In many cicumstances, a single computation of f() may take hous, days, o weeks! In these cases it is highly desied to minimize the total numbe of computations of f(). It is often woth the investment of a few hous to wite an awesome code that uns in an hou than waiting days o weeks fo the answe to come fom a simple code you wote in a few minutes. 8 4
/8/18 The Bisection Method 9 Step 1 Pick a lowe and uppe bound, and U that is known to contain a single oot between them. 1..8.6.4 f(). -. Root we wish to find. f() -.4 -.6 U -.8.5.75 3. 3.5 3.5 3.75 4. 1 5
/8/18 Step Calculate the midpoint between and U as the fist guess fo the oot. 1..8.6.4 f(). -. Fist guess U f() -.4 -.6 U -.8.5.75 3. 3.5 3.5 3.75 4. 11 Step 3 Calculate the function at the midpoint. f f() U 1 6
/8/18 Step 4 Adjust the bounds. f() U 13 Step 5 Calculate the midpoint. 1..8.6 Second guess U f().4 f(). -. -.4 -.6 U -.8.5.75 3. 3.5 3.5 3.75 4. 14 7
/8/18 Step 6 Calculate the function at the midpoint. 1..8.6.4 f(). -. U f() -.4 -.6 -.8 f.5.75 3. 3.5 3.5 3.75 4. 15 Step 7 Adjust the bounds. 1..8.6.4 f(). -. -.4 -.6 U f() -.8.5.75 3. 3.5 3.5 3.75 4. 16 8
/8/18 Step 8 Calculate a midpoint. 1..8.6.4 f(). U f() -. -.4 -.6 -.8.5.75 3. 3.5 3.5 3.75 4. U 17 Step 9 Calculate the function at the midpoint. 1..8.6.4 f(). U f() -. -.4 -.6 f -.8.5.75 3. 3.5 3.5 3.75 4. 18 9
/8/18 Step 1 Adjust the bounds. 1..8.6.4 f(). -. -.4 -.6 U f() -.8.5.75 3. 3.5 3.5 3.75 4. 19 Step 11 Calculate a midpoint. 1..8.6.4 f(). U f() -. -.4 -.6 -.8.5.75 3. 3.5 3.5 3.75 4. U 1
/8/18 Step 1 Calculate the function as the midpoint. 1. U.8.6.4 f(). f f() -. -.4 -.6 -.8.5.75 3. 3.5 3.5 3.75 4. 1 Step 13 and Beyond And so on Iteation 1 Iteation 1 1.5.5 f() f() -.5 -.5.5 3 3.5 4 Iteation 3.5 3 3.5 4 Iteation 4 1 1.5.5 f() f() -.5 -.5.5 3 3.5 4 Iteation 5.5 3 3.5 4 Iteation 6 1 1.5.5 f() f() -.5 -.5.5 3 3.5 4 Iteation 7.5 3 3.5 4 Iteation 8 1 1.5.5 f() f() -.5 -.5.5 3 3.5 4.5 3 3.5 4 11
/8/18 Adjusting the Bounds (1 of ) Be caeful about signs when adjusting the bounds. f() 1..8.6.4. -. -.4 -.6 -.8 Move uppe bound.5.75 3. 3.5 3.5 3.75 4. Hee the function is positive and we move the uppe bound. f().8.6.4. -. -.4 -.6 -.8-1. - Move uppe bound.5.75 3. 3.5 3.5 3.75 4. Hee the function is negative and we still move the uppe bound. 3 Adjusting the Bounds ( of ) If f f If f f then thee is a sign change between and. This means the oot is close to than U. Move U to. then the sign change must be between U and. This means the oot is close to U than. Move to. If f f then we ae done because we have the oot eactly. % Adjust the Bounds if f*f< U = ; fu = f; elseif f*f> = ; f = f; else beak; end %oot towad f %oot towad fu 4 1
/8/18 When is the Algoithm Finished? i. Calculate the amount has moved fom one iteation to the net. old old ii. At the end of each iteation, check if is less than some theshold. toleance Rule of thumb: If you want some numbe of digits of pecision, ensue is at least an ode of magnitude less than the desied pecision. WARNING! Do not set you convegence condition to U <toleance because this will fail when the same bounday is being adjusted each iteation. 5 Block Diagam of Bisection Method Stat Choose and. Evaluate f() at endpoints. f f f f U U Calculate midpoint. U Move lowe bound. f f Evaluate f() at midpoint. f f f f Done! Calculate. U Move uppe bound. f f U U Calculate change. old no tol yes Done! 6 13
/8/18 Algoithm fo Bisection Method 1. Choose lowe and uppe bounds, and U so that they suound a oot.. Evaluate the function at the endpoints, f( ) and f( U ). 3. Calculate midpoint. U 4. Iteate until conveged a) Evaluate the function at the midpoint f( ). b) Adjust the bounds. If f f, then U If f f, then If f, then DONE! c) Update the midpoint. U d) Detemine if conveged i. Calculate step size old ii. Algoithm is conveged if < toleance. 7 Notes on Bisection Method Most obust oot finde east efficient oot finde Guaanteed to find a oot as long as the bounds span a cossing Sometimes good to check sign change of bounds No sign change o even numbe of oots. Sign change odd numbe of oots. 8 14
/8/18 False Position Method 9 Moe Intelligent Midpoint False-Position Method U f f f f U U U f U U f Bisection Method U Since f f H, it is a good assumption that the oot is close to than it is to H. 3 15
/8/18 Step 1 Pick a lowe and uppe bound, and U that is known to contain a single oot. 1..8.6.4 f(). -. Root we wish to find. f() -.4 -.6 U -.8.5.75 3. 3.5 3.5 3.75 4. 31 Step Calculate a bette estimate of the position of the oot using a linea appoimation. 1..8.6.4 f(). -. Bette estimate f() -.4 -.6 U -.8.5.75 3. 3.5 3.5 3.75 4. 3 16
/8/18 Step 3 Calculate the function at the estimate fo. 1..8.6.4 f(). f() -. -.4 -.6 f U -.8.5.75 3. 3.5 3.5 3.75 4. 33 Step 4 Adjust the bounds. 1..8.6.4 f(). -. -.4 f() -.6 U -.8.5.75 3. 3.5 3.5 3.75 4. 34 17
/8/18 Step 5 Estimate the position of the oot by linea appoimation. 1..8 Second guess.6.4 f(). f() -. -.4 -.6 U -.8.5.75 3. 3.5 3.5 3.75 4. 35 Deivation of Estimate (1 of 3) The equation of a line given a point (, y ) and slope m is y y m Assuming the function connecting the bounds is close to linea, the slope is appoimately m f f U U 36 18
/8/18 Deivation of Estimate ( of 3) et s choose the lowe bound to be the point in ou line equation. y f U f f y f U m We now estimate the position of the oot by setting y = and solving fo. f U f f U f U f U f 37 Deivation of Estimate (3 of 3) et s choose the uppe bound to be the point in ou line equation. f U U f y f U U y f U U We now estimate the position of the oot by setting y = and solving fo. f U f f U U U f U U U f U f m 38 19
/8/18 Intepetation of Estimate (1 of ) We have two possible equations to estimate the position of the oot. f U f U f f U U U f U f et s aveage these equations. f f U U U U f U f f U f f f U U f f U U 39 Intepetation of Estimate ( of ) U U f f U f U f Typical bisection method equation A coection tem to give a bette estimate. 4
/8/18 Block Diagam of False Position Method Stat Choose and. Evaluate f() at endpoints. f f f f U U Calculate midpoint. U Move lowe bound. f f Evaluate f() at midpoint. f f f f Done! Calculate. f f f f U U U U Move uppe bound. f f U U Calculate change. old This is the only diffeence fom bisection method. no tol yes Done! 41 When False Position Fails The false position method can fail o ehibit etemely slow convegence when the function is highly nonlinea between the bounds. This happens because the estimated oot is a vey poo guess. Slide 4 1
/8/18 Notes on False Position Method Vey simila to bisection method Calculates a moe intelligent midpoint. Conveges much faste fo nea linea functions. Conveges slowe fo functions with abupt cuves 43 Multiple Roots 44
/8/18 Recognizing Numbe of Roots Single Root Sign changes on eithe side of oot. f f Slope at oot is not zeo. f Tiple Root Sign changes on eithe side of oot. f f Slope at oot is zeo. f Cuvatue changes on eithe side of oot. f f Double Root Sign is same on eithe side of oot. f f Slope at oot is zeo. f Cuvatue is same on eithe side of oot. f f Quaduple Root Sign is same on eithe side of oot. f f Slope at oot is zeo. f Cuvatue is same on eithe side of oot. f f Cuvatue is boad and flat. 45 Poblem with Multiple Roots Backeting methods equie a sign change on eithe side of the oot. This means they only wok fo odd multiple oots. double oot tiple oot WI NOT WORK Slide 46 3
/8/18 A Useful Popety We can define an auiliay function u() that will have the same oots as f() but will always change sign on eithe side of any multiple oot. f single oot u f f double oot tiple oot Slide 47 The Fi If f() has even multiple oots, pefom oot finding on the auiliay function u() instead. Slide 48 4