An example iteration Introduction Newton Iterative Method Newton Iterative method Introduction Simple deduction Taylor Formula derivation extension and application
an instance
Java implementation of the Sqrt class and method public
class sqrt {public
static double sqrt (double n)
{
if (n<0) return Double.NaN;
Double err = 1e-15;
Double t = n;
while (Math.Abs (t-n/t) > err*t)
t = (n/t + t)/2;
return t;
}
public static void Main (string[] args)
{
sqrt a = new sqrt ();
System.out.println (A.SQRT (2));
}
}
The solution result of the square root of 2
>>1.414213562373095
Introduction to Iterations
Iteration, is a numerical method, which refers to the method of gradually approaching the real value from an initial value through iterative process.
The opposite is the direct method, that is, through the construction of analytic solutions, one step to find a way to solve the problem.
Usually, we always like to get the result of the problem in one step, so the direct method is always a priority.
However, when encountering complex problems, especially in the unknown quantity, the nonlinear equation, can not get a direct solution (such as five-time equation and no analytic solution).
At this point, we need to use an iterative algorithm to approach the problem and get the answer.
Iterative algorithms, you usually need to consider the following questions:
-Determine iteration variables
-Determine the iterative formula
-Determination of iteration termination conditions Introduction to Newton Iterative method Newton Iterative method
Newton iterative method to solve the problem of the root x x
F (x) =0 f (x) = 0
Here's how to solve it:
Xn+1=xn−f (xn) f′ (xn) x_{n+1} = x_n-\frac{f (x_n)}{f ' (X_n)}
method, the iteration variable is the root x x, the iterative relationship is as above, and the iteration termination condition is |f (xn) −0|<error \vert f (x_n)-0 \vert.
The conditions to be met by Newton's iterative method are:
f′ (x) F ' (x) is continuous, and the 0 points x x to be asked are isolated.
So, there is an area around 0 x x, as long as the initial value x0 X_0 is in this neighborhood, then Newton's method must converge.
Also, if f′ (x) F ' (x) is not 0, then the Newton method will have the attribute of a square convergence, that is, each iteration, the effective multiplier of the result will increase by one times. Simple Derivation
By
f′ (xn) =dydx=f (xn) xn−xn+1