org.apache.commons.math.analysis
Class BisectionSolver

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

public class BisectionSolver
extends UnivariateRealSolverImpl

Implements the bisection algorithm for finding zeros of univariate real functions.

The function should be continuous but not necessarily smooth.

Version:
$Revision: 1.18 $ $Date: 2004/07/17 21:19:39 $
See Also:
Serialized Form

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

Field Detail

serialVersionUID

static final long serialVersionUID
Serializable version identifier

See Also:
Constant Field Values
Constructor Detail

BisectionSolver

public BisectionSolver(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 ConvergenceException,
                    FunctionEvaluationException
Find a zero in the given interval.

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:
ConvergenceException - the maximum iteration count is exceeded
FunctionEvaluationException - if an error occurs evaluating the function
IllegalArgumentException - if min is not less than max

solve

public double solve(double min,
                    double max)
             throws ConvergenceException,
                    FunctionEvaluationException
Find a zero root in the given interval.

Parameters:
min - the lower bound for the interval
max - the upper bound for the interval
Returns:
the value where the function is zero
Throws:
ConvergenceException - if the maximum iteration count is exceeded.
FunctionEvaluationException - if an error occurs evaluating the function
IllegalArgumentException - if min is not less than max


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