Unconstrained minimization of a function of more than one variable by the BFGS method.
optfunc The function to be minimized. See below.
xin Initial estimate of the point at which the optimum occurs.
showit Optional. If true, the progress of iterations is printed. Default value is false.
itmax Optional. Maximum number of allowed iterations. Defaults to 200.
tol Optional. Required accuracy of the solution. Defaults to 1.e-8.
fm The estimated minimum value.
xm The estimated location of the minimum.
success True if the optimization was deemed to be successful. False otherwise.

The function optfunc should be of the form
which returns, for the given input x , the function value f and its gradient DF .

Note that DF should be a row vector, with DF[1,i] being the partial derivative of the function with respect to x[i] .

For minimization of a function of several variables without the need to compute the gradient, use fmins.

>>// 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,DF)=()(x)
>     f=.5*(x'*A*x)-b'*x
>     DF=(A*x-b)'
>  end
>>A=[2 3; 4 1],A=A*A', b=[3 4]'
>>(fm,xm)=fminbfgs(new QuadForm(A,b),rand(2,1))

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