FMINV Function
Minimizes a function f (x) of n variables using a quasi-Newton method.
Usage
result = FMINV(f, n)
Input Parameters
f—A scalar string specifying a user-supplied function to evaluate the function to be minimized. The f function accepts the following parameter and returns the computed function value at the point:
*x—The point at which the function is evaluated.
n—The number of variables.
Returned Value
result—The minimum point x of the function. If no value can be computed, NaN is returned.
Keywords
Double—If present and nonzero, double precision is used.
FScale—A scalar containing the function scaling. Keyword FScale is used mainly in scaling the gradient. See keyword Tol_Grad for more detail. (Default: FScale = 1.0)
FValue—The name of a variable into which the value of the function at the computed solution is stored.
Grad—A scalar string specifying a user-supplied function to compute the gradient. This function accepts the following parameter and returns the computed gradient at the point:
*x—The point at which the gradient is evaluated.
Ihess—The Hessian initialization parameter. If Ihess is zero, the Hessian is initialized to the identity matrix; otherwise, it is initialized to a diagonal matrix containing max ( f (t), fs ) * si on the diagonal, where t = XGuess, fs = FScale, and s = XScale. (Default: Ihess = 0)
Itmax—The maximum number of iterations. (Default: Itmax = 100)
Max_Evals—The maximum number of function evaluations. (Default: Max_Evals = 400)
Max_Grad—The maximum number of gradient evaluations. (Default: Max_Grad = 400)
Max_Step—The maximum allowable step size.
(Default: Max_Step = 1000max (ε1, ε2), where:
s = XScale, and t = XGuess)
N_Digit—The number of good digits in the function. (Default: machine dependent)
Tol_Grad—The scaled gradient tolerance. The i-th component of the scaled gradient at x is calculated as:
s = XScale, and  fs = FScale.
(Default:  Tol_Grad = ε1/2  (ε1/3  in double), where ε is the machine precision)
Tol_Rfcn—The relative function tolerance.
(Default: Tol_Rfcn = max (10-10, ε2/3), max (10-20, ε2/3) in double)
Tol_Step—The scaled step tolerance. The i-th component of the scaled step between two points x and y is computed as:
where s = XScale. (Default:  Tol_Step = ε2/3)
XGuess—An array with n components containing an initial guess of the computed solution. (Default: XGuess (*) = 0)
XScale—An array with n components containing the scaling vector for the variables. Keyword XScale is used mainly in scaling the gradient and the distance between two points. See keywords Tol_Grad and Tol_Step for more detail. (Default: XScale (*) = 1.0)
Discussion
FMINV uses a quasi-Newton method to find the minimum of a function f (x) of n variables. The problem is stated below:
Given a starting point xc, the search direction is computed according to the formula:
d = –B–1gc
where B is a positive definite approximation of the Hessian and gc is the gradient evaluated at xc.
A line search is then used to find a new point
xn = xc + λd , λ > 0
such that:
f(xn) f(xc)αgTd
where  α ∈(0, 0.5). Finally, the optimality condition ||g(x)|| ≤ ε is checked, where ε is a gradient tolerance.
When optimality is not achieved, B is updated according to the BFGS formula:
where s = xnxc and y = gngc. Another search direction is then computed to begin the next iteration. For more details, refer to Dennis and Schnabel (1983).
In this implementation, the first stopping criterion for FMINV occurs when the norm of the gradient is less than the given gradient tolerance Tol_Grad. The second stopping criterion for FMINV occurs when the scaled distance between the last two steps is less than the step tolerance Tol_Step.
Since by default, a finite-difference method is used to estimate the gradient for some single-precision calculations, an inaccurate estimate of the gradient may cause the algorithm to terminate at a noncritical point. In such cases, high-precision arithmetic is recommended or keyword Grad is used to provide more accurate gradient evaluation.
Example
 
In this example, the function f(x) = 100 ( x2x12)2 + ( 1 – x1)2 is minimized using FMINV.
.RUN
; Define the function.
FUNCTION f, x
xn = x
xn(0) = x(1) - x(0)^2
xn(1) = 1 - x(0)
RETURN, 100 * xn(0)^2 + xn(1)^2
END
% Compiled module: F.
; Compute the minimum.
xmin = FMINV("f", 2)
PM, xmin, Title = 'Solution:'
; PV-WAVE prints the following:
; Solution:
; 0.999986
; 0.999971
PM, f(xmin), Title = 'Function value:'
; PV-WAVE prints the following:
; Function value:
; 2.09543e-10
See Also