Basic algorithm of C language 25-Newton iterative method for approximate root of equation

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.