org.hipparchus.analysis.solvers

## Interface BracketedRealFieldUnivariateSolver<T extends CalculusFieldElement<T>>

• Type Parameters:
T - the type of the field elements
All Known Implementing Classes:
FieldBracketingNthOrderBrentSolver

public interface BracketedRealFieldUnivariateSolver<T extends CalculusFieldElement<T>>
Interface for (univariate real) root-finding algorithms that maintain a bracketed solution. There are several advantages to having such root-finding algorithms:
• The bracketed solution guarantees that the root is kept within the interval. As such, these algorithms generally also guarantee convergence.
• The bracketed solution means that we have the opportunity to only return roots that are greater than or equal to the actual root, or are less than or equal to the actual root. That is, we can control whether under-approximations and over-approximations are allowed solutions. Other root-finding algorithms can usually only guarantee that the solution (the root that was found) is around the actual root.

For backwards compatibility, all root-finding algorithms must have ANY_SIDE as default for the allowed solutions.

AllowedSolution
• ### Nested Class Summary

Nested Classes
Modifier and Type Interface and Description
static class  BracketedRealFieldUnivariateSolver.Interval<T extends CalculusFieldElement<T>>
An interval of a function that brackets a root.
• ### Method Summary

All Methods
Modifier and Type Method and Description
T getAbsoluteAccuracy()
Get the absolute accuracy of the solver.
int getEvaluations()
Get the number of evaluations of the objective function.
T getFunctionValueAccuracy()
Get the function value accuracy of the solver.
int getMaxEvaluations()
Get the maximum number of function evaluations.
T getRelativeAccuracy()
Get the relative accuracy of the solver.
T solve(int maxEval, CalculusFieldUnivariateFunction<T> f, T min, T max, AllowedSolution allowedSolution)
Solve for a zero in the given interval.
T solve(int maxEval, CalculusFieldUnivariateFunction<T> f, T min, T max, T startValue, AllowedSolution allowedSolution)
Solve for a zero in the given interval, start at startValue.
default BracketedRealFieldUnivariateSolver.Interval<T> solveInterval(int maxEval, CalculusFieldUnivariateFunction<T> f, T min, T max)
Solve for a zero in the given interval and return a tolerance interval surrounding the root.
BracketedRealFieldUnivariateSolver.Interval<T> solveInterval(int maxEval, CalculusFieldUnivariateFunction<T> f, T min, T max, T startValue)
Solve for a zero in the given interval and return a tolerance interval surrounding the root.
• ### Method Detail

• #### getMaxEvaluations

int getMaxEvaluations()
Get the maximum number of function evaluations.
Returns:
the maximum number of function evaluations.
• #### getEvaluations

int getEvaluations()
Get the number of evaluations of the objective function. The number of evaluations corresponds to the last call to the optimize method. It is 0 if the method has not been called yet.
Returns:
the number of evaluations of the objective function.
• #### getAbsoluteAccuracy

T 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 and v is a value returned by one of the solve methods, then a root of the function should exist somewhere in the interval (v - ε, v + ε).
Returns:
the absolute accuracy.
• #### getRelativeAccuracy

T getRelativeAccuracy()
Get the relative accuracy of the solver. The contract for relative accuracy is the same as getAbsoluteAccuracy(), but using relative, rather than absolute error. If ρ is the relative accuracy configured for a solver and v 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

T getFunctionValueAccuracy()
Get the function value accuracy of the solver. If v is a value returned by the solver for a function f, 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

T solve(int maxEval,
CalculusFieldUnivariateFunction<T> f,
T min,
T max,
AllowedSolution allowedSolution)
Solve for a zero 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.
allowedSolution - The kind of solutions that the root-finding algorithm may accept as solutions.
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

T solve(int maxEval,
CalculusFieldUnivariateFunction<T> f,
T min,
T max,
T startValue,
AllowedSolution allowedSolution)
Solve for a zero in the given interval, start at startValue. 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.
allowedSolution - The kind of solutions that the root-finding algorithm may accept as solutions.
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.
• #### solveInterval

default BracketedRealFieldUnivariateSolver.Interval<T> solveInterval(int maxEval,
CalculusFieldUnivariateFunction<T> f,
T min,
T max)
throws MathIllegalArgumentException,
MathIllegalStateException
Solve for a zero in the given interval and return a tolerance interval surrounding the root.

It is required that the starting interval brackets a root.

Parameters:
maxEval - Maximum number of evaluations.
f - Function to solve.
min - Lower bound for the interval. f(min) != 0.0.
max - Upper bound for the interval. f(max) != 0.0.
Returns:
an interval [ta, tb] such that for some t in [ta, tb] f(t) == 0.0 or has a step wise discontinuity that crosses zero. Both end points also satisfy the convergence criteria so either one could be used as the root. That is the interval satisfies the condition (| tb - ta | <= absolute accuracy + max(ta, tb) * relative accuracy) or ( max(|f(ta)|, |f(tb)|) <= getFunctionValueAccuracy()) or there are no numbers in the field between ta and tb. The width of the interval (tb - ta) may be zero.
Throws:
MathIllegalArgumentException - if the arguments do not satisfy the requirements specified by the solver.
MathIllegalStateException - if the allowed number of evaluations is exceeded.
• #### solveInterval

BracketedRealFieldUnivariateSolver.Interval<T> solveInterval(int maxEval,
CalculusFieldUnivariateFunction<T> f,
T min,
T max,
T startValue)
throws MathIllegalArgumentException,
MathIllegalStateException
Solve for a zero in the given interval and return a tolerance interval surrounding the root.

It is required that the starting interval brackets a root.

Parameters:
maxEval - Maximum number of evaluations.
startValue - start value to use.
f - Function to solve.
min - Lower bound for the interval. f(min) != 0.0.
max - Upper bound for the interval. f(max) != 0.0.
Returns:
an interval [ta, tb] such that for some t in [ta, tb] f(t) == 0.0 or has a step wise discontinuity that crosses zero. Both end points also satisfy the convergence criteria so either one could be used as the root. That is the interval satisfies the condition (| tb - ta | <= absolute accuracy + max(ta, tb) * relative accuracy) or ( max(|f(ta)|, |f(tb)|) <= getFunctionValueAccuracy()) or numbers in the field between ta and tb. The width of the interval (tb - ta) may be zero.
Throws:
MathIllegalArgumentException - if the arguments do not satisfy the requirements specified by the solver.
MathIllegalStateException - if the allowed number of evaluations is exceeded.