1 / 12

第六讲 方程的近似根(解)的求法

第六讲 方程的近似根(解)的求法. 一、问题背景. 对分法. 2. 迭代法. 2. 迭代法. 3. 牛顿 (Newton) 法(牛顿切线法). 3. 牛顿 (Newton) 法(牛顿切线法). 4. 求方程根 ( 解 ) 的其它方法. (1) solve('x^3-3*x+1=0') (2) roots([1 0 -3 1]) (3) fzero('x^3-3*x+1', -2) (4) fzero('x^3-3*x+1', 0.5) (5) fzero('x^3-3*x+1', 1.4)

rumor
Download Presentation

第六讲 方程的近似根(解)的求法

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第六讲 方程的近似根(解)的求法

  2. 一、问题背景

  3. 对分法

  4. 2. 迭代法

  5. 2. 迭代法

  6. 3. 牛顿(Newton)法(牛顿切线法)

  7. 3. 牛顿(Newton)法(牛顿切线法)

  8. 4. 求方程根(解)的其它方法 (1) solve('x^3-3*x+1=0') (2) roots([1 0 -3 1]) (3) fzero('x^3-3*x+1', -2) (4) fzero('x^3-3*x+1', 0.5) (5) fzero('x^3-3*x+1', 1.4) (6) linsolve([1, 2, 3; 4, 5, 6; 7, 8, 0], [1, 2, 3]') 具体实验1:对分法

  9. 具体实验1:对分法 syms x fx; a=0;b=1;fx=x^3-3*x+1;x=(a+b)/2;k=0; ffx=subs(fx, 'x', x); if ffx==0; disp(['the root is:', num2str(x)]) else disp('k ak bk f(xk)') while abs(ffx)>0.0001 & a<b; disp([num2str(k), ' ', num2str(a), ' ', num2str(b), ' ', num2str(ffx)]) fa=subs(fx, 'x', a);ffx=subs(fx, 'x', x); if fa*ffx<0 b=x; else a=x; end k=k+1;x=(a+b)/2; end disp([num2str(k), ' ', num2str(a), ' ', num2str(b), ' ', num2str(ffx)]) end

  10. 具体实验2:普通迭代法 syms x fx gx; gx=(x^3+1)/3;fx=x^3-3*x+1; disp('k x f(x)') x=0.5;k=0; ffx=subs(fx, 'x', x); while abs(ffx)>0.0001; disp([num2str(k), ' ', num2str(x), ' ', num2str(ffx)]); x=subs(gx, 'x', x);ffx=subs(fx, 'x', x);k=k+1; end disp([num2str(k), ' ', num2str(x), ' ', num2str(ffx)])

  11. 具体实验3:牛顿法 syms x fx gx; fx=x^3-3*x+1;gx=diff(fx, 'x'); x1=-2;x2=0.5;x3=1.4;k=0; disp('k x1 x2 x3') fx1=subs(fx, 'x', x1);fx2=subs(fx, 'x', x2);fx3=subs(fx, 'x', x3); gx1=subs(gx, 'x', x1);gx2=subs(gx, 'x', x2);gx3=subs(gx, 'x', x3); while abs(fx1)>0.0001|abs(fx2)>0.0001|abs(fx3)>0.0001; disp([num2str(k), ' ', num2str(x1), ' ', num2str(x2), ' ', num2str(x3)]) x1=x1-fx1/gx1;x2=x2-fx2/gx2;x3=x3-fx3/gx3;k=k+1; fx1=subs(fx, 'x', x1);fx2=subs(fx, 'x', x2);fx3=subs(fx, 'x', x3); gx1=subs(gx, 'x', x1);gx2=subs(gx, 'x', x2);gx3=subs(gx, 'x', x3); end disp([num2str(k), ' ', num2str(x1), ' ', num2str(x2), ' ', num2str(x3)])

More Related