Class BrentSolver
java.lang.Object
org.apache.commons.math3.analysis.solvers.BaseAbstractUnivariateSolver<UnivariateFunction>
org.apache.commons.math3.analysis.solvers.AbstractUnivariateSolver
org.apache.commons.math3.analysis.solvers.BrentSolver
- All Implemented Interfaces:
BaseUnivariateSolver<UnivariateFunction>, UnivariateSolver
This class implements the
Brent algorithm for finding zeros of real univariate functions.
The function should be continuous but not necessarily smooth.
The
solve method returns a zero x of the function f
in the given interval [a, b] to within a tolerance
2 eps abs(x) + t where eps is the relative accuracy and
t is the absolute accuracy.
The given interval must bracket the root.
The reference implementation is given in chapter 4 of
Algorithms for Minimization Without Derivatives, Richard P. Brent, Dover, 2002
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a solver with default absolute accuracy (1e-6).BrentSolver(double absoluteAccuracy) Construct a solver.BrentSolver(double relativeAccuracy, double absoluteAccuracy) Construct a solver.BrentSolver(double relativeAccuracy, double absoluteAccuracy, double functionValueAccuracy) Construct a solver. -
Method Summary
Modifier and TypeMethodDescriptionprotected doubledoSolve()Method for implementing actual optimization algorithms in derived classes.Methods inherited from class BaseAbstractUnivariateSolver
computeObjectiveValue, getAbsoluteAccuracy, getEvaluations, getFunctionValueAccuracy, getMax, getMaxEvaluations, getMin, getRelativeAccuracy, getStartValue, incrementEvaluationCount, isBracketing, isSequence, setup, solve, solve, solve, verifyBracketing, verifyInterval, verifySequenceMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BaseUnivariateSolver
getAbsoluteAccuracy, getEvaluations, getFunctionValueAccuracy, getMaxEvaluations, getRelativeAccuracy, solve, solve, solve
-
Constructor Details
-
BrentSolver
public BrentSolver()Construct a solver with default absolute accuracy (1e-6). -
BrentSolver
Construct a solver.- Parameters:
absoluteAccuracy- Absolute accuracy.
-
BrentSolver
Construct a solver.- Parameters:
relativeAccuracy- Relative accuracy.absoluteAccuracy- Absolute accuracy.
-
BrentSolver
Construct a solver.- Parameters:
relativeAccuracy- Relative accuracy.absoluteAccuracy- Absolute accuracy.functionValueAccuracy- Function value accuracy.- See Also:
-
-
Method Details
-
doSolve
protected double doSolve() throws NoBracketingException, TooManyEvaluationsException, NumberIsTooLargeExceptionMethod for implementing actual optimization algorithms in derived classes.- Specified by:
doSolvein classBaseAbstractUnivariateSolver<UnivariateFunction>- Returns:
- the root.
- Throws:
NoBracketingException- if the initial search interval does not bracket a root and the solver requires it.TooManyEvaluationsException- if the maximal number of evaluations is exceeded.NumberIsTooLargeException
-