Package dev.nm.analysis.root.univariate
Class BrentRoot
- java.lang.Object
-
- dev.nm.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. UnlikeNewtonRootandHalleyRoot, it does not need the derivatives of the function. Brent's algorithm is the preferred method of choice for root-finding.- See Also:
- Wikipedia: Brent's method
-
-
Constructor Summary
Constructors Constructor Description BrentRoot(double tol, int maxIterations)Construct an instance of Brent's root finding algorithm.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublesolve(UnivariateRealFunction f, double lower, double upper)doublesolve(UnivariateRealFunction f, double lower, double upper, double... guess)Search for a root, x, in the interval [lower, upper] such that f(x) = 0.
-
-
-
Method Detail
-
solve
public double solve(UnivariateRealFunction f, double lower, double upper, double... guess)
Description copied from interface:UnirootSearch for a root, x, in the interval [lower, upper] such that f(x) = 0.- Specified by:
solvein interfaceUniroot- Parameters:
f- a univariate functionlower- the lower bound of the bracketing intervalupper- the upper bound of the bracketing intervalguess- an initial guess of the root within [lower, upper]. Note thatguessis adouble[]. 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)
-
-