org.apache.commons.math.analysis
Class SecantSolver

java.lang.Object
  extended byorg.apache.commons.math.analysis.UnivariateRealSolverImpl
      extended byorg.apache.commons.math.analysis.SecantSolver
All Implemented Interfaces:
Serializable, UnivariateRealSolver

public class SecantSolver
extends UnivariateRealSolverImpl
implements Serializable

Provide the secant algorithm for solving for zeros of real univariate functions. Because of forced bracketing, convergence is slower than the unrestricted secant algorithm. However, slow convergence of the Regula Falsi can be avoided. It will only search for one zero in the given interval. The function is supposed to be continuous but not necessarily smooth.

Version:
$Revision: 1.9 $ $Date: 2003/11/19 03:28:23 $
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.commons.math.analysis.UnivariateRealSolverImpl
absoluteAccuracy, defaultAbsoluteAccuracy, defaultFunctionValueAccuracy, defaultMaximalIterationCount, defaultRelativeAccuracy, f, functionValueAccuracy, iterationCount, maximalIterationCount, relativeAccuracy, result, resultComputed
 
Constructor Summary
SecantSolver(UnivariateRealFunction f)
          Construct a solver for the given function.
 
Method Summary
 double solve(double min, double max)
          Solve for a zero root in the given interval.
 double solve(double min, double max, double initial)
          Solve for a zero in the given interval.
 
Methods inherited from class org.apache.commons.math.analysis.UnivariateRealSolverImpl
clearResult, getAbsoluteAccuracy, getFunctionValueAccuracy, getIterationCount, getMaximalIterationCount, getRelativeAccuracy, getResult, resetAbsoluteAccuracy, resetFunctionValueAccuracy, resetMaximalIterationCount, resetRelativeAccuracy, setAbsoluteAccuracy, setFunctionValueAccuracy, setMaximalIterationCount, setRelativeAccuracy, setResult
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecantSolver

public SecantSolver(UnivariateRealFunction f)
Construct a solver for the given function.

Parameters:
f - function to solve.
Method Detail

solve

public double solve(double min,
                    double max,
                    double initial)
             throws MathException
Solve for a zero in the given interval.

Specified by:
solve in interface UnivariateRealSolver
Parameters:
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:
MathException - if the iteration count was exceeded or the solver detects convergence problems otherwise.

solve

public double solve(double min,
                    double max)
             throws MathException
Solve for a zero root in the given interval.

Specified by:
solve in interface UnivariateRealSolver
Parameters:
min - the lower bound for the interval.
max - the upper bound for the interval.
Returns:
the value where the function is zero
Throws:
MathException - if the iteration count was exceeded or the solver detects convergence problems otherwise.


Copyright © 2003-2004 Apache Software Foundation. All Rights Reserved.