WebCab Functions for COM v2.0

EquationSolver.NewtonRaphsonFailSafe Method (Double, Double, Double, Int64)

Fail-Safe Newton-Raphson Method in which the initial point and maximum number of iterations must be given.

public double NewtonRaphsonFailSafe(
   double beginningOfInterval,
   double endOfInterval,
   double precision,
   long maxIterations
);

Parameters

beginningOfInterval
The coordinate value of the lower bound of the interval over which a solution to the equation is known to exist.
endOfInterval
The coordinate value of the upper bound of the interval over which a solution to the equation is known to exist.
precision
The level of precision of a solution required before it is returned and the algorithm exists. That is, if the precision is set to 0.0001 then the result will be returned to within 0.0001 etc, assuming that an solution to this level of accuracy is found within the maximum number of iterations allowed. A reasonable value to take for this parameter is 0.00001. For smaller values of the precision parameter the solution will be more precise however the procedure will require more iterations and hence time in order to find the solution to the desired level of accuracy. Generally speaking, if using if for the precision 0.00001, we require t ms; then using a precision of 0.001, will take 0.6t ms, and using a precision of 0.0000001, will take 1.4t.
maxIterations
The maximum number of iterations performed before the result will be returned. If the method fails for a given level of precision you may need to increase the maximum number of iterations.

Return Value

A solution of the equation set using SetFunction, to the given level of precision required or NaN if the algorithm fails to produce such a solution.

Remarks

Further Details

This method combines the Interval Bisection method and the Newton-Raphson method, by taking a bisection step whenever the Newton-Raphson takes the solution off bounds or is not bracketing the solution fast enough. This approach in many ways combines the best of the Bisection and Newton-Raphson method and unlike the pure Newton-Raphson methods is certain to converge. For further details on the bisection algorithm we refer the reader to the Bisection API Docs, below we provide further details on the Newton-Raphson algorithm.

The Newton-Raphson method is the mostly widely used method for finding the roots of an equation of one real variable. The Newton-Raphson approach does not depend on bracketing the solution (unlike the other algorithms provided) and instead will locally approximate the equation by a linear equation and then solve this approximation which will provide the next point within the iterative sequence which will lead to a solution. The successful application of this approach will depend on:

  1. Provide Initial Point: When applying this approach an initial point (rather than a bracketing interval) will need to be provided, and moreover the particular point selected will determine the speed and effect whether or not the algorithm converges. As a rule of thumb the closer to the solution the initial point can be chosen the more likely the convergence and the faster that convergence will be.
  2. Evaluation of the Derivative: The Newton-Raphson approach requires that the derivative of the equation considered is evaluated at a sequence of points. The reason for this is that the derivative is used to find the linear approximation of the equation at a given point.

Assuming that an initial starting point x0, from which a solution to an equation ƒ(x)=0 has been given, the Newton-Raphson method will produce a sequence of points: x0, x1, ..., xn,..., using the iterative formula:

xn+1 = xn - ƒ(xn) / ƒ'(xn),

where ƒ'(xn) is the derivative of the equation ƒ, evaluated at the point xn. The idea behind the above formula is to draw the tangent to the curve at xn and then trace this line down to the x-axis which will give us our next estimate of the solution xn+1. By repeating this process the resulting sequence of points will converge to a solution of the equation in question.

When to use this Approach?

As mentioned above the Fail Safe Newton-Raphson method in many ways offers a good balance between the speed of the Newton-Raphson method and the security of the bisection method. Though the method may not be as fast as a pure Newton-Raphson approach it is certain to converge once a bracketing interval has been established. As is the case with a pure Newton-Raphson approach it requires that the derivative is evaluated at a sequence of points and therefore often the viability of this approach will depend on how expensive it is to evaluate the derivative for the equation being considered. However, if the derivative is not particularly expensive to evaluate then this approach is ideal for those who want almost the speed of the Newton-Raphson approach with the security of convergence of the Bisection approach.

See Also

EquationSolver Class | WebCab.COM.Math.EquationSolver Namespace | EquationSolver.NewtonRaphsonFailSafe Overload List | Newton-Raphson Fail Safe - Applies the Newton-Raphson method without the need to provide the initial starting point or maximum number of iterations.