Intuitive understanding of Newton iterative method

Source: Internet
Author: User

Overview

Newton Iterative method is a numerical algorithm, which can be used to find 0 points of a function. The idea is to abstract the function into a straight line, step by step with the estimated approximation function of 0 points.

The approximation speed is very efficient, and it is often possible to obtain very accurate results in more than 10-step iterations.

Lemma

Consider a line in the following coordinate system \ (xoy\) :

The value at \ (x=x_0\) is a value of \ (y_0\). So what is the \ (x\) coordinate \ (a\) of the intersection of this line and the \ (x\) axis?

The analytic formula for this line is \ (y=kx+b\), then there is
\[y_0=kx_0+b\]

That
\[b=y_0-kx_0\]

Order \ (y=0\), get the equation
\[kx+y_0-kx_0=0\]

Solution to
\[x=\frac{kx_0-y_0}{k}\]

That

\[x=x_0-\frac{y_0}{k}\]

Newton Iterative Method

We formally began using Newton's iterative method to find the function \ (f (x) \) 0 points.

problem : try \ (\sqrt{2}\) approximate value.

The original proposition is equivalent to the 0 points of the function \ (f (x) =x^2-2\) .

First step: Guess the initial value

First we randomly guess a value. Set it to \ (x=4\) .

Step Two: Iteration

Over \ ((x,f (x)) \) point for \ (f (x) \) tangent, get:

According to the geometric meaning of the derivative, the slope of this line is \ (f ' (x) \), then according to the conclusion we obtained earlier, the function and the \ (x\) coordinates of the intersection of the \ (x\) axis are
\[x ' =x-\frac{f (x)}{f ' (x)}\]

According to the best estimate, if the derivative does not change, the 0 point should be in that position. Then we make \ (x=x '), which is called an iteration.

Back to the example. \ (f (x) =x^2-2\), then \ (f ' (x) =2x\):
\[x ' =x-\frac{f (x)}{f ' (x)}=x-\frac{x^2-2}{2x}=\frac{x}{2}+\frac{1}{x}\]

Each time you replace \ ( \frac{x}{2}+\frac{1}{x}\) with \ (x\), repeat the above process:

As you can see, the exact value of the \ (20\) bit is obtained with just six iterations.

The procedure is as follows:

#include<iostream>#include<cstdio>#include<cmath>using namespace std;const double eps=1e-10;double a,x;double f(double x){return x*x-a;}double df(double x){return 2*x;}int main(){    scanf("%lf",&a);    x=1;    while(fabs(f(x))>=eps)x-=f(x)/df(x);    

Intuitive understanding of Newton iterative method

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.