public class Optimization
extends java.lang.Object
Constructor and Description |
---|
Optimization() |
Modifier and Type | Method and Description |
---|---|
static void |
main(java.lang.String[] args) |
static double |
optimize(UnivariateFunction f,
double ax,
double bx)
Brent's minimization function with default tolerance (1e-10)
|
static double |
optimize(UnivariateFunction f,
double ax,
double bx,
double tol,
int maxiter)
Richard Brent's function minimization routine.
Wikipedia's link Adapted from Netlib's fmin. Also looked at Numerical Methods in C, 2nd ed. |
static double |
zeroin(UnivariateFunction f,
double ax,
double bx,
double tol,
int maxiter)
************************************************************************
C math library
function ZEROIN - obtain a function zero within the given range
Output
Zeroin returns an estimate for the root with accuracy
4*EPSILON*abs(x) + tol
Algorithm
G.Forsythe, M.Malcolm, C.Moler, Computer methods for mathematical
computations.
|
public static final double optimize(UnivariateFunction f, double ax, double bx)
f
- ax
- bx
- public static final double optimize(UnivariateFunction f, double ax, double bx, double tol, int maxiter)
f
- the function to minimizeax
- lower boundbx
- upper boundtol
- tolerancemaxiter
- the maximum number of iterationspublic static final double zeroin(UnivariateFunction f, double ax, double bx, double tol, int maxiter)
************************************************************************ C math library function ZEROIN - obtain a function zero within the given range Output Zeroin returns an estimate for the root with accuracy 4*EPSILON*abs(x) + tol Algorithm G.Forsythe, M.Malcolm, C.Moler, Computer methods for mathematical computations. M., Mir, 1980, p.180 of the Russian edition The function makes use of the bisection procedure combined with the linear or quadric inverse interpolation. At every step program operates on three abscissae - a, b, and c. b - the last and the best approximation to the root a - the last but one approximation c - the last but one or even earlier approximation than a that 1) |f(b)| <= |f(c)| 2) f(b) and f(c) have opposite signs, i.e., b and c confine the root At every step Zeroin selects one of the two new approximations, the former being obtained by the bisection procedure and the latter resulting in the interpolation (if a,b, and c are all different the quadric interpolation is utilized, otherwise the linear one). If the latter (i.e. obtained by the interpolation) point is reasonable (i.e. lies within the current interval [b,c] not being too close to the boundaries) it is accepted. The bisection result is used in the other case. Therefore, the range of uncertainty is ensured to be reduced at least by the factor 1.6 NOTE: uniroot() --> do_zeroin2() --- in ../main/optimize.c ~~~~~~~~~~~~~~~~~~
f
- The function whose zero is soughtax
- Root will be sought for within a range [ax,bx]bx
- tol
- Acceptable tolerance for the root value. May be specified as 0.0 to cause the program to find the root as accurate as possible.maxiter
- Max. iterationspublic static void main(java.lang.String[] args)