fmins
Unconstrained minimization of a function of more than one variable by the Nelder-Mead method.
(fm,xm)=fmins(optfunc,xin)
(fm,xm)=fmins(optfunc,xin,showit,maxstarts,tol,maxfeval)
Inputs
optfunc The function to be minimized. See below.
xin Initial estimate of the simplex enclosing the point at which the optimum occurs.
showit Optional. If true, the progress of iterations is printed. Default value is false.
maxstarts Optional. Maximum number of starting points to seek the minimum. The default value if 5.
maxfeval Optional. Maximum number of function evaluations for each starting point. The default value if 200.
tol Optional. Required accuracy of the solution. Defaults to 1.e-6.
Outputs
fm The estimated minimum value.
xm The estimated location of the minimum.


Description
The function optfunc should be of the form
    f=optfunc(x)
which returns, for the given input x , the value of the function.

If the gradient of the function can be easily computed, the function fminbfgs may be faster.

The second input should preferably be a set of points that form a simplex which encloses or is near the estimated minimum. (Note that in two dimensions, a simplex is a triangle, and in a space of higher dimensions, n, it is a convex hull of n+1 affinely independent points.) The points should be specified as an nX(n+1) matrix.




Example

>>function func(x)
>>/*
>>See http://math.fullerton.edu/mathews/n2003/neldermead/NelderMeadMod/Links/NelderMeadMod_lnk_4.html 
>>*/
>>  y=x[2];x=x[1]
>>   return x/4+5x^2+x^4-9x^2*y+3y^2+2y^4
>>end
>>xin=[0 .1 -.1;-.2 .1 .1];
>>[fm,xm]=fmins($func,xin,null,null,1.e-8)
>>printf("Estimated Minimum is %12.8f at the point [%12.8f %12.8f]\n",
		fm,xm[1],xm[2]);
Estimated Minimum is  -0.0031272525777023 at the point [ -0.0250360908189253   0.0009402078250463]

>>// Solve A*x=b for positive definite A by function minimization
>>class QuadForm
>  var A, b
>  function QuadForm(A, b)
>     this.A=A;
>     this.b=b;
>  end
>  function (f)=()(x)
>     f=.5*(x'*A*x)-b'*x
>  end
>end
>>A=[2 3; 4 1],A=A*A', b=[3 4]'
>>
>>(fm,xm)=fmins(new QuadForm(A,b),rand(2,1))
>>xm
    0.0700
    0.1900

>>fm
   -0.4850
>>A\b  // should be identical to xm
    0.0700
    0.1900