资源描述:
《数值分析新课件教学作者教学专用 NA02am.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、第二章非线性方程求根/*SolutionsofNonlinearEquations*/§1多项式基础/*Polynomials*/(自习)§2二分法/*BisectionMethod*/求f(x)=0的根原理:若fC[a,b],且f(a)·f(b)<0,则f在(a,b)上必有一根。§2BisectionMethodabx1x2abWhentostop?或不能保证x的精度x*2xx*§2BisectionMethod误差分析:第1步产生的有误差第k步产生的xk有误差对于给定的精度,可估计二分法所需的步数k:①简单;②对f(x)要求不高(只要连续即可).①无法求复根及重根②收敛慢注
2、:用二分法求根,最好先给出f(x)草图以确定根的大概位置。或用搜索程序,将[a,b]分为若干小区间,对每一个满足f(ak)·f(bk)<0的区间调用二分法程序,可找出区间[a,b]内的多个根,且不必要求f(a)·f(b)<0。HW:p.16#1§2BisectionMethodLab02.BisectionMethodUsetheBisectionmethodtofindonmgivenintervalsthemrealrootsofagivenpolynomialofdegree5nm,.InputThereareseveralsetsofinputs.Foreachset:T
3、he1stlinecontainsanintegernwhichisthedegreeofapolynomial.n=1signalstheendoffile.The2ndlinecontainsn+1realnumberswhicharethecoefficientsofthepolynomial.Thenumbersareseparatedbyspaces.The3rdlinecontainsanintegerMaxandtworealnumberseps1andeps2,whereMaxisthemaximumnumberofiterations,eps1istheaccur
4、acyboundforxandeps2istheaccuracyboundforp(x).The4thlinecontainsanintegerm(nm0),followedbympairsofrealnumbersa1b1…ambmwhicharetheendpointsoftheintervals[a1,b1]…[am,bm].OutputEachrootistobeprintedasintheCfprintf:fprintf(outfile,"%12.7f",root);/*hererepresentsaspace*/Ifthereisnorootfoundinanin
5、terval,simplyprint“noroot”.Theoutputofthenextsetmustbeprintedinanewline.SampleInput(representsaspace)210110000.000000010.00000001220.50.523100110000.000000010.00000001210021SampleOutput(representsaspace)1.00000001.0000000noroot1.0000000§2BisectionMethod
6、试位法/*RegulaFalsiMethod*/ab(a+b)/2x*(a,f(a))(b,f(b))IsitreallybetterthanBisectionMethod?注:试位法每次迭代比二分法多算一次乘法,而且不保证收敛。§2BisectionMethod§3迭代法/*Fixed-PointIteration*/f(x)=0x=g(x)等价变换f(x)的根g(x)的不动点思路从一个初值x0出发,计算x1=g(x0),x2=g(x1),…,xk+1=g(xk),…若收敛,即存在x*使得,且g连续,则由可知x*=g(x*),即x*是g的不动点,也就是f的根。Sobasically
7、wearedone!Ican’tbelieveit’ssosimple!What’stheproblem?Ohyeah?Whotellsyouthatthemethodisconvergent?§3Fixed-PointIterationxyy=xxyy=xxyy=xxyy=xx*x*x*x*y=g(x)y=g(x)y=g(x)y=g(x)x0p0x1p1x0p0x1p1x0p0x1p1x0p0x1p1§3Fixed-PointIteration定