The optimization problem is to minimize f ( x ) {\displaystyle f(\mathbf {x} )} , where x {\displaystyle \mathbf {x} } is a vector in R n {\displaystyle \mathbb {R} ^{n}} , and f {\displaystyle f} is a differentiable scalar function. There are no constraints on the values that x {\displaystyle \mathbf {x} } can take.
The algorithm begins at an initial estimate x 0 {\displaystyle \mathbf {x} _{0}} 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 B k {\displaystyle B_{k}} is an approximation to the Hessian matrix at x k {\displaystyle \mathbf {x} _{k}} , which is updated iteratively at each stage, and ∇ f ( x k ) {\displaystyle \nabla f(\mathbf {x} _{k})} 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 f ( x k + γ p k ) {\displaystyle f(\mathbf {x} _{k}+\gamma \mathbf {p} _{k})} over the scalar γ > 0. {\displaystyle \gamma >0.}
The quasi-Newton condition imposed on the update of B k {\displaystyle B_{k}} is
Let y k = ∇ f ( x k + 1 ) − ∇ f ( x k ) {\displaystyle \mathbf {y} _{k}=\nabla f(\mathbf {x} _{k+1})-\nabla f(\mathbf {x} _{k})} and s k = x k + 1 − x k {\displaystyle \mathbf {s} _{k}=\mathbf {x} _{k+1}-\mathbf {x} _{k}} , then B k + 1 {\displaystyle B_{k+1}} satisfies
which is the secant equation.
The curvature condition s k ⊤ y k > 0 {\displaystyle \mathbf {s} _{k}^{\top }\mathbf {y} _{k}>0} should be satisfied for B k + 1 {\displaystyle B_{k+1}} to be positive definite, which can be verified by pre-multiplying the secant equation with s k T {\displaystyle \mathbf {s} _{k}^{T}} . If the function is not strongly convex, then the condition has to be enforced explicitly e.g. by finding a point xk+1 satisfying the Wolfe conditions, which entail the curvature condition, using line search.
Instead of requiring the full Hessian matrix at the point x k + 1 {\displaystyle \mathbf {x} _{k+1}} to be computed as B k + 1 {\displaystyle B_{k+1}} , the approximate Hessian at stage k is updated by the addition of two matrices:
Both U k {\displaystyle U_{k}} and V k {\displaystyle V_{k}} 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 B k + 1 {\displaystyle B_{k+1}} , the update form can be chosen as B k + 1 = B k + α u u ⊤ + β v v ⊤ {\displaystyle B_{k+1}=B_{k}+\alpha \mathbf {u} \mathbf {u} ^{\top }+\beta \mathbf {v} \mathbf {v} ^{\top }} . Imposing the secant condition, B k + 1 s k = y k {\displaystyle B_{k+1}\mathbf {s} _{k}=\mathbf {y} _{k}} . Choosing u = y k {\displaystyle \mathbf {u} =\mathbf {y} _{k}} and v = B k s k {\displaystyle \mathbf {v} =B_{k}\mathbf {s} _{k}} , we can obtain:8
Finally, we substitute α {\displaystyle \alpha } and β {\displaystyle \beta } into B k + 1 = B k + α u u ⊤ + β v v ⊤ {\displaystyle B_{k+1}=B_{k}+\alpha \mathbf {u} \mathbf {u} ^{\top }+\beta \mathbf {v} \mathbf {v} ^{\top }} and get the update equation of B k + 1 {\displaystyle B_{k+1}} :
Consider the following unconstrained optimization problem minimize x ∈ R n f ( x ) , {\displaystyle {\begin{aligned}{\underset {\mathbf {x} \in \mathbb {R} ^{n}}{\text{minimize}}}\quad &f(\mathbf {x} ),\end{aligned}}} where f : R n → R {\displaystyle f:\mathbb {R} ^{n}\to \mathbb {R} } is a nonlinear objective function.
From an initial guess x 0 ∈ R n {\displaystyle \mathbf {x} _{0}\in \mathbb {R} ^{n}} and an initial guess of the Hessian matrix B 0 ∈ R n × n {\displaystyle B_{0}\in \mathbb {R} ^{n\times n}} the following steps are repeated as x k {\displaystyle \mathbf {x} _{k}} converges to the solution:
Convergence can be determined by observing the norm of the gradient; given some ϵ > 0 {\displaystyle \epsilon >0} , one may stop the algorithm when | | ∇ f ( x k ) | | ≤ ϵ . {\displaystyle ||\nabla f(\mathbf {x} _{k})||\leq \epsilon .} If B 0 {\displaystyle B_{0}} is initialized with B 0 = I {\displaystyle B_{0}=I} , the first step will be equivalent to a gradient descent, but further steps are more and more refined by B k {\displaystyle B_{k}} , the approximation to the Hessian.
The first step of the algorithm is carried out using the inverse of the matrix B k {\displaystyle B_{k}} , 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 B k − 1 {\displaystyle B_{k}^{-1}} is symmetric, and that y k T B k − 1 y k {\displaystyle \mathbf {y} _{k}^{\mathrm {T} }B_{k}^{-1}\mathbf {y} _{k}} and s k T y k {\displaystyle \mathbf {s} _{k}^{\mathrm {T} }\mathbf {y} _{k}} are scalars, using an expansion such as
Therefore, in order to avoid any matrix inversion, the inverse of the Hessian can be approximated instead of the Hessian itself: H k = def B k − 1 . {\displaystyle H_{k}{\overset {\operatorname {def} }{=}}B_{k}^{-1}.} 9
From an initial guess x 0 {\displaystyle \mathbf {x} _{0}} and an approximate inverted Hessian matrix H 0 {\displaystyle H_{0}} the following steps are repeated as x k {\displaystyle \mathbf {x} _{k}} converges to the solution:
In statistical estimation problems (such as maximum likelihood or Bayesian inference), 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.10
The BFGS update formula heavily relies on the curvature s k ⊤ y k {\displaystyle \mathbf {s} _{k}^{\top }\mathbf {y} _{k}} being strictly positive and bounded away from zero. This condition is satisfied when we perform a line search with Wolfe conditions on a convex target. However, some real-life applications (like Sequential Quadratic Programming methods) routinely produce negative or nearly-zero curvatures. This can occur when optimizing a nonconvex target or when employing a trust-region approach instead of a line search. It is also possible to produce spurious values due to noise in the target.
In such cases, one of the so-called damped BFGS updates can be used (see 11) which modify s k {\displaystyle \mathbf {s} _{k}} and/or y k {\displaystyle \mathbf {y} _{k}} in order to obtain a more robust update.
Notable open source implementations are:
Notable proprietary implementations include:
Fletcher, Roger (1987), Practical Methods of Optimization (2nd ed.), New York: John Wiley & Sons, ISBN 978-0-471-91547-8 978-0-471-91547-8 ↩
Dennis, J. E. Jr.; Schnabel, Robert B. (1983), "Secant Methods for Unconstrained Minimization", Numerical Methods for Unconstrained Optimization and Nonlinear Equations, Englewood Cliffs, NJ: Prentice-Hall, pp. 194–215, ISBN 0-13-627216-9 0-13-627216-9 ↩
Byrd, Richard H.; Lu, Peihuang; Nocedal, Jorge; Zhu, Ciyou (1995), "A Limited Memory Algorithm for Bound Constrained Optimization", SIAM Journal on Scientific Computing, 16 (5): 1190–1208, CiteSeerX 10.1.1.645.5814, doi:10.1137/0916069 http://www.ece.northwestern.edu/~nocedal/PSfiles/limited.ps.gz ↩
Broyden, C. G. (1970), "The convergence of a class of double-rank minimization algorithms", Journal of the Institute of Mathematics and Its Applications, 6: 76–90, doi:10.1093/imamat/6.1.76 /wiki/Charles_George_Broyden ↩
Fletcher, R. (1970), "A New Approach to Variable Metric Algorithms", Computer Journal, 13 (3): 317–322, doi:10.1093/comjnl/13.3.317 /wiki/Doi_(identifier) ↩
Goldfarb, D. (1970), "A Family of Variable Metric Updates Derived by Variational Means", Mathematics of Computation, 24 (109): 23–26, doi:10.1090/S0025-5718-1970-0258249-6 /wiki/Donald_Goldfarb ↩
Shanno, David F. (July 1970), "Conditioning of quasi-Newton methods for function minimization", Mathematics of Computation, 24 (111): 647–656, doi:10.1090/S0025-5718-1970-0274029-X, MR 0274029 /wiki/Doi_(identifier) ↩
Fletcher, Roger (1987), Practical methods of optimization (2nd ed.), New York: John Wiley & Sons, ISBN 978-0-471-91547-8 978-0-471-91547-8 ↩
Nocedal, Jorge; Wright, Stephen J. (2006), Numerical Optimization (2nd ed.), Berlin, New York: Springer-Verlag, ISBN 978-0-387-30303-1 978-0-387-30303-1 ↩
Ge, Ren-pu; Powell, M. J. D. (1983). "The Convergence of Variable Metric Matrices in Unconstrained Optimization". Mathematical Programming. 27 (2). 123. doi:10.1007/BF02591941. S2CID 8113073. /wiki/Mathematical_Programming ↩
Jorge Nocedal; Stephen J. Wright (2006), Numerical Optimization ↩
"GNU Scientific Library — GSL 2.6 documentation". www.gnu.org. Retrieved 2020-11-22. https://www.gnu.org/software/gsl/doc/html/index.html ↩
"R: General-purpose Optimization". stat.ethz.ch. Retrieved 2020-11-22. https://stat.ethz.ch/R-manual/R-devel/library/stats/html/optim.html ↩
"scipy.optimize.fmin_bfgs — SciPy v1.5.4 Reference Guide". docs.scipy.org. Retrieved 2020-11-22. https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.fmin_bfgs.html ↩
"scipy.optimize.minimize — SciPy v1.5.4 Reference Guide". docs.scipy.org. Retrieved 2025-01-22. https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html ↩
"Optim.jl Configurable options". julianlsolvers. https://julianlsolvers.github.io/Optim.jl/stable/#user/config/#solver-options ↩