# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.analysis.root.univariate

## Class BrentRoot

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

public class BrentRoot
extends Object
implements Uniroot
Brent's root-finding algorithm combines super-linear convergence with reliability of bisection. It uses the secant method or inverse quadratic interpolation whenever possible because they converge faster, but falls back to the more robust bisection method if necessary. Unlike NewtonRoot and HalleyRoot, it does not need the derivatives of the function. Brent's algorithm is the preferred method of choice for root-finding.
Wikipedia: Brent's method
• ### Constructor Summary

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

All Methods
Modifier and Type Method and Description
double solve(UnivariateRealFunction f, double lower, double upper)
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.
• ### Methods inherited from class java.lang.Object

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

• #### BrentRoot

public BrentRoot(double tol,
int maxIterations)
Construct an instance of Brent'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)
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
• #### solve

public double solve(UnivariateRealFunction f,
double lower,
double upper)