Chapter 4: Root Fndng Startng values Closed nterval methods (roots are search wthn an nterval o Bsecton Open methods (no nterval o Fxed Pont o Newton-Raphson o Secant Method Repeated roots Zeros of Hgher-Dmensonal Functons MATLAB routnes
4. Introducton Roots are solutons for solvng f( x = 0. We can dstngush: Closed methods o convergence guaranteed Open methods o Dvergence may occur o f convergence occurs, t s usually faster (rate s hgher To approxmate a root, the startng value s mportant: f possble, frst draw a graph feval(f,x,,xn: evaluates functon f n the ponts x,,xn,.e. f(x,,f(xn Ex. feval('sn',0.3 sn(0.3 or feval('mycode',0.,0.3 mycode(0.,0.3
4. Startng Values Userfn.m functon [value] = userfn(x,par,par value = x - par * sn(x.^par; Code x=-.0:0.0:.0; y=feval('userfn',x,,; plot(x,y; grd on; zoom on; zoom n: clck on graph zoom out: shft & clck 4 3 0 - - -3-4 - -.5 - -0.5 0 0.5.5 3
4.4 Bsecton Assumpton: nterval [a, b] contans one root In ths method, the nterval s splt n two: f the functon changes sgn (+ to or to +, then the functon s evaluated n the mddle the locaton of the root should le n the subnterval n whch the product changes sgn The absolute error s halved n each teraton: length nterval after n teratons: f ε s a gven tolerance, then b a n b a ln ε n > ln 4
4.3 Fxed Pont Rewrte equaton f( x = 0 n x= gx ( Ths can usually be done s several ways: for nstance ( ( x= sn( x g(x= *sn(x.^ x= sn ( x/ g(x=sqrt(asn(x/ Scheme: xn+ = gx ( n n = 0,,... f( x = x sn( x Startng value: x 0 (how to choose? When to stop? o f( xn 0 f xn+ gx ( n : xn+ xn <ε (ε small o maxmum number of teratons (to prevent nfnte loop Method only works f g'( x < g(x= *sn(x.^ fnds root 0 g(x= sqrt(abs(asn(x/ fnds root close to 0.5 5
4.3 Fxed Pont: convergence a Convergent:0 g ' < b Convergent: < g ' 0 c Dvergent: g ' > d Dvergent: g ' < 6
4.3 Fxed Pont: convergence Defnton fxed pont: gx ( = x If ( g s a contnuous functon on the closed nterval [a,b] ( g:[ ab, ] [ ab, ] ( g s dfferentable wth g'( x k < for all xî ( ab,, then the sequence { xn = gx ( n} converges to the fxed pont x for every x0 Î [ ab, ]. Proof: xn - x = gx ( n -gx ( by defnton of xn and x = g'( c xn -x Mean value theorem k x -x g' bounded by k n k xn- -x repeat prevous 3 steps n k x 0 -x Because 0< k <, we get lm x - x lm k n x - x =. n+. 0 0 n n Mean value theorem: f fî Cab [, ] and dfferentable, then there exsts a pont cî ( ab, such that f '( c = ( f( b - f( a / ( b- a f( b - f( a = f '( c( b- a 7
4.5 Newton-Raphson Taylor approxmaton: ( ( ( n ( ( ( '' (3 ( ' f x f x 3 f x n + = + + + + + + n f x f x f x h h h h R! 3! n! ' f ( x+ = f ( x + f ( x h+ O( h Suppose f( x + = 0 & Oh ( = 0, then ' 0 = f x + f x h, h= ( x x ( ( + Solvng for h: ( x+ x = f( x f '( x Iteraton scheme Newton-Raphson: x + = x f( x f '( x 8
4.5 Newton-Raphson - Graphcal f x ' ( x = = x + ' f( x 0 x x + f( x f ( x 9
4.5 Secant Method Approxmate the dervatve f '( x numercal: ( ( def. '( lm f x +δ f x = f x δ 0 δ f( x f( x fnte dfference: f '( x x x [forward dfference] Newton Raphson: x+ = x f( x f '( x x x forward dfference: f '( x f( x f( x x x Secant Method: x+ = x f( x f( x f( x no dervatve needed now, two startng values: x0, x varatons: x x o book: x+ = x f( x f( x f( x o backwards/central dfferences now: =,,... 0
4.6 Repeated roots Suppose: px ( = ( x λ qx ( wth q( λ 0 n [so λ s a root of order n] Dervatve: n p'( x = n( x λ q( x + ( x λ q'( x n n p'( λ = n( λ λ q( λ + ( λ λ q'( λ = 0 n Concluson: methods based on / p'( x unusable for searchng roots (nd order Taylor approxmaton: ( ( ( 3 f( x + 0 and Oh ( 0 '' ' ( ( ( f x h + f x h + f x = ah + bh + c = 0 ABC-formula: h ( ± + ( x '' ' f 3 + = + + + f x f x f x h h O( h! ( + ( + ( x+ f x+ < f x+ + = ( x+ otherwse b ± b 4ac f '( x ± f '( x 4 f ''( x f( x = = a f ''( x ( ( + ( ( x+ = x + h ; x+ = x + h ; x f ( (
4.7 Zeros of Hgher-Dmensonal Functons Suppose z x = y and f( z f( xy, = f( xy,, then ( ( ( f z+ = f z + f z h+ O( h f f f f δx δy f( z =, x y = f f δx δy hx T h= = ( hx : hy h y h = hx + hy Solvng for h: ( ( 0 = f z + f z h h= [ f( z ] f( z Newton-Raphson: z+ = z [ f( z] f( z [compare to x + = x ( f '( x f x ]
4.8 MATLAB Routnes for Fndng Roots roots(c: fndng roots of a polynomal wth coeffcents c polynomal coeffcents startng wth the coeffcent of hghest order a coeffcent of 0 ndcates an ntermedate powers that are not present polynomal of order n wth n+ coeffcents fzero(fun,x0,optons: very powerful, choses the best algorthm tself Ex. fzero('func',0.4,optmset('dsp','ter' or fzero(@(x x-*sn(x.^,0.4,optmset('dsp','ter' 3