Package org.hipparchus.analysis.solvers
Interface BaseUnivariateSolver<F extends UnivariateFunction>
- Type Parameters:
F
- Type of function to solve.
- All Known Subinterfaces:
BracketedUnivariateSolver<F>
,PolynomialSolver
,UnivariateDifferentiableSolver
,UnivariateSolver
- All Known Implementing Classes:
AbstractPolynomialSolver
,AbstractUnivariateDifferentiableSolver
,AbstractUnivariateSolver
,BaseAbstractUnivariateSolver
,BaseSecantSolver
,BisectionSolver
,BracketingNthOrderBrentSolver
,BrentSolver
,IllinoisSolver
,LaguerreSolver
,MullerSolver
,MullerSolver2
,NewtonRaphsonSolver
,PegasusSolver
,RegulaFalsiSolver
,RiddersSolver
,SecantSolver
public interface BaseUnivariateSolver<F extends UnivariateFunction>
Interface for (univariate real) rootfinding algorithms.
Implementations will search for only one zero in the given interval.
This class is not intended for use outside of the Hipparchus
library, regular user should rely on more specific interfaces like
UnivariateSolver
, PolynomialSolver
or UnivariateDifferentiableSolver
.-
Method Summary
Modifier and TypeMethodDescriptiondouble
Get the absolute accuracy of the solver.int
Get the number of evaluations of the objective function.double
Get the function value accuracy of the solver.double
Get the relative accuracy of the solver.double
Solve for a zero in the vicinity ofstartValue
.double
Solve for a zero root in the given interval.double
Solve for a zero in the given interval, start atstartValue
.
-
Method Details
-
getEvaluations
int getEvaluations()Get the number of evaluations of the objective function. The number of evaluations corresponds to the last call to theoptimize
method. It is 0 if the method has not been called yet.- Returns:
- the number of evaluations of the objective function.
-
getAbsoluteAccuracy
double getAbsoluteAccuracy()Get the absolute accuracy of the solver. Solutions returned by the solver should be accurate to this tolerance, i.e., if ε is the absolute accuracy of the solver andv
is a value returned by one of thesolve
methods, then a root of the function should exist somewhere in the interval (v
- ε,v
+ ε).- Returns:
- the absolute accuracy.
-
getRelativeAccuracy
double getRelativeAccuracy()Get the relative accuracy of the solver. The contract for relative accuracy is the same asgetAbsoluteAccuracy()
, but using relative, rather than absolute error. If ρ is the relative accuracy configured for a solver andv
is a value returned, then a root of the function should exist somewhere in the interval (v
- ρv
,v
+ ρv
).- Returns:
- the relative accuracy.
-
getFunctionValueAccuracy
double getFunctionValueAccuracy()Get the function value accuracy of the solver. Ifv
is a value returned by the solver for a functionf
, then by contract,|f(v)|
should be less than or equal to the function value accuracy configured for the solver.- Returns:
- the function value accuracy.
-
solve
double solve(int maxEval, F f, double min, double max) throws MathIllegalArgumentException, MathIllegalStateException Solve for a zero root in the given interval. A solver may require that the interval brackets a single zero root. Solvers that do require bracketing should be able to handle the case where one of the endpoints is itself a root.- Parameters:
maxEval
- Maximum number of evaluations.f
- Function to solve.min
- Lower bound for the interval.max
- Upper bound for the interval.- Returns:
- a value where the function is zero.
- Throws:
MathIllegalArgumentException
- if the arguments do not satisfy the requirements specified by the solver.MathIllegalStateException
- if the allowed number of evaluations is exceeded.
-
solve
double solve(int maxEval, F f, double min, double max, double startValue) throws MathIllegalArgumentException, MathIllegalStateException Solve for a zero in the given interval, start atstartValue
. A solver may require that the interval brackets a single zero root. Solvers that do require bracketing should be able to handle the case where one of the endpoints is itself a root.- Parameters:
maxEval
- Maximum number of evaluations.f
- Function to solve.min
- Lower bound for the interval.max
- Upper bound for the interval.startValue
- Start value to use.- Returns:
- a value where the function is zero.
- Throws:
MathIllegalArgumentException
- if the arguments do not satisfy the requirements specified by the solver.MathIllegalStateException
- if the allowed number of evaluations is exceeded.
-
solve
Solve for a zero in the vicinity ofstartValue
.- Parameters:
f
- Function to solve.startValue
- Start value to use.maxEval
- Maximum number of evaluations.- Returns:
- a value where the function is zero.
- Throws:
MathIllegalArgumentException
- if the arguments do not satisfy the requirements specified by the solver.MathIllegalStateException
- if the allowed number of evaluations is exceeded.
-