Newton Iterative Method!
/*
============================================================
Title: Newton Iterative method is used to solve the approximate solution of 3*x*x*x-2*x*x-16=0.
============================================================
*/
#include <stdio.h>
#include <math.h>
#define E 1e-8
Double HS (Double x)
{
return (3*X*X*X-2*X*X-16);Original function
}
Double DHS (double x)
{
return (9*X*X-4*X);Guide function
}
void Main ()
{
Double x1=1.0,x2;
x2=x1+1.0;
while (Fabs (x2-x1) >e)No matter how it changes, only to X1 and X2 can enter the cycle, it can be completed solution. That is x2!=x1.
{
x1=x2;
X2=X1-HS (x1)/dhs (x1);This is the first two items to be torn down with the Taylor display.
Readers can find the relevant literature to understand the specific.
}
printf ("Equation: 3*x*x*x-2*x*x-16=0\n");
printf ("Solution: x=%.4lf\n", x2);
}
/*
============================================================
Comment: Newton's iterative method is very well mastered. Strong Usability! Programming requires only the derivative function. The original function and
The solution of the equation can be obtained by substituting the guiding function in the program.
============================================================
*/
Basic algorithm of C language 25-Newton iterative method for approximate root of equation