Using Newton's Iterative method to find the root of the following equation near 1.5:2x^3-4x^2+3x-6=0
As for the Newton iterative method, in the course of computational methods, the basic formula is:
xn+1=xn-f (Xn)/F *(Xn) xn+1 is the n+1 iteration result,Xn is the nth iteration result,f * ( Xn) is the Guide function value of f (Xn) .
Basic steps:
The first step is to rewrite the equation as polynomial f (x) =2x^3-4x^2+3x-6, given initial value X0;
The second step takes Xn into the iteration formula xn+1=xn-f (Xn)/F *(Xn) to find the xn+1
The third step is to determine whether the precision fabs (xn+1-Xn) Meet the requirements , the output is satisfied, or return to the previous step;
The following code is given:
#include <stdio.h>
#include <math.h>
int main ()
{
int i=0;
Double x1=1.5,x2=0;//iteration Initial value while
(Fabs (x2-x1) >=1e-5)
{
x1=x1-(2*x1*x1*x1-4*x1*x1+3*x1-6)/(6*x1* X1-8*X1+3);
X2=x1-(2*x1*x1*x1-4*x1*x1+3*x1-6)/(6*x1*x1-8*x1+3);
i++;
printf ("%d iterations x1=%9.8f\tx2=%9.8f\n", i,x1,x2);
}
printf ("\nx=%9.8f\t total iterations:%d \ n", x2,i);
return 0;
}
The test results are given below: