org.apache.commons.math3.analysis.solvers

## Class SecantSolver

- java.lang.Object
- - org.apache.commons.math3.analysis.solvers.BaseAbstractUnivariateSolver<UnivariateFunction>
  - - org.apache.commons.math3.analysis.solvers.AbstractUnivariateSolver
    - - org.apache.commons.math3.analysis.solvers.SecantSolver

- All Implemented Interfaces:
    BaseUnivariateSolver<UnivariateFunction>, UnivariateSolver

      public class SecantSolver
      extends AbstractUnivariateSolver

  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.

  Version:
    $Id: SecantSolver.java 1379560 2012-08-31 19:40:30Z erans $

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static double` | `DEFAULT_ABSOLUTE_ACCURACY` Default absolute accuracy.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SecantSolver()` Construct a solver with default accuracy (1e-6).
    `SecantSolver(double absoluteAccuracy)` Construct a solver.
    `SecantSolver(double relativeAccuracy, double absoluteAccuracy)` Construct a solver.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected double` | `doSolve()` Method for implementing actual optimization algorithms in derived classes.

    - ### Methods inherited from class org.apache.commons.math3.analysis.solvers.BaseAbstractUnivariateSolver

      `computeObjectiveValue, getAbsoluteAccuracy, getEvaluations, getFunctionValueAccuracy, getMax, getMaxEvaluations, getMin, getRelativeAccuracy, getStartValue, incrementEvaluationCount, isBracketing, isSequence, setup, solve, solve, solve, verifyBracketing, verifyInterval, verifySequence`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.commons.math3.analysis.solvers.BaseUnivariateSolver

      `getAbsoluteAccuracy, getEvaluations, getFunctionValueAccuracy, getMaxEvaluations, getRelativeAccuracy, solve, solve, solve`

- - ### Field Detail

    - #### DEFAULT_ABSOLUTE_ACCURACY

          protected static final double DEFAULT_ABSOLUTE_ACCURACY

      Default absolute accuracy.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SecantSolver

          public SecantSolver()

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

    - #### SecantSolver

          public SecantSolver(double absoluteAccuracy)

      Construct a solver.
      Parameters:
        `absoluteAccuracy` - absolute accuracy

    - #### SecantSolver

          public SecantSolver(double relativeAccuracy,
                      double absoluteAccuracy)

      Construct a solver.
      Parameters:
        `relativeAccuracy` - relative accuracy
        `absoluteAccuracy` - absolute accuracy

  - ### Method Detail

    - #### doSolve

          protected final double doSolve()
                                  throws TooManyEvaluationsException,
                                         NoBracketingException

      Method for implementing actual optimization algorithms in derived classes.
      Specified by:
        `doSolve` in class `BaseAbstractUnivariateSolver<UnivariateFunction>`
      Returns:
        the root.
      Throws:
        `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.

Copyright (c) 2003-2013 Apache Software Foundation