Class SecantSolver

  • All Implemented Interfaces:
    UnivariateRealSolver, ConvergingAlgorithm

    public class SecantSolver
    extends UnivariateRealSolverImpl
    Implements a modified version of the secant method for approximating a zero of a real univariate function.

    The algorithm is modified to maintain bracketing of a root by successive approximations. Because of forced bracketing, convergence may be slower than the unrestricted secant algorithm. However, this implementation should in general outperform the regula falsi method.

    The function is assumed to be continuous but not necessarily smooth.

    • Method Detail

      • solve

        @Deprecated
        public double solve​(double min,
                            double max)
                     throws ConvergenceException,
                            FunctionEvaluationException
        Deprecated.
        Solve for a zero root 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:
        min - the lower bound for the interval.
        max - the upper bound for the interval.
        Returns:
        a value where the function is zero
        Throws:
        ConvergenceException - if the maximum iteration count is exceeded or the solver detects convergence problems otherwise.
        FunctionEvaluationException - if an error occurs evaluating the function
      • solve

        @Deprecated
        public double solve​(double min,
                            double max,
                            double initial)
                     throws ConvergenceException,
                            FunctionEvaluationException
        Deprecated.
        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:
        min - the lower bound for the interval.
        max - the upper bound for the interval.
        initial - the start value to use
        Returns:
        a value where the function is zero
        Throws:
        ConvergenceException - if the maximum iteration count is exceeded or the solver detects convergence problems otherwise.
        FunctionEvaluationException - if an error occurs evaluating the function
      • solve

        @Deprecated
        public double solve​(UnivariateRealFunction f,
                            double min,
                            double max,
                            double initial)
                     throws MaxIterationsExceededException,
                            FunctionEvaluationException
        Deprecated.
        in 2.2 (to be removed in 3.0).
        Find a zero in the given interval.
        Parameters:
        f - the function to solve
        min - the lower bound for the interval
        max - the upper bound for the interval
        initial - the start value to use (ignored)
        Returns:
        the value where the function is zero
        Throws:
        MaxIterationsExceededException - if the maximum iteration count is exceeded
        FunctionEvaluationException - if an error occurs evaluating the function
        java.lang.IllegalArgumentException - if min is not less than max or the signs of the values of the function at the endpoints are not opposites
      • solve

        @Deprecated
        public double solve​(UnivariateRealFunction f,
                            double min,
                            double max)
                     throws MaxIterationsExceededException,
                            FunctionEvaluationException
        Deprecated.
        in 2.2 (to be removed in 3.0).
        Find a zero in the given interval.
        Parameters:
        f - the function to solve
        min - the lower bound for the interval.
        max - the upper bound for the interval.
        Returns:
        the value where the function is zero
        Throws:
        MaxIterationsExceededException - if the maximum iteration count is exceeded
        FunctionEvaluationException - if an error occurs evaluating the function
        java.lang.IllegalArgumentException - if min is not less than max or the signs of the values of the function at the endpoints are not opposites