牛顿迭代法求多项式在1.5附近的值2*x的3次幂--4x平方+3*x-6=0的实现代码

 更新时间:2020年4月25日 17:47  点击:1737

代码如下所示:

复制代码 代码如下:

#include <stdio.h>
#include <math.h>

int main()
{
   float x,x0,f,f0;
   x=1.5;
   do
   {
    x0=x; 
    f0=((2*x-4)*x+3)*x-6;  //求得在x0处解
    f=(6*x0-8)*x0+3;     // 在(x0 ,f0)处导数
    x=x0-f0/f;    
   }while(fabs(x-x0)>=1e-6);
    printf("the root is %.2f",x0);
   return 0;

}


[!--infotagslink--]

相关文章