1、);主窗口:fun=inline(3*x+1)/x2x_star,k=iteratel(fun,-1.5)结果:x = -1.5556 k = 1x = -1.5153k = 2 -1.5443 3 -1.5233 4 -1.5384 5 -1.5275 6 -1.5354 7 -1.5297 8 -1.5338 9 -1.5308 10 -1.5330 11 -1.5314 12 -1.5326 13 -1.5318 14 -1.5323 15 -1.5319 16 -1.5322 17 -1.5320 18 19 20 -1.5321 21 22 23 24 25 26 27 28x_st
2、ar =28x_star,k=iteratel(fun,1.9) 1.8560 1 1.9067 1.8484 1.9157 1.8385 1.9276 1.8255 1.9435 1.8084 1.9648 1.7860 1.9933 1.7567 2.0317 1.7188 2.0839 1.6699 2.1551 1.6074 2.2535 1.5282 2.3913 1.4294 2.5882 1.3084 2.8770 1.1636 3.3169 0.9954 29 4.0233 30 0.8074 31 5.2494 32 0.6078 33 7.6430 34 0.4096 35
3、 13.2830 36 0.2315 37 31.6141 38 0.0959 39 140.0292 40 0.0215 41 2.3080e+003 42 0.0013 43 5.9403e+005 44 5.0502e-006 45 3.9209e+010 46 7.6513e-011 47 1.7082e+020 48 1.7563e-020 49 3.2420e+039 50 9.2535e-040 51 1.1679e+078 52 2.5688e-078 53 1.5155e+155 54 0 55 Inf 56 NaN 57x_star,k=iteratel(fun,1)结果
4、: 0.8125 5.2071 0.6130 7.5549 0.4146 13.0528 0.2357 30.7272 0.0987 133.0649 0.0226 2.0903e+003 0.0014 4.8741e+005 6.1550e-006 2.6397e+010 1.1365e-010 7.7421e+019 3.8749e-020 6.6600e+038 4.5045e-039 4.9284e+076 6.0872e-077 2.6988e+152 1.1116e-152 8.0925e+303x_star,k=iteratel(fun,-1) -2 -1.2500 -1.760
5、0 -1.3817 -1.6474 -1.4526 -1.5914 -1.4903 -1.5628 -1.5102 -1.5480 -1.5207 -1.5404 -1.5261 -1.5364 -1.5290 -1.5343 -1.5305 -1.5333 -1.5312 -1.5327 -1.5316 -1.5324 fun=inline(x3-1)/3x_star,k=iteratel(fun,1.5) 0.7917 -0.1679 -0.3349 -0.3459 -0.3471 -0.34732.解答:function x_star,k=Newton1(fname,dfname,x0,
6、ep,Nmax)5 Nmax=500;4 ep=1e-5;Nmax k=k+1;x=x0-feval(fname,x0)/feval(dfname,x0); fname=inline(x3-2*x2-4*x-7 dfname=inline(3*x2-4*x-4 x_star,k=Newton1(fname,dfname,3) 3.63203.解答:M文件(双点割线):function x_star,k=Gline(fun,x0,x1,ep,Nmax)while abs(x1-x0) x2=x1-feval(fun,x1)*(x1-x0)/(feval(fun,x1)-feval(fun,x0) x0=x1; x1=x2;x_star=x1; x_star,k=Gline(fun,3,4)x2 = 3.5263 3.6168 3.63275解答:x2-2*x-exp(x)+2 x_star,k=Gline(fun,0,1) 0.3679 0.3508 0.3513
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1