Root Fidig COS 323
Remider Sig up for Piazza Assigmet 0 is posted, due Tue 9/25
Last time.. Floatig poit umbers ad precisio Machie epsilo Sources of error Sesitivity ad coditioig Stability ad accuracy Asymptotic aalysis ad covergece order
Today Root fidig defiitio & motivatio Stadard techiques for root fidig Algorithms, covergece, tradeoffs Eample applicatios of Newto s Method Root fidig i > 1 dimesio
1-D Root Fidig Give some fuctio, fid locatio where f0
Why Root Fidig? Solve for i ay equatio: f b where? fid root of g f b 0 Might ot be able to solve for directly e.g., f e -0.2 si3-0.5 Evaluatig f might itself require solvig a differetial equatio, ruig a simulatio, etc.
Why Root Fidig? Egieerig applicatios: Predict depedet variable e.g., temperature, force, voltage give idepedet variables e.g., time, positio Focus o fidig real roots
Bracket-Based Methods Give: Poits that bracket the root A well-behaved fuctio Ca always fid some root f + > 0 f < 0
What Goes Wrog? Taget poit: very difficult to fid Sigularity: brackets do t surroud root Pathological case: ifiite umber of roots e.g. si1/
Bisectio Method Give poits + ad that bracket a root, fid half ½ + + ad evaluate f half If positive, + half else half Stop whe + ad close eough If fuctio is cotiuous, this will succeed i fidig some root
Error Covergece of Iterative Methods Absolute error boud ε at step : ε bouds estimated at step true Covergece: describes how ε +1 relates to ε Liear covergece: ε +1 c ε for some c 0,1 Superliear covergece: ε +1 c ε q for some c 0,1, q > 1
Liear: Superliear: Subliear:
Bisectio Error Covergece Very robust method: guarateed to fid root! Covergece rate: Error bouded by size of [ + ] iterval Iterval shriks i half at each iteratio So, error boud cut i half at each iteratio: ε +1 ½ ε Liear covergece! Oe etra bit of accuracy i at each iteratio
Faster Root-Fidig Facier methods get super-liear covergece Typical approach: model fuctio locally by somethig whose root you ca fid eactly Model did t match fuctio eactly, so iterate I may cases, these are less safe tha bisectio
Secat Method Iterpolate or etrapolate through two most recet poits 3 2 1 4
Secat Method Covergece Faster tha bisectio: ε +1 c ε 1.6 Faster tha liear: umber of correct bits multiplied by 1.6 Drawback: oly true if sufficietly close to a root of a sufficietly smooth fuctio Does ot guaratee that root remais bracketed
False Positio Method Similar to secat, but guaratees bracketig 4 3 2 1 Stable, but liear i bad cases
False Positio Failure 2 1 3
Other Iterpolatio Strategies Ridders method: fit epoetial to f +, f, ad f half Va Wijgaarde-Dekker-Bret method: iverse quadratic fit to 3 most recet poits if withi bracket, else bisectio Both of these safe if fuctio is asty, but fast super-liear if fuctio is ice
Demo
Newto-Raphso Best-kow algorithm for gettig quadratic covergece whe derivative is easy to evaluate Quadratic: # correct bits doubles each iteratio! ε +1 c ε 2 Aother variat o the etrapolatio theme 3 4 2 1 Slope derivative at 1 + 1 f f
Newto-Raphso covergece Begi with Taylor series Divide by derivative ca t be zero! f +δ f +δ f +δ 2 f 2 +... wat 0 2 1 2 2 2 ~ 2 0 2 0 2 Newto Newto f f f f f f f f ε ε δ δ δ δ δ δ δ δ + + + + +
Newto-Raphso Method fragile: ca easily get cofused Good startig poit critical Newto popular for polishig off a root foud approimately usig a more robust method Quadratic oly for simple root
Newto-Raphso Covergece Ca talk about basi of covergece : rage of 0 for which method fids a root Ca be etremely comple: here s a eample i 2-D with 4 roots
Commo Eample of Newto: Square Root Let f 2 a: zero of this is square root of a f 2, so Newto iteratio is Divide ad average method ~2000 B.C. a a + + 2 1 2 1 2 1 f f +
Reciprocal via Newto Divisio is slowest of basic operatios O some computers, hardware divide ot available!: simulate i software Need oly subtract ad multiply b b a b b f b f a + 2 0 * 2 2 1 1 1 1 1 1
Rootfidig i >1D Behavior ca be comple: e.g. i 2D wat f, y wat g, y 0 0
Rootfidig i >1D Ca t bracket ad bisect Result: few geeral methods
Newto i Higher Dimesios Start with Write as vector-valued fuctio 0, 0, wat wat y g y f,, y g y f f
Newto i Higher Dimesios Epad i terms of Taylor series wat f + δ f + f δ +... 0 f is a Jacobia f f J y f
Newto i Higher Dimesios 1-dimesioal case: δ f / f N-dimesioal: Solve for δ δ J 1 f Requires matri iversio we ll see this later Ofte fragile must be careful Keep track of whether error decreases If ot, try a smaller step i directio δ
Recap: Tradeoffs Bracketig methods Bisectio, False-positio Stable, slow Ope methods Secat, Newto Possibly diverget, fast Newto requires derivative Hybrid methods Bret Combie bracketig & ope methods i a pricipled way
Practical otes Root-fidig i Matlab: fzero: For fidig root of a sigle fuctio Combies safe ad fast methods roots: For fidig polyomial roots Ecel: Goal Seek: Drive a equatio to 0 by adjustig 1 parameter Solver: Ca vary multiple parameters simultaeously, also miimize & maimize Tip: Plot your fuctio first!!!