迭代法求解
用迭代法求方程在1.5附近的根2x^3-4x^2+3x-6=0
我是这样写的,但运行不了。那位高手给指点一下吧
main()
{
float x,x0;
x=1.5;
x0=x-(2x^3-4x^2+3x-6)/(6x^2-8x+3);
while (fabs(x-x0)>1e-5)
{
x=x0;
x0=x-(2x^3-4x^2+3x-6)/(6x^2-8x+3);
printf("%f\n",x0);
}
getch();
}
不加#include"math.h",fabs的值不正确。最后的结果是1.999978