牛顿迭代法求方程2*x*x*x4*x*x+3*x6=0在0.5附近的根

 1 #include<iostream>
 2 #include<math.h>
 3 using namespace std;
 4 
 5 //牛顿迭代法求方程2*x*x*x-4*x*x+3*x-6=0在0.5附近的根。
 6 void ND_method(double x)
 7 {
 8     double x0,f,f1;
 9     do
10     {
11         x0=x;
12         f=exp(x0)*x0-1;
13         f1=exp(x0)+exp(x0)*x0;
14         x=x0-f/f1;
15     }while(fabs(x-x0)>=1e-5);
16 
17     cout<<"the root is:" << x << endl;
18 }
19 
20 void main()
21 {
22     double x;
23     x=0.5;
24     ND_method(x);
25 }
原文地址:https://www.cnblogs.com/uniqid/p/4152424.html