| java.lang.Object org.apache.commons.math.analysis.UnivariateRealSolverUtils
UnivariateRealSolverUtils | public class UnivariateRealSolverUtils (Code) | | Utility routines for
UnivariateRealSolver objects.
version: $Revision: 155427 $ $Date: 2005-02-26 06:11:52 -0700 (Sat, 26 Feb 2005) $ |
Method Summary | |
public static double[] | bracket(UnivariateRealFunction function, double initial, double lowerBound, double upperBound) This method attempts to find two values a and b satisfying
-
lowerBound <= a < initial < b <= upperBound
-
f(a) * f(b) < 0
If f is continuous on [a,b], this means that a
and b bracket a root of f. | public static double[] | bracket(UnivariateRealFunction function, double initial, double lowerBound, double upperBound, int maximumIterations) This method attempts to find two values a and b satisfying
-
lowerBound <= a < initial < b <= upperBound
-
f(a) * f(b) < 0
If f is continuous on [a,b], this means that a
and b bracket a root of f. | public static double | midpoint(double a, double b) Compute the midpoint of two values.
Parameters: a - first value. Parameters: b - second value. | public static double | solve(UnivariateRealFunction f, double x0, double x1) Convenience method to find a zero of a univariate real function. | public static double | solve(UnivariateRealFunction f, double x0, double x1, double absoluteAccuracy) Convenience method to find a zero of a univariate real function. |
bracket | public static double[] bracket(UnivariateRealFunction function, double initial, double lowerBound, double upperBound) throws ConvergenceException, FunctionEvaluationException(Code) | | This method attempts to find two values a and b satisfying
-
lowerBound <= a < initial < b <= upperBound
-
f(a) * f(b) < 0
If f is continuous on [a,b], this means that a
and b bracket a root of f.
The algorithm starts by setting
a := initial -1; b := initial +1, examines the value of the
function at a and b and keeps moving
the endpoints out by one unit each time through a loop that terminates
when one of the following happens:
-
f(a) * f(b) < 0 -- success!
-
a = lower and b = upper
-- ConvergenceException
-
Integer.MAX_VALUE iterations elapse
-- ConvergenceException
Note: this method can take
Integer.MAX_VALUE iterations to throw a
ConvergenceException. Unless you are confident that there
is a root between lowerBound and upperBound
near initial, it is better to use
UnivariateRealSolverUtils.bracket(UnivariateRealFunction,double,double,double,int) ,
explicitly specifying the maximum number of iterations.
Parameters: function - the function Parameters: initial - initial midpoint of interval being expanded tobracket a root Parameters: lowerBound - lower bound (a is never lower than this value) Parameters: upperBound - upper bound (b never is greater than thisvalue) a two element array holding {a, b} throws: ConvergenceException - if a root can not be bracketted throws: FunctionEvaluationException - if an error occurs evaluating thefunction throws: IllegalArgumentException - if function is null, maximumIterationsis not positive, or initial is not between lowerBound and upperBound |
bracket | public static double[] bracket(UnivariateRealFunction function, double initial, double lowerBound, double upperBound, int maximumIterations) throws ConvergenceException, FunctionEvaluationException(Code) | | This method attempts to find two values a and b satisfying
-
lowerBound <= a < initial < b <= upperBound
-
f(a) * f(b) < 0
If f is continuous on [a,b], this means that a
and b bracket a root of f.
The algorithm starts by setting
a := initial -1; b := initial +1, examines the value of the
function at a and b and keeps moving
the endpoints out by one unit each time through a loop that terminates
when one of the following happens:
-
f(a) * f(b) < 0 -- success!
-
a = lower and b = upper
-- ConvergenceException
-
maximumIterations iterations elapse
-- ConvergenceException
Parameters: function - the function Parameters: initial - initial midpoint of interval being expanded tobracket a root Parameters: lowerBound - lower bound (a is never lower than this value) Parameters: upperBound - upper bound (b never is greater than thisvalue) Parameters: maximumIterations - maximum number of iterations to perform a two element array holding {a, b}. throws: ConvergenceException - if the algorithm fails to find a and bsatisfying the desired conditions throws: FunctionEvaluationException - if an error occurs evaluating the function throws: IllegalArgumentException - if function is null, maximumIterationsis not positive, or initial is not between lowerBound and upperBound |
midpoint | public static double midpoint(double a, double b)(Code) | | Compute the midpoint of two values.
Parameters: a - first value. Parameters: b - second value. the midpoint. |
solve | public static double solve(UnivariateRealFunction f, double x0, double x1, double absoluteAccuracy) throws ConvergenceException, FunctionEvaluationException(Code) | | Convenience method to find a zero of a univariate real function. A default
solver is used.
Parameters: f - the function Parameters: x0 - the lower bound for the interval Parameters: x1 - the upper bound for the interval Parameters: absoluteAccuracy - the accuracy to be used by the solver a value where the function is zero throws: ConvergenceException - if the iteration count is exceeded throws: FunctionEvaluationException - if an error occurs evaluating thefunction throws: IllegalArgumentException - if f is null, the endpoints do not specify a valid interval, or the absoluteAccuracy is not valid for thedefault solver |
|
|