Using Newton's Iterative method to find the root of the following equation near 1.5:2x^3-4x^2+3x-6=0

Source: Internet
Author: User

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:



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.