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

public abstract Class BaseSecantSolver

extends AbstractUnivariateSolver
implements BracketedUnivariateSolver<UnivariateFunction>
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.analysis.solvers.BracketedUnivariateSolver, org.apache.commons.math3.analysis.solvers.BaseUnivariateSolver
Known Direct Subclasses
org.apache.commons.math3.analysis.solvers.IllinoisSolver, org.apache.commons.math3.analysis.solvers.PegasusSolver, org.apache.commons.math3.analysis.solvers.RegulaFalsiSolver
Imports
org.apache.commons.math3.util.FastMath, org.apache.commons.math3.analysis.UnivariateFunction, org.apache.commons.math3.exception.ConvergenceException, .MathInternalError

Base class for all bracketing Secant-based methods for root-finding (approximating a zero of a univariate real function).

Implementation of the Regula Falsi and Illinois methods is based on the following article: M. Dowell and P. Jarratt, A modified regula falsi method for computing the root of an equation, BIT Numerical Mathematics, volume 11, number 2, pages 168-174, Springer, 1971.

Implementation of the Pegasus method is based on the following article: M. Dowell and P. Jarratt, The "Pegasus" method for computing the root of an equation, BIT Numerical Mathematics, volume 12, number 4, pages 503-508, Springer, 1972.

The Secant method is not a bracketing method, so it is not implemented here. It has a separate implementation.

Since
3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static enum
BaseSecantSolver.Method

Secant-based root-finding methods.

Field Summary

Modifier and TypeField and Description
private AllowedSolution
allowed

The kinds of solutions that the algorithm may accept.

protected static final double
DEFAULT_ABSOLUTE_ACCURACY

Default absolute accuracy.

private final BaseSecantSolver.Method
method

The Secant-based root-finding method to use.

Constructor Summary

AccessConstructor and Description
protected
BaseSecantSolver(final double
Absolute accuracy.
absoluteAccuracy
,
final BaseSecantSolver.Method
Secant-based root-finding method to use.
method
)

Construct a solver.

protected
BaseSecantSolver(final double
Relative accuracy.
relativeAccuracy
,
final double
Absolute accuracy.
absoluteAccuracy
,
final BaseSecantSolver.Method
Secant-based root-finding method to use.
method
)

Construct a solver.

protected
BaseSecantSolver(final double
Maximum relative error.
relativeAccuracy
,
final double
Maximum absolute error.
absoluteAccuracy
,
final double
Maximum function value error.
functionValueAccuracy
,
final BaseSecantSolver.Method
Secant-based root-finding method to use
method
)

Construct a solver.

Method Summary

Modifier and TypeMethod and Description
protected final double
doSolve()

Implements abstract org.apache.commons.math3.analysis.solvers.BaseAbstractUnivariateSolver.doSolve.

Method for implementing actual optimization algorithms in derived classes.

public double
solve(final int
Maximum number of evaluations.
maxEval
,
final UnivariateFunction
Function to solve.
f
,
final double
Lower bound for the interval.
min
,
final double
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.BracketedUnivariateSolver.solve.

Solve for a zero in the given interval.

public double
solve(final int
Maximum number of evaluations.
maxEval
,
final UnivariateFunction
Function to solve.
f
,
final double
Lower bound for the interval.
min
,
final double
Upper bound for the interval.
max
,
final double
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.BracketedUnivariateSolver.solve.

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

public double
solve(final int
Maximum number of evaluations.
maxEval
,
final UnivariateFunction
Function to solve.
f
,
final double
Lower bound for the interval.
min
,
final double
Upper bound for the interval.
max
,
final double
Start value to use.
startValue
)

Overrides org.apache.commons.math3.analysis.solvers.BaseAbstractUnivariateSolver.solve.

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

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

Field Detail

allowedback to summary
private AllowedSolution allowed

The kinds of solutions that the algorithm may accept.

DEFAULT_ABSOLUTE_ACCURACYback to summary
protected static final double DEFAULT_ABSOLUTE_ACCURACY

Default absolute accuracy.

methodback to summary
private final BaseSecantSolver.Method method

The Secant-based root-finding method to use.

Constructor Detail

BaseSecantSolverback to summary
protected BaseSecantSolver(final double absoluteAccuracy, final BaseSecantSolver.Method method)

Construct a solver.

Parameters
absoluteAccuracy:double

Absolute accuracy.

method:BaseSecantSolver.Method

Secant-based root-finding method to use.

BaseSecantSolverback to summary
protected BaseSecantSolver(final double relativeAccuracy, final double absoluteAccuracy, final BaseSecantSolver.Method method)

Construct a solver.

Parameters
relativeAccuracy:double

Relative accuracy.

absoluteAccuracy:double

Absolute accuracy.

method:BaseSecantSolver.Method

Secant-based root-finding method to use.

BaseSecantSolverback to summary
protected BaseSecantSolver(final double relativeAccuracy, final double absoluteAccuracy, final double functionValueAccuracy, final BaseSecantSolver.Method method)

Construct a solver.

Parameters
relativeAccuracy:double

Maximum relative error.

absoluteAccuracy:double

Maximum absolute error.

functionValueAccuracy:double

Maximum function value error.

method:BaseSecantSolver.Method

Secant-based root-finding method to use

Method Detail

doSolveback to summary
protected final double doSolve() throws ConvergenceException

Implements abstract org.apache.commons.math3.analysis.solvers.BaseAbstractUnivariateSolver.doSolve.

Doc from org.apache.commons.math3.analysis.solvers.BaseAbstractUnivariateSolver.doSolve.

Method for implementing actual optimization algorithms in derived classes.

Returns:double

the root.

Annotations
@Override
Exceptions
ConvergenceException:
if the algorithm failed due to finite precision.
solveback to summary
public double solve(final int maxEval, final UnivariateFunction f, final double min, final double max, final AllowedSolution allowedSolution)

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

Doc from org.apache.commons.math3.analysis.solvers.BracketedUnivariateSolver.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:UnivariateFunction

Function to solve.

min:double

Lower bound for the interval.

max:double

Upper bound for the interval.

allowedSolution:AllowedSolution

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

Returns:double

A value where the function is zero.

solveback to summary
public double solve(final int maxEval, final UnivariateFunction f, final double min, final double max, final double startValue, final AllowedSolution allowedSolution)

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

Doc from org.apache.commons.math3.analysis.solvers.BracketedUnivariateSolver.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:UnivariateFunction

Function to solve.

min:double

Lower bound for the interval.

max:double

Upper bound for the interval.

startValue:double

Start value to use.

allowedSolution:AllowedSolution

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

Returns:double

A value where the function is zero.

solveback to summary
public double solve(final int maxEval, final UnivariateFunction f, final double min, final double max, final double startValue)

Overrides org.apache.commons.math3.analysis.solvers.BaseAbstractUnivariateSolver.solve.

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

Doc from org.apache.commons.math3.analysis.solvers.BaseUnivariateSolver.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:UnivariateFunction

Function to solve.

min:double

Lower bound for the interval.

max:double

Upper bound for the interval.

startValue:double

Start value to use.

Returns:double

a value where the function is zero.

Annotations
@Override
org.apache.commons.math3.analysis.solvers back to summary

protected final Enum BaseSecantSolver.Method

extends Enum<BaseSecantSolver.Method>
Class Inheritance

Secant-based root-finding methods.

Field Summary

Modifier and TypeField and Description
public static final BaseSecantSolver.Method
ILLINOIS

The Illinois method.

public static final BaseSecantSolver.Method
PEGASUS

The Pegasus method.

public static final BaseSecantSolver.Method
REGULA_FALSI

The Regula Falsi or False Position method.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static BaseSecantSolver.Method
public static BaseSecantSolver.Method[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ILLINOISback to summary
public static final BaseSecantSolver.Method ILLINOIS

The Illinois method.

PEGASUSback to summary
public static final BaseSecantSolver.Method PEGASUS

The Pegasus method.

REGULA_FALSIback to summary
public static final BaseSecantSolver.Method REGULA_FALSI

The Regula Falsi or False Position method.

Constructor Detail

Methodback to summary
private Method()

Method Detail

valueOfback to summary
public static BaseSecantSolver.Method valueOf(String name)
valuesback to summary
public static BaseSecantSolver.Method[] values()