|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.math.ConvergingAlgorithmImpl
org.apache.commons.math.analysis.solvers.UnivariateRealSolverImpl
org.apache.commons.math.analysis.solvers.BrentSolver
public class BrentSolver
Implements the Brent algorithm for finding zeros of real univariate functions.
The function should be continuous but not necessarily smooth.
Field Summary | |
---|---|
private static long |
serialVersionUID
Serializable version identifier |
Fields inherited from class org.apache.commons.math.analysis.solvers.UnivariateRealSolverImpl |
---|
defaultFunctionValueAccuracy, f, functionValue, functionValueAccuracy, result, resultComputed |
Fields inherited from class org.apache.commons.math.ConvergingAlgorithmImpl |
---|
absoluteAccuracy, defaultAbsoluteAccuracy, defaultMaximalIterationCount, defaultRelativeAccuracy, iterationCount, maximalIterationCount, relativeAccuracy |
Constructor Summary | |
---|---|
BrentSolver()
Construct a solver. |
|
BrentSolver(UnivariateRealFunction f)
Deprecated. as of 2.0 the function to solve is passed as an argument to the solve(UnivariateRealFunction, double, double) or
UnivariateRealSolver.solve(UnivariateRealFunction, double, double, double)
method. |
Method Summary | |
---|---|
double |
solve(double min,
double max)
Deprecated. |
double |
solve(double min,
double max,
double initial)
Deprecated. |
double |
solve(UnivariateRealFunction f,
double min,
double max)
Find a zero in the given interval. |
double |
solve(UnivariateRealFunction f,
double min,
double max,
double initial)
Find a zero in the given interval with an initial guess. |
private double |
solve(UnivariateRealFunction f,
double x0,
double y0,
double x1,
double y1,
double x2,
double y2)
Find a zero starting search according to the three provided points. |
Methods inherited from class org.apache.commons.math.analysis.solvers.UnivariateRealSolverImpl |
---|
checkResultComputed, clearResult, getFunctionValue, getFunctionValueAccuracy, getResult, isBracketing, isSequence, resetFunctionValueAccuracy, setFunctionValueAccuracy, setResult, setResult, verifyBracketing, verifyInterval, verifySequence |
Methods inherited from class org.apache.commons.math.ConvergingAlgorithmImpl |
---|
getAbsoluteAccuracy, getIterationCount, getMaximalIterationCount, getRelativeAccuracy, resetAbsoluteAccuracy, resetMaximalIterationCount, resetRelativeAccuracy, setAbsoluteAccuracy, setMaximalIterationCount, setRelativeAccuracy |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.commons.math.ConvergingAlgorithm |
---|
getAbsoluteAccuracy, getIterationCount, getMaximalIterationCount, getRelativeAccuracy, resetAbsoluteAccuracy, resetMaximalIterationCount, resetRelativeAccuracy, setAbsoluteAccuracy, setMaximalIterationCount, setRelativeAccuracy |
Field Detail |
---|
private static final long serialVersionUID
Constructor Detail |
---|
@Deprecated public BrentSolver(UnivariateRealFunction f)
solve(UnivariateRealFunction, double, double)
or
UnivariateRealSolver.solve(UnivariateRealFunction, double, double, double)
method.
f
- function to solve.public BrentSolver()
Method Detail |
---|
@Deprecated public double solve(double min, double max) throws MaxIterationsExceededException, FunctionEvaluationException
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.
min
- the lower bound for the interval.max
- the upper bound for the interval.
FunctionEvaluationException
- if an error occurs evaluating the
function
MaxIterationsExceededException
@Deprecated public double solve(double min, double max, double initial) throws MaxIterationsExceededException, FunctionEvaluationException
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.
min
- the lower bound for the interval.max
- the upper bound for the interval.initial
- the start value to use
FunctionEvaluationException
- if an error occurs evaluating the
function
MaxIterationsExceededException
public double solve(UnivariateRealFunction f, double min, double max, double initial) throws MaxIterationsExceededException, FunctionEvaluationException
Throws IllegalArgumentException
if the values of the
function at the three points have the same sign (note that it is
allowed to have endpoints with the same sign if the initial point has
opposite sign function-wise).
f
- function to solve.min
- the lower bound for the interval.max
- the upper bound for the interval.initial
- the start value to use (must be set to min if no
initial point is known).
MaxIterationsExceededException
- the maximum iteration count
is exceeded
FunctionEvaluationException
- if an error occurs evaluating
the function
java.lang.IllegalArgumentException
- if initial is not between min and max
(even if it is a root)public double solve(UnivariateRealFunction f, double min, double max) throws MaxIterationsExceededException, FunctionEvaluationException
Requires that the values of the function at the endpoints have opposite
signs. An IllegalArgumentException
is thrown if this is not
the case.
f
- the function to solvemin
- the lower bound for the interval.max
- the upper bound for the interval.
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 oppositesprivate double solve(UnivariateRealFunction f, double x0, double y0, double x1, double y1, double x2, double y2) throws MaxIterationsExceededException, FunctionEvaluationException
f
- the function to solvex0
- old approximation for the rooty0
- function value at the approximation for the rootx1
- last calculated approximation for the rooty1
- function value at the last calculated approximation
for the rootx2
- bracket point (must be set to x0 if no bracket point is
known, this will force starting with linear interpolation)y2
- function value at the bracket point.
MaxIterationsExceededException
- if the maximum iteration count
is exceeded
FunctionEvaluationException
- if an error occurs evaluating
the function
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |