Newton iteration method to find the value of the polynomial around 1.5 2 * x to the third 4x squared + 3 * x 6 = 0

  • 2020-04-01 23:26:31
  • OfStack

The code is as follows:


#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;  //Find the solution at x0
    f=(6*x0-8)*x0+3;     //Derivative at (x0, f0)
    x=x0-f0/f;     
   }while(fabs(x-x0)>=1e-6);
    printf("the root is %.2f",x0);
   return 0;
}


Related articles: