Root-Finding:Bisection method

用二分法找出的根

function y=funcbisect01(x);
y=3*x^5-2*x^3+6*x-8;
x1=1;
x2=2; tol=0.00001;
while (abs(x1-x2)>tol)
      f1=funcbisect01(x1);
      f2=funcbisect01(x2);
      xm=(x1+x2)/2;
      fm=funcbisect01(xm);
      if (f1*fm<0)
         x2=xm;
      else
         x1=xm;
      end
end

 

posted @ 2013-05-22 00:36  StanleyWu  阅读(247)  评论(0编辑  收藏  举报