Package org.hipparchus.analysis.solvers
Class FieldBracketingNthOrderBrentSolver<T extends CalculusFieldElement<T>>
- java.lang.Object
-
- org.hipparchus.analysis.solvers.FieldBracketingNthOrderBrentSolver<T>
-
- Type Parameters:
T
- the type of the field elements
- All Implemented Interfaces:
BracketedRealFieldUnivariateSolver<T>
public class FieldBracketingNthOrderBrentSolver<T extends CalculusFieldElement<T>> extends Object implements BracketedRealFieldUnivariateSolver<T>
This class implements a modification of the Brent algorithm.The changes with respect to the original Brent algorithm are:
- the returned value is chosen in the current interval according
to user specified
AllowedSolution
- the maximal order for the invert polynomial root search is user-specified instead of being invert quadratic only
The given interval must bracket the root.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.hipparchus.analysis.solvers.BracketedRealFieldUnivariateSolver
BracketedRealFieldUnivariateSolver.Interval<T extends CalculusFieldElement<T>>
-
-
Constructor Summary
Constructors Constructor Description FieldBracketingNthOrderBrentSolver(T relativeAccuracy, T absoluteAccuracy, T functionValueAccuracy, int maximalOrder)
Construct a solver.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
getAbsoluteAccuracy()
Get the absolute accuracy.int
getEvaluations()
Get the number of evaluations of the objective function.T
getFunctionValueAccuracy()
Get the function accuracy.int
getMaxEvaluations()
Get the maximal number of function evaluations.int
getMaximalOrder()
Get the maximal order.T
getRelativeAccuracy()
Get the relative accuracy.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 atstartValue
.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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hipparchus.analysis.solvers.BracketedRealFieldUnivariateSolver
solveInterval
-
-
-
-
Constructor Detail
-
FieldBracketingNthOrderBrentSolver
public FieldBracketingNthOrderBrentSolver(T relativeAccuracy, T absoluteAccuracy, T functionValueAccuracy, int maximalOrder) throws MathIllegalArgumentException
Construct a solver.- Parameters:
relativeAccuracy
- Relative accuracy.absoluteAccuracy
- Absolute accuracy.functionValueAccuracy
- Function value accuracy.maximalOrder
- maximal order.- Throws:
MathIllegalArgumentException
- if maximal order is lower than 2
-
-
Method Detail
-
getMaximalOrder
public int getMaximalOrder()
Get the maximal order.- Returns:
- maximal order
-
getMaxEvaluations
public int getMaxEvaluations()
Get the maximal number of function evaluations.- Specified by:
getMaxEvaluations
in interfaceBracketedRealFieldUnivariateSolver<T extends CalculusFieldElement<T>>
- Returns:
- the maximal number of function evaluations.
-
getEvaluations
public 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.- Specified by:
getEvaluations
in interfaceBracketedRealFieldUnivariateSolver<T extends CalculusFieldElement<T>>
- Returns:
- the number of evaluations of the objective function.
-
getAbsoluteAccuracy
public T getAbsoluteAccuracy()
Get the absolute accuracy.- Specified by:
getAbsoluteAccuracy
in interfaceBracketedRealFieldUnivariateSolver<T extends CalculusFieldElement<T>>
- Returns:
- absolute accuracy
-
getRelativeAccuracy
public T getRelativeAccuracy()
Get the relative accuracy.- Specified by:
getRelativeAccuracy
in interfaceBracketedRealFieldUnivariateSolver<T extends CalculusFieldElement<T>>
- Returns:
- relative accuracy
-
getFunctionValueAccuracy
public T getFunctionValueAccuracy()
Get the function accuracy.- Specified by:
getFunctionValueAccuracy
in interfaceBracketedRealFieldUnivariateSolver<T extends CalculusFieldElement<T>>
- Returns:
- function accuracy
-
solve
public T solve(int maxEval, CalculusFieldUnivariateFunction<T> f, T min, T max, AllowedSolution allowedSolution) throws MathIllegalArgumentException, NullArgumentException
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.- Specified by:
solve
in interfaceBracketedRealFieldUnivariateSolver<T extends CalculusFieldElement<T>>
- 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:
NullArgumentException
- if f is null.MathIllegalArgumentException
- if root cannot be bracketed
-
solve
public T solve(int maxEval, CalculusFieldUnivariateFunction<T> f, T min, T max, T startValue, AllowedSolution allowedSolution) throws MathIllegalArgumentException, NullArgumentException
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.- Specified by:
solve
in interfaceBracketedRealFieldUnivariateSolver<T extends CalculusFieldElement<T>>
- 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:
NullArgumentException
- if f is null.MathIllegalArgumentException
- if root cannot be bracketed
-
solveInterval
public 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.
- Specified by:
solveInterval
in interfaceBracketedRealFieldUnivariateSolver<T extends CalculusFieldElement<T>>
- 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.startValue
- start value to use.- 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)|) <=BracketedRealFieldUnivariateSolver.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.
-
-