已知方程x2-x-2=0在区间【1,4】内有一个实根。以下程序中函数rootY采用二分法求方程f(x)=0在区间【a,b】内的一个实根,当|f(x)|<0.000001时,x即为所求的近似实根。
while(fabs(f(m))>1e-6{
if(1>0)
a=m;
else
b=m;
2;
}
return3;
}
int main(void)
{
printf("/n One root is %if\n",root(1,4));
}
