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

public Class SecantSolver

extends AbstractUnivariateSolver
Class Inheritance
Imports
org.apache.commons.math3.util.FastMath, org.apache.commons.math3.exception.NoBracketingException, .TooManyEvaluationsException

Implements the Secant method for root-finding (approximating a zero of a univariate real function). The solution that is maintained is not bracketed, and as such convergence is not guaranteed.

Implementation 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.

Note that since release 3.0 this class implements the actual Secant algorithm, and not a modified one. As such, the 3.0 version is not backwards compatible with previous versions. To use an algorithm similar to the pre-3.0 releases, use the Illinois algorithm or the Pegasus algorithm.

Field Summary

Modifier and TypeField and Description
protected static final double
DEFAULT_ABSOLUTE_ACCURACY

Default absolute accuracy.

Constructor Summary

AccessConstructor and Description
public
SecantSolver()

Construct a solver with default accuracy (1e-6).

public
SecantSolver(final double
absolute accuracy
absoluteAccuracy
)

Construct a solver.

public
SecantSolver(final double
relative accuracy
relativeAccuracy
,
final double
absolute accuracy
absoluteAccuracy
)

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.

Field Detail

DEFAULT_ABSOLUTE_ACCURACYback to summary
protected static final double DEFAULT_ABSOLUTE_ACCURACY

Default absolute accuracy.

Constructor Detail

SecantSolverback to summary
public SecantSolver()

Construct a solver with default accuracy (1e-6).

SecantSolverback to summary
public SecantSolver(final double absoluteAccuracy)

Construct a solver.

Parameters
absoluteAccuracy:double

absolute accuracy

SecantSolverback to summary
public SecantSolver(final double relativeAccuracy, final double absoluteAccuracy)

Construct a solver.

Parameters
relativeAccuracy:double

relative accuracy

absoluteAccuracy:double

absolute accuracy

Method Detail

doSolveback to summary
protected final double doSolve() throws TooManyEvaluationsException, NoBracketingException

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
TooManyEvaluationsException:
if the maximal number of evaluations is exceeded.
NoBracketingException:
if the initial search interval does not bracket a root and the solver requires it.