Spread f (x) around X0 expansions series f (x) = f (x0) +f ' (x0) (x-x0) +f "(x0)/2!* (x-x0) ^2+ ... Then take its linear part, as the nonlinear equation f (x) = 0
Approximate equation, that is, the first two of Taylor's expansion, there are
f (x) = F ' (x0) x-x0*f ' (x0) + f (x0) = 0
F ' (x0) x = X0*f ' (x0)-F (x0)
x = x0-f (x0)/F ' (x0)
Get an iterative sequence of Newton:
->x (n+1) = x (n)-f (x (n))/F ' (x (n))
Example: Finding the equation f (x) = 2*x^3-4*x^2+3*x-6 at the root near x = 1.5, and finding the total number of iterations and the approximate root of each time.
#include <iostream>#include<cmath>using namespacestd;DoubleFUN1 (Doublex) { return 2*x*x*x-4*x*x+3*x-6;}DoubleFun2 (Doublex) { return 6*x*x-8*x+3;}intMain () {Doublef1,f2,x,d; intCNT =0; X= -; Do{F1= FUN1 (x);//the value of the equationF2 = fun2 (x);//derivative of the equationD = f1/f2;//"Slope"X-= D;//Update the value of the equationCNT + +; printf ("the value of the first%d iteration equation is:%lf\n", CNT,FUN1 (x)); cout<<"the current approximate root is:"; printf ("%.lf\n", x); } while(Fabs (d) > 1e-5); cout<<"Total number of iterations:"<<cnt<<Endl; cout<<"The final approximate root is:"; printf ("%lf\n", x); return 0;}
Calculation method-c/c++ Newton iterative method for solving the approximate root of nonlinear equation