Newton-Raphson method

Source: Internet
Author: User

I. Basic concepts of iterative methods:

Iteration is a common algorithm design method. Iteration is a process of constantly replacing the old value of a variable with a new value, or the new value of a variable is delivered by the old value. The iteration mechanism requires the following elements:

① Iteration expression;

② Iteration variable;

③ Initial iteration values;

④ Iteration termination condition.

When a problem can be solved by an initial value using an iterative expression for repeated iterations, it can be described with highly efficient repetition programs. Therefore, iteration is also implemented using a cyclic structure, the operation that needs to be repeated is to constantly calculate its new value from the old value of a variable. The basic format is as follows:

Grant initial values to iteration variables;

Loop statement

{

Computing iteration;

The new value replaces the old value;

}

The word "iteration" appears inWikipediaIs defined as follows:

IterationIt is a process of finding a series of approximate solutions to solve the problem (generally solving equations or equations) from an initial estimate in numerical analysis. The methods used to achieve this process are collectively referred toIteration Method(Iterative Method ).

What corresponds to the iteration method is a direct method (or a single solution), that is, a one-time solution to the problem, for example, solving the equation through the open party.X2 = 4. If possible, the direct solution is always preferred. However, when a complex problem occurs, especially when the number of unknown equations is large and the equations are non-linear, we cannot find a direct solution (for example, five or more algebra equations do not parse the Abell theorem ), at this time, you may be able to seek the approximate solution of the equation (Group) through iterative method. , See

The most common iteration method is the Newton method. Others include the shortest descent method, bounded iteration method, variable-scale iteration method, least square method, linear programming, nonlinear programming, symmetric method, penalty function method, slope projection method, genetic algorithm, simulated annealing, etc..

The Newton Iteration Method is a commonly used iteration method.

Newton's method(Newton's method) Is also calledNewton-lafson Method(Newton-Raphson method), Which is an approximate method for solving equations in real and complex fields. Method Use FunctionF(X) To find the equation.F(X) = 0 root.

First, select a functionF(X) ZeroX0, calculate the correspondingF(X0) and tangent SlopeF'(X0) (hereF'Indicates a function.FDerivative ). Then we calculate the pass through point (X0,F(X0) and the slope isF'(X0) Straight Line andXThe intersectionXCoordinate, that is, the solution to the following equation:

We willXCoordinates are namedX1, usuallyX1 RatioX0 is closer to the equationF(X) = 0. Therefore, we can useX1. Start the next iteration. The iteration formula can be simplified as follows:

It has been proved that ifF'Is continuous and the zero point to be obtainedXIs isolated.XThere is a region around, as long as the initial valueX0 is located in the adjacent area, so the Newton method will converge. And, ifF'(X) If it is not 0, the Newton method will have the square convergence performance. Roughly speaking, this means that the number of valid results for each iteration will be doubled. An example of an Newton method execution process.

Example 1

EquationsF(X) = Cos (X) −X3. Evaluate on both sides.F'(X) = −Sin (X) −3X2. Because cos (X) ≤ 1 (for allX), AndX3> 1 (X> 1) We can see that the root of the equation is between 0 and 1. FromX0 = starting from 0.5.

X_1 & = & x_0-\ frac {f (x_0)} {f' (x_0)} & = & 0.5-\ frac {\ cos (0.5) -0.5 ^ 3} {-\ sin (0.5)-3 \ times 0.5 ^ 2} & = & 1.112141637097 \\

X_2 & = & x_1-\ frac {f (x_1)} {f' (x_1)} & = & \ vdots & = & \ underline {0.} 909672693736 \\

X_3 & =& \ vdots & =& \ underline {0.86} 7263818209 \\

X_4 & =& \ vdots & =& \ underline {0.86547} 7135298 \\

X_5 & = & \ vdots & = & \ underline {0.8654740331} 11 \\

X_6 & = & \ vdots & = & \ underline {0.865474033102}

\ End {matrix} "src =" http://upload.wikimedia.org/math/7/3/ B /73bde5bc53b56decd268e95088364840.png ">

Example 2

The Newton method can also be used to expand functions with Taylor.

Evaluate the m Root of.

X M-A = 0

SetF(X) =X MA,F'(X) =M X M−1

The m Root of a is also the solution of x,

Iteration by Newton method:

(Or)

In addition, the Newton Iteration MethodBaidu entryDefinition in: click here

2. Simple instances

Example 1:

Evaluate the series of the Fibonacci statements.

, 34... this is a series of Fibonacci.

Input: integer n (n> = 3)

Output: n Fibonacci Series

Algorithm Design: Basic Iterative Method

That is

F (1) = f (2) = 1;

F (n) = f (n-1) + f (n-2); (n> = 3)

The C ++ implementation is as follows:

   1. #include<iostream>     2. using namespace std;     3. void f(int n)     4. {     5.     int f,f1,f2;     6.     f1=f2=1;     7.     cout<<f1<<" "<<f2<<" ";     8.     for(int i=3;i<=n;i++)     9.     {    10.         f=f1+f2;    11.         cout<<f<<" ";    12.         f1=f2;    13.         f2=f;    14.     }    15.     cout<<endl;    16. }    17. int main()    18. {    19.     int n;    20.     cin>>n;    21.     f(n);    22.     return 0;    23. }  

10
1 1 2 3 5 8 13 21 34 55
Press any key to continue

Example 2:

Compile a program to find the root of the following equation:

X Percentile-5x ² + 6x-80 = 0

Algorithm Design: Newton Iteration Method

Using the Newton iteration formula x (n + 1) = x (n)-f (x (n)/F' (x (n ));

The loop body is:

For (int I = 0; I <n; I ++)
{
X1 = x0-f (x0)/df (x0 );
X0 = x1;
}

N indicates the number of iterations. The larger the value, the more precise the root value. x0 indicates any value within the range of the root value of the equation as the condition for initial iteration.

The C ++ implementation is as follows:

   1. #include<iostream>     2. using namespace std;     3. float f(float x)     4. {     5.     float y;     6.     y=x*x*x-5.0*x*x+16.0*x-80.0;     7.     return y;     8. }     9. float df(float x)    10. {    11.     float y;    12.     y=3.0*x*x-10.0*x+6;    13.     return y;    14. }    15. int main()    16. {    17.     float x0,x1;    18.     int n;    19.     cout<<"ÊäÈëx0:";    20.     cin>>x0;    21.     cout<<"µü´ú´ÎÊý:";    22.     cin>>n;    23.     for(int i=0;i<n;i++)    24.     {    25.         x1=x0-f(x0)/df(x0);    26.         x0=x1;    27.     }    28.     cout<<"·½³ÌµÄ¸ù:x="<<x0<<endl;    29.     return 0;    30. }  

Input x0: 2
Iterations: 10
The root of the equation: x = 5.15874
Press any key to continue

Input x0: 2
Iterations: 100
Root of the equation: x = 5
Press any key to continue

 

Original: http://blog.csdn.net/iamskying/archive/2009/08/22/4471071.aspx

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.