a=2; b=4; x=a:b; f = @(x)(x-1).^3-3*x+2; c=(a+b)./2; while abs(b-a)>1e-10%精度0.0005 if f(c)*f(b)<0 a=c; else b=c; end c=(a+b)./2; x=c; end disp('输出结果:'); fprintf('\n x = %.5f, f(x) = %.5f \n', x, f(x));