Unconstrained minimization of a function of more than one variable by the Nelder-Mead method.
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.
fm The estimated minimum value.
xm The estimated location of the minimum.

The function optfunc should be of the form
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.


>>function func(x)
>>  y=x[2];x=x[1]
>>   return x/4+5x^2+x^4-9x^2*y+3y^2+2y^4
>>xin=[0 .1 -.1;-.2 .1 .1];
>>printf("Estimated Minimum is %12.8f at the point [%12.8f %12.8f]\n",
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
>>A=[2 3; 4 1],A=A*A', b=[3 4]'
>>(fm,xm)=fmins(new QuadForm(A,b),rand(2,1))

>>A\b  // should be identical to xm