org.apache.commons.math.analysis
Class BrentSolver
java.lang.Object
org.apache.commons.math.analysis.UnivariateRealSolverImpl
org.apache.commons.math.analysis.BrentSolver
- All Implemented Interfaces:
- Serializable, UnivariateRealSolver
- public class BrentSolver
- extends UnivariateRealSolverImpl
- implements Serializable
Provide the Brent 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.9 $ $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 |
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 |
BrentSolver
public BrentSolver(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.
Copyright © 2003-2004 Apache Software Foundation. All Rights Reserved.