UnivariateSolver objects.
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static double[] | Returns: a two-element array holding a and b.Function. function, double Initial midpoint of interval being expanded to
bracket a root. initial, double Lower bound (a is never lower than this value) lowerBound, double Upper bound (b never is greater than this
value). upperBound)This method simply calls |
| public static double[] | Returns: a two element array holding a and b.Function. function, double Initial midpoint of interval being expanded to
bracket a root. initial, double Lower bound (a is never lower than this value). lowerBound, double Upper bound (b never is greater than this
value). upperBound, int Maximum number of iterations to perform maximumIterations)This method simply calls |
| public static double[] | Returns: a two element array holding the bracketing values.function to check function, final double Initial midpoint of interval being expanded to
bracket a root. initial, final double Lower bound (a is never lower than this value). lowerBound, final double Upper bound (b never is greater than this
value). upperBound, final double additive offset used to compute bounds sequence (must be strictly positive) q, final double multiplicative factor used to compute bounds sequence r, final int Maximum number of iterations to perform maximumIterations)This method attempts to find two values a and b satisfying
|
| public static double | Returns: a root approximation, on the specified side of the exact rootmaximal number of new evaluations of the function
(evaluations already done for finding the root should have already been subtracted
from this number) maxEval, final UnivariateFunction function to solve f, final BracketedUnivariateSolver<UnivariateFunction> bracketing solver to use for shifting the root bracketing, final double original root found by a previous non-bracketing solver baseRoot, final double minimal bound of the search interval min, final double maximal bound of the search interval max, final AllowedSolution the kind of solutions that the root-finding algorithm may
accept as solutions. allowedSolution)Force a root found by a non-bracketing solver to lie on a specified side, as if the solver were a bracketing one. |
| public static boolean | Returns: true if the function values have opposite signs at the
given points.Function. function, final double Lower endpoint. lower, final double Upper endpoint. upper)Check whether the interval bounds bracket a root. |
| public static boolean | Returns: true if the arguments form an increasing sequence.First number. start, final double Second number. mid, final double Third number. end)Check whether the arguments form a (strictly) increasing sequence. |
| public static double | Returns: the midpoint.first value. a, double second value. b)Compute the midpoint of two values. |
| public static double | Returns: a value where the function is zero.Function. function, double Lower bound for the interval. x0, double Upper bound for the interval. x1)Convenience method to find a zero of a univariate real function. |
| public static double | Returns: a value where the function is zero.Function. function, double Lower bound for the interval. x0, double Upper bound for the interval. x1, double Accuracy to be used by the solver. absoluteAccuracy)Convenience method to find a zero of a univariate real function. |
| public static void | verifyBracketing(UnivariateFunction
Function. function, final double Lower endpoint. lower, final double Upper endpoint. upper)Check that the endpoints specify an interval and the end points bracket a root. |
| public static void | verifyInterval(final double
Lower endpoint. lower, final double Upper endpoint. upper)Check that the endpoints specify an interval. |
| public static void | verifySequence(final double
Lower endpoint. lower, final double Initial value. initial, final double Upper endpoint. upper)Check that |
| UnivariateSolverUtils | back to summary |
|---|---|
| private UnivariateSolverUtils() Class contains only static methods. | |
| bracket | back to summary |
|---|---|
| public static double[] bracket(UnivariateFunction function, double initial, double lowerBound, double upperBound) throws NullArgumentException, NotStrictlyPositiveException, NoBracketingException This method simply calls Note this method can take
| |
| bracket | back to summary |
|---|---|
| public static double[] bracket(UnivariateFunction function, double initial, double lowerBound, double upperBound, int maximumIterations) throws NullArgumentException, NotStrictlyPositiveException, NoBracketingException This method simply calls
| |
| bracket | back to summary |
|---|---|
| public static double[] bracket(final UnivariateFunction function, final double initial, final double lowerBound, final double upperBound, final double q, final double r, final int maximumIterations) throws NoBracketingException This method attempts to find two values a and b satisfying
f is continuous on [a,b], this means that a
and b bracket a root of f.
The algorithm checks the sign of \( f(l_k) \) and \( f(u_k) \) for increasing values of k, where \( l_k = max(lower, initial - \delta_k) \), \( u_k = min(upper, initial + \delta_k) \), using recurrence \( \delta_{k+1} = r \delta_k + q, \delta_0 = 0\) and starting search with \( k=1 \). The algorithm stops when one of the following happens:
If different signs are found at first iteration (
Interval expansion rate is tuned by changing the recurrence parameters
As a rule of thumb, when the location of the root is expected to be approximately known
within some error margin,
As an example, if we consider the trivial function
| |
| forceSide | back to summary |
|---|---|
| public static double forceSide(final int maxEval, final UnivariateFunction f, final BracketedUnivariateSolver<UnivariateFunction> bracketing, final double baseRoot, final double min, final double max, final AllowedSolution allowedSolution) throws NoBracketingException Force a root found by a non-bracketing solver to lie on a specified side, as if the solver were a bracketing one.
| |
| isBracketing | back to summary |
|---|---|
| public static boolean isBracketing(UnivariateFunction function, final double lower, final double upper) throws NullArgumentException Check whether the interval bounds bracket a root. That is, if the values at the endpoints are not equal to zero, then the function takes opposite signs at the endpoints.
| |
| isSequence | back to summary |
|---|---|
| public static boolean isSequence(final double start, final double mid, final double end) Check whether the arguments form a (strictly) increasing sequence.
| |
| midpoint | back to summary |
|---|---|
| public static double midpoint(double a, double b) Compute the midpoint of two values.
| |
| solve | back to summary |
|---|---|
| public static double solve(UnivariateFunction function, double x0, double x1) throws NullArgumentException, NoBracketingException Convenience method to find a zero of a univariate real function. A default solver is used.
| |
| solve | back to summary |
|---|---|
| public static double solve(UnivariateFunction function, double x0, double x1, double absoluteAccuracy) throws NullArgumentException, NoBracketingException Convenience method to find a zero of a univariate real function. A default solver is used.
| |
| verifyBracketing | back to summary |
|---|---|
| public static void verifyBracketing(UnivariateFunction function, final double lower, final double upper) throws NullArgumentException, NoBracketingException Check that the endpoints specify an interval and the end points bracket a root.
| |
| verifyInterval | back to summary |
|---|---|
| public static void verifyInterval(final double lower, final double upper) throws NumberIsTooLargeException Check that the endpoints specify an interval.
| |
| verifySequence | back to summary |
|---|---|
| public static void verifySequence(final double lower, final double initial, final double upper) throws NumberIsTooLargeException Check that
| |