org.apache.commons.math.analysis
Class BisectionSolver
java.lang.Object
org.apache.commons.math.analysis.UnivariateRealSolverImpl
org.apache.commons.math.analysis.BisectionSolver
- All Implemented Interfaces:
- Serializable, UnivariateRealSolver
- public class BisectionSolver
- extends UnivariateRealSolverImpl
- implements Serializable
Provide the bisection algorithm for solving for zeros of real univariate
functions. 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.8 $ $Date: 2003/11/19 03:28:23 $
- See Also:
- Serialized Form
Fields inherited from class org.apache.commons.math.analysis.UnivariateRealSolverImpl |
absoluteAccuracy, defaultAbsoluteAccuracy, defaultFunctionValueAccuracy, defaultMaximalIterationCount, defaultRelativeAccuracy, f, functionValueAccuracy, iterationCount, maximalIterationCount, relativeAccuracy, result, resultComputed |
Method Summary |
static double |
midpoint(double a,
double b)
Compute the midpoint of two values. |
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 |
BisectionSolver
public BisectionSolver(UnivariateRealFunction f)
- Construct a solver for the given function.
- Parameters:
f
- function to solve.
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.
midpoint
public static double midpoint(double a,
double b)
- Compute the midpoint of two values.
- Parameters:
a
- first value.b
- second value.
- Returns:
- the midpoint.
Copyright © 2003-2004 Apache Software Foundation. All Rights Reserved.