function [F] = f(x)
F=x-2^-x;
end
function [] =cal()
tol=1e-8;
x0=0;
x1=1;
[k,c]=half_1(x0,x1,tol)
end
function [k, c]=half_1(a, b, tol)
c=(a+b)/2; k=1;
m=1+round((log(b-a)-log(2*tol))/log(2));
while k<=m
if f(c)==0
c=c;
return;
elseif f(a)*f(c)<0
b=(a+b)/2;
else
a=(a+b)/2;
end
c=(a+b)/2; k=k+1;
end
二分法 matlab求方程的根
于 2022-04-29 16:39:59 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)