fminbfgs
Unconstrained minimization of a function of more than one variable by the BFGS method.
(fm,xm,success)=fminbfgs(optfunc,xin)
(fm,xm,success)=fminbfgs(optfunc,xin,showit,itmax,tol)
Inputs
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.
Outputs
fm The estimated minimum value.
xm The estimated location of the minimum.
success True if the optimization was deemed to be successful. False otherwise.


Description
The function optfunc should be of the form
    (f,DF)=optfunc(x)
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.


Example
>>// 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
>end
>>A=[2 3; 4 1],A=A*A', b=[3 4]'
>>
>>(fm,xm)=fminbfgs(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