Top Description Fields Constructors Methods
org.apache.commons.math3.analysis.solvers

public Class FieldBracketingNthOrderBrentSolver<T extends RealFieldElement<T>>

extends Object
implements BracketedRealFieldUnivariateSolver<T extends RealFieldElement<T>>
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.analysis.solvers.BracketedRealFieldUnivariateSolver
Known Direct Subclasses
org.apache.commons.math3.dfp.BracketingNthOrderBrentSolverDFP
Type Parameters
<T>
the type of the field elements
Imports
org.apache.commons.math3.Field, .RealFieldElement, org.apache.commons.math3.analysis.RealFieldUnivariateFunction, org.apache.commons.math3.exception.MathInternalError, .NoBracketingException, .NullArgumentException, .NumberIsTooSmallException, org.apache.commons.math3.util.IntegerSequence, .MathArrays, .MathUtils, .Precision

This class implements a modification of the Brent algorithm.

The changes with respect to the original Brent algorithm are:

The given interval must bracket the root.

Since
3.6

Field Summary

Modifier and TypeField and Description
private final T
absoluteAccuracy

Absolute accuracy.

private IntegerSequence.Incrementor
evaluations

Evaluations counter.

private final Field<T>
field

Field to which the elements belong.

private final T
functionValueAccuracy

Function value accuracy.

private static final int
MAXIMAL_AGING

Maximal aging triggering an attempt to balance the bracketing interval.

private final int
maximalOrder

Maximal order.

private final T
relativeAccuracy

Relative accuracy.

Constructor Summary

AccessConstructor and Description
public
FieldBracketingNthOrderBrentSolver(final T
Relative accuracy.
relativeAccuracy
,
final T
Absolute accuracy.
absoluteAccuracy
,
final T
Function value accuracy.
functionValueAccuracy
,
final int
maximal order.
maximalOrder
)

Construct a solver.

Method Summary

Modifier and TypeMethod and Description
public T
public int

Returns:

the number of evaluations of the objective function.
getEvaluations
()

Implements org.apache.commons.math3.analysis.solvers.BracketedRealFieldUnivariateSolver.getEvaluations.

Get the number of evaluations of the objective function.

public T
public int

Returns:

the maximal number of function evaluations.
getMaxEvaluations
()

Implements org.apache.commons.math3.analysis.solvers.BracketedRealFieldUnivariateSolver.getMaxEvaluations.

Get the maximal number of function evaluations.

public int

Returns:

maximal order
getMaximalOrder
()

Get the maximal order.

public T
private T

Returns:

guessed root (will be a NaN if two points share the same y)
guessX
(final T
target value for y
targetY
,
final T[]
reference points abscissas for interpolation, note that this array is modified during computation
x
,
final T[]
reference points ordinates for interpolation
y
,
final int
start index of the points to consider (inclusive)
start
,
final int
end index of the points to consider (exclusive)
end
)

Guess an x value by nth order inverse polynomial interpolation.

public T

Returns:

a value where the function is zero.
solve
(final int
Maximum number of evaluations.
maxEval
,
final RealFieldUnivariateFunction<T>
Function to solve.
f
,
final T
Lower bound for the interval.
min
,
final T
Upper bound for the interval.
max
,
final AllowedSolution
The kind of solutions that the root-finding algorithm may accept as solutions.
allowedSolution
)

Implements org.apache.commons.math3.analysis.solvers.BracketedRealFieldUnivariateSolver.solve.

Solve for a zero in the given interval.

public T

Returns:

a value where the function is zero.
solve
(final int
Maximum number of evaluations.
maxEval
,
final RealFieldUnivariateFunction<T>
Function to solve.
f
,
final T
Lower bound for the interval.
min
,
final T
Upper bound for the interval.
max
,
final T
Start value to use.
startValue
,
final AllowedSolution
The kind of solutions that the root-finding algorithm may accept as solutions.
allowedSolution
)

Implements org.apache.commons.math3.analysis.solvers.BracketedRealFieldUnivariateSolver.solve.

Solve for a zero in the given interval, start at startValue.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

absoluteAccuracyback to summary
private final T absoluteAccuracy

Absolute accuracy.

evaluationsback to summary
private IntegerSequence.Incrementor evaluations

Evaluations counter.

fieldback to summary
private final Field<T> field

Field to which the elements belong.

functionValueAccuracyback to summary
private final T functionValueAccuracy

Function value accuracy.

MAXIMAL_AGINGback to summary
private static final int MAXIMAL_AGING

Maximal aging triggering an attempt to balance the bracketing interval.

maximalOrderback to summary
private final int maximalOrder

Maximal order.

relativeAccuracyback to summary
private final T relativeAccuracy

Relative accuracy.

Constructor Detail

FieldBracketingNthOrderBrentSolverback to summary
public FieldBracketingNthOrderBrentSolver(final T relativeAccuracy, final T absoluteAccuracy, final T functionValueAccuracy, final int maximalOrder) throws NumberIsTooSmallException

Construct a solver.

Parameters
relativeAccuracy:T

Relative accuracy.

absoluteAccuracy:T

Absolute accuracy.

functionValueAccuracy:T

Function value accuracy.

maximalOrder:int

maximal order.

Exceptions
NumberIsTooSmallException:
if maximal order is lower than 2

Method Detail

getAbsoluteAccuracyback to summary
public T getAbsoluteAccuracy()

Implements org.apache.commons.math3.analysis.solvers.BracketedRealFieldUnivariateSolver.getAbsoluteAccuracy.

Get the absolute accuracy.

Returns:T

absolute accuracy

getEvaluationsback to summary
public int getEvaluations()

Implements org.apache.commons.math3.analysis.solvers.BracketedRealFieldUnivariateSolver.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:int

the number of evaluations of the objective function.

getFunctionValueAccuracyback to summary
public T getFunctionValueAccuracy()

Implements org.apache.commons.math3.analysis.solvers.BracketedRealFieldUnivariateSolver.getFunctionValueAccuracy.

Get the function accuracy.

Returns:T

function accuracy

getMaxEvaluationsback to summary
public int getMaxEvaluations()

Implements org.apache.commons.math3.analysis.solvers.BracketedRealFieldUnivariateSolver.getMaxEvaluations.

Get the maximal number of function evaluations.

Returns:int

the maximal number of function evaluations.

getMaximalOrderback to summary
public int getMaximalOrder()

Get the maximal order.

Returns:int

maximal order

getRelativeAccuracyback to summary
public T getRelativeAccuracy()

Implements org.apache.commons.math3.analysis.solvers.BracketedRealFieldUnivariateSolver.getRelativeAccuracy.

Get the relative accuracy.

Returns:T

relative accuracy

guessXback to summary
private T guessX(final T targetY, final T[] x, final T[] y, final int start, final int end)

Guess an x value by nth order inverse polynomial interpolation.

The x value is guessed by evaluating polynomial Q(y) at y = targetY, where Q is built such that for all considered points (xi, yi), Q(yi) = xi.

Parameters
targetY:T

target value for y

x:T[]

reference points abscissas for interpolation, note that this array is modified during computation

y:T[]

reference points ordinates for interpolation

start:int

start index of the points to consider (inclusive)

end:int

end index of the points to consider (exclusive)

Returns:T

guessed root (will be a NaN if two points share the same y)

solveback to summary
public T solve(final int maxEval, final RealFieldUnivariateFunction<T> f, final T min, final T max, final AllowedSolution allowedSolution) throws NullArgumentException, NoBracketingException

Implements org.apache.commons.math3.analysis.solvers.BracketedRealFieldUnivariateSolver.solve.

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:int

Maximum number of evaluations.

f:RealFieldUnivariateFunction<T>

Function to solve.

min:T

Lower bound for the interval.

max:T

Upper bound for the interval.

allowedSolution:AllowedSolution

The kind of solutions that the root-finding algorithm may accept as solutions.

Returns:T

a value where the function is zero.

Exceptions
NullArgumentException:
if f is null.
NoBracketingException:
if root cannot be bracketed
solveback to summary
public T solve(final int maxEval, final RealFieldUnivariateFunction<T> f, final T min, final T max, final T startValue, final AllowedSolution allowedSolution) throws NullArgumentException, NoBracketingException

Implements org.apache.commons.math3.analysis.solvers.BracketedRealFieldUnivariateSolver.solve.

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:int

Maximum number of evaluations.

f:RealFieldUnivariateFunction<T>

Function to solve.

min:T

Lower bound for the interval.

max:T

Upper bound for the interval.

startValue:T

Start value to use.

allowedSolution:AllowedSolution

The kind of solutions that the root-finding algorithm may accept as solutions.

Returns:T

a value where the function is zero.

Exceptions
NullArgumentException:
if f is null.
NoBracketingException:
if root cannot be bracketed