牛顿迭代法求得的值代入方程不为0,哪里错了?
#include<stdio.h>#include<math.h>
void main()
{double f(double x);
double f1(double x);
double eps,x0,x1=1;
printf("请输入要求的精度:");
scanf("%lf",&eps);
do
{x0=x1;
x1=x0-f(x0)/f1(x0);
}while(fabs(x1-x0>eps));
printf("所求的根为:%lf\n",x1);
}
double f(double x)
{double y;
y=x*x+2*x+1;
return y;}
double f1(double x)
{double y;
y=2*x+2;
return y;}