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 the change, as long as the X1 and X2 can enter the cycle, you can complete the 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 in detail.
}
printf ("Equation: 3*x*x*x-2*x*x-16=0\n");
printf ("Solution: x=%.4lf\n", x2);
}
/*
============================================================
Review: Newton iterative method is very good grasp, practical strong! When programming, you only need to obtain the guide function, the original function and
The solution of the equation can be obtained by substituting the guiding function in the program!
============================================================
*/
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Basic algorithm of C language 25-Newton iterative method for approximate root of equation