The optimization problem is to minimize, where is a vector in, and is a differentiable scalar function. There are no constraints on the values that can take. The algorithm begins at an initial estimate for the optimal value and proceeds iteratively to get a better estimate at each stage. The search direction pk at stage k is given by the solution of the analogue of the Newton equation: where is an approximation to the Hessian matrix, which is updated iteratively at each stage, and is the gradient of the function evaluated at xk. A line search in the direction pk is then used to find the next point xk+1 by minimizing over the scalar The quasi-Newton condition imposed on the update of is Let and, then satisfies, which is the secant equation. The curvature condition should be satisfied for to be positive definite, which can be verified by pre-multiplying the secant equation with. If the function is not strongly convex, then the condition has to be enforced explicitly. Instead of requiring the full Hessian matrix at the point to be computed as, the approximate Hessian at stage k is updated by the addition of two matrices: Both and are symmetric rank-one matrices, but their sum is a rank-two update matrix. BFGS and DFP updating matrix both differ from its predecessor by a rank-two matrix. Another simpler rank-one method is known as symmetric rank-one method, which does not guarantee the positive definiteness. In order to maintain the symmetry and positive definiteness of, the update form can be chosen as. Imposing the secant condition,. Choosing and, we can obtain: Finally, we substitute and into and get the update equation of :
Algorithm
From an initial guess and an approximate Hessian matrix the following steps are repeated as converges to the solution:
Obtain a direction by solving.
Perform a one-dimensional optimization to find an acceptable stepsize in the direction found in the first step, so.
Set and update.
.
.
denotes the objective function to be minimized. Convergence can be checked by observing the norm of the gradient,. If is initialized with, the first step will be equivalent to a gradient descent, but further steps are more and more refined by, the approximation to the Hessian. The first step of the algorithm is carried out using the inverse of the matrix, which can be obtained efficiently by applying the Sherman–Morrison formula to the step 5 of the algorithm, giving This can be computed efficiently without temporary matrices, recognizing that is symmetric, and that and are scalars, using an expansion such as In statistical estimation problems, credible intervals or confidence intervals for the solution can be estimated from the inverse of the final Hessian matrix. However, these quantities are technically defined by the true Hessian matrix, and the BFGS approximation may not converge to the true Hessian matrix.
Notable implementations
The large scale nonlinear optimization software Artelys Knitro implements, among others, both BFGS and L-BFGS algorithms.
The GSL implements BFGS as gsl_multimin_fdfminimizer_vector_bfgs2.
In the MATLAB Optimization Toolbox, the fminunc function uses BFGS with cubic line search when the problem size is set to "medium scale."
In R, the BFGS algorithm is implemented as an option of the base function optim.
In SciPy, the scipy.optimize.fmin_bfgs function implements BFGS. It is also possible to run BFGS using any of the L-BFGS algorithms by setting the parameter L to a very large number.