SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.analysis.uniroot
Class Newton

java.lang.Object
  extended by com.numericalmethod.suanshu.analysis.uniroot.Uniroot
      extended by 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.

See Also:
Wikipedia: Newton's method

Nested Class Summary
 
Nested classes/interfaces inherited from class com.numericalmethod.suanshu.analysis.uniroot.Uniroot
Uniroot.NoRootFoundException
 
Field Summary
 UnivariateRealFunction df
          the 1st derivative of f, df/dx
 
Fields inherited from class com.numericalmethod.suanshu.analysis.uniroot.Uniroot
f, tol
 
Constructor Summary
Newton(UnivariateRealFunction f, double tol)
          Construct an instance of Newton's root finding algorithm.
Newton(UnivariateRealFunction f, UnivariateRealFunction df, double tol)
          Construct an instance of Newton's root finding algorithm.
 
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
 

Field Detail

df

public final UnivariateRealFunction df
the 1st derivative of f, df/dx

Constructor Detail

Newton

public Newton(UnivariateRealFunction f,
              UnivariateRealFunction df,
              double tol)
Construct an instance of Newton's root finding algorithm.

Parameters:
f - the function to be solved
df - the derivative of the function
tol - 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 solved
tol - the convergence tolerance
Method Detail

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 iterations
guess - 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 iterations
lower - the lower bound of the bracketing interval
upper - the upper bound of the bracketing interval
guess - 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

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.