com.numericalmethod.suanshu.analysis.uniroot
Class Newton
java.lang.Object
com.numericalmethod.suanshu.analysis.uniroot.Uniroot
com.numericalmethod.suanshu.analysis.uniroot.Newton
public class Newton
- extends Uniroot
Newton–Raphson method is an iterative root finding method for univariate functions.
It has the following properties.
- The function to be solved is assumed to be continuous and smooth (1st derivative exists).
- The solution converges quadratically, when the multiplicity of the root is 1; otherwise, it is linear.
- The solution may fail to converge when the derivative is or is close to 0.
- The solution may fail to converge if the initial guess is far away from the true value.
- See Also:
- Wikipedia: Newton's method
| Fields inherited from class com.numericalmethod.suanshu.analysis.uniroot.Uniroot |
f, tol |
|
Method Summary |
double |
solve(int maxIterations,
double guess)
Solve f(x) = 0 using Newton's algorithm
with an initial guess for the maximum number of iterations. |
double |
solve(int maxIterations,
double lower,
double upper,
double... guess)
The implementation of a specific uniroot finding algorithm. |
| Methods inherited from class com.numericalmethod.suanshu.analysis.uniroot.Uniroot |
solve |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
df
public final UnivariateRealFunction df
- the 1st derivative of
f, df/dx
Newton
public Newton(UnivariateRealFunction f,
UnivariateRealFunction df,
double tol)
- Construct an instance of Newton's root finding algorithm.
- Parameters:
f - the function to be solveddf - the derivative of the functiontol - the convergence tolerance
Newton
public Newton(UnivariateRealFunction f,
double tol)
- Construct an instance of Newton's root finding algorithm.
The first derivative is automatically computed using the central finite difference.
- Parameters:
f - the function to be solvedtol - the convergence tolerance
solve
public double solve(int maxIterations,
double guess)
- Solve
f(x) = 0 using Newton's algorithm
with an initial guess for the maximum number of iterations.
- Parameters:
maxIterations - the maximum number of iterationsguess - an initial guess
- Returns:
- an (approximate) root
solve
public double solve(int maxIterations,
double lower,
double upper,
double... guess)
- Description copied from class:
Uniroot
- The implementation of a specific uniroot finding algorithm.
- Specified by:
solve in class Uniroot
- Parameters:
maxIterations - the maximum number of iterationslower - the lower bound of the bracketing intervalupper - the upper bound of the bracketing intervalguess - an initial guess of the root. It should lie between [lower, upper].
Note that guess is a double[] array.
This signature allows multiple initial guesses for certain types of uniroot algorithms, e.g., Brent's algorithm.
- Returns:
- an approximate root
Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.