# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.analysis.root.univariate

## Class HalleyRoot

• java.lang.Object
• com.numericalmethod.suanshu.analysis.root.univariate.HalleyRoot
• All Implemented Interfaces:
Uniroot

public class HalleyRoot
extends Object
implements 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.
• The function to be solved is assumed to be continuous and smooth (1st derivative exists).
• The 1st derivative is assumed to be continuous and smooth (2nd derivative exists).
• The rate of convergence for solution is cubic.
Wikipedia: Halley's method
• ### Constructor Summary

Constructors
Constructor and Description
HalleyRoot(double tol, int maxIterations)
Construct an instance of Halley's root finding algorithm.
• ### Method Summary

All Methods
Modifier and Type Method and Description
double solve(UnivariateRealFunction f, double guess)
double solve(UnivariateRealFunction f, double lower, double upper, double... guess)
Search for a root, x, in the interval [lower, upper] such that f(x) = 0.
double solve(UnivariateRealFunction f, UnivariateRealFunction df, UnivariateRealFunction d2f, double guess)
Search for a root, x, in the interval [lower, upper] such that f(x) = 0.
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### HalleyRoot

public HalleyRoot(double tol,
int maxIterations)
Construct an instance of Halley's root finding algorithm.
Parameters:
tol - the convergence tolerance
maxIterations - the maximum number of iterations
• ### Method Detail

• #### solve

public double solve(UnivariateRealFunction f,
double lower,
double upper,
double... guess)
throws NoRootFoundException
Description copied from interface: Uniroot
Search for a root, x, in the interval [lower, upper] such that f(x) = 0.
Specified by:
solve in interface Uniroot
Parameters:
f - a univariate function
lower - the lower bound of the bracketing interval
upper - the upper bound of the bracketing interval
guess - an initial guess of the root within [lower, upper]. Note that guess is a double[]. This signature allows multiple initial guesses for certain types of uniroot algorithms, e.g., Brent's algorithm.
Returns:
an approximate root
Throws:
NoRootFoundException - when the search fails to find a root
• #### solve

public double solve(UnivariateRealFunction f,
double guess)
throws NoRootFoundException
Throws:
NoRootFoundException
• #### solve

public double solve(UnivariateRealFunction f,
UnivariateRealFunction df,
UnivariateRealFunction d2f,
double guess)
throws NoRootFoundException
Search for a root, x, in the interval [lower, upper] such that f(x) = 0.
Parameters:
f - a univariate function
df - the first order derivative
d2f - the second order derivative
guess - an initial guess of the root within [lower, upper]
Returns:
an approximate root
Throws:
NoRootFoundException - when the search fails to find a root