SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.analysis.uniroot
Class Halley

java.lang.Object
  extended by com.numericalmethod.suanshu.analysis.uniroot.Uniroot
      extended by com.numericalmethod.suanshu.analysis.uniroot.Halley

public class Halley
extends Uniroot

Halley's method is an iterative root finding method for a univariate function with a continuous second derivative, i.e., a C2 function.

It has the following properties.

See Also:
Wikipedia: Halley's method

Nested Class Summary
 
Nested classes/interfaces inherited from class com.numericalmethod.suanshu.analysis.uniroot.Uniroot
Uniroot.NoRootFoundException
 
Field Summary
 UnivariateRealFunction d2f
          the 2nd derivative of f, d2f/dx2
 UnivariateRealFunction df
          the 1st derivative of f, df/dx
 
Fields inherited from class com.numericalmethod.suanshu.analysis.uniroot.Uniroot
f, tol
 
Constructor Summary
Halley(UnivariateRealFunction f, double tol)
          Construct an instance of Halley's root finding algorithm.
Halley(UnivariateRealFunction f, UnivariateRealFunction df, UnivariateRealFunction d2f, double tol)
          Construct an instance of Halley's root finding algorithm.
 
Method Summary
 double solve(int maxIterations, double guess)
          Solve f(x) = 0 using Halley's algorithm with an initial guess for the maximum number of iterations.
 double solve(int iterations, 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


d2f

public final UnivariateRealFunction d2f
the 2nd derivative of f, d2f/dx2

Constructor Detail

Halley

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

Parameters:
f - the function to be solved
df - the first derivative of the function
d2f - the second derivative of the function
tol - the convergence tolerance

Halley

public Halley(UnivariateRealFunction f,
              double tol)
Construct an instance of Halley's root finding algorithm. The first and second derivatives are 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 Halley'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 iterations,
                    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:
iterations - 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.