# Newton's method in optimization

Last updated A comparison of gradient descent (green) and Newton's method (red) for minimizing a function (with small step sizes). Newton's method uses curvature information (i.e. the second derivative) to take a more direct route.

In calculus, Newton's method is an iterative method for finding the roots of a differentiable function F, which are solutions to the equation F (x) = 0. As such, Newton's method can be applied to the derivative f of a twice-differentiable function f to find the roots of the derivative (solutions to f ′(x) = 0), also known as the critical points of f. These solutions may be minima, maxima, or saddle points; see section "Several variables" in Critical point (mathematics) and also section "Geometric interpretation" in this article. This is relevant in optimization, which aims to find (global) minima of the function f.

## Newton's Method

The central problem of optimization is minimization of functions. Let us first consider the case of univariate functions, i.e., functions of a single real variable. We will later consider the more general and more practically useful multivariate case.

Given a twice differentiable function $f:\mathbb {R} \to \mathbb {R}$ , we seek to solve the optimization problem

$\min _{x\in \mathbb {R} }f(x).$ Newton's method attempts to solve this problem by constructing a sequence $\{x_{k}\}$ from an initial guess (starting point) $x_{0}\in \mathbb {R}$ that converges towards a minimizer $x_{*}$ of $f$ by using a sequence of second-order Taylor approximations of $f$ around the iterates. The second-order Taylor expansion of f around $x_{k}$ is

$f(x_{k}+t)\approx f(x_{k})+f'(x_{k})t+{\frac {1}{2}}f''(x_{k})t^{2}.$ The next iterate $x_{k+1}$ is defined so as to minimize this quadratic approximation in $t$ , and setting $x_{k+1}=x_{k}+t$ . If the second derivative is positive, the quadratic approximation is a convex function of $t$ , and its minimum can be found by setting the derivative to zero. Since

$\displaystyle 0={\frac {\rm {d}}{{\rm {d}}t}}\left(f(x_{k})+f'(x_{k})t+{\frac {1}{2}}f''(x_{k})t^{2}\right)=f'(x_{k})+f''(x_{k})t,$ the minimum is achieved for

$t=-{\frac {f'(x_{k})}{f''(x_{k})}}.$ Putting everything together, Newton's method performs the iteration

$x_{k+1}=x_{k}+t=x_{k}-{\frac {f'(x_{k})}{f''(x_{k})}}.$ ## Geometric interpretation

The geometric interpretation of Newton's method is that at each iteration, it amounts to the fitting of a parabola to the graph of $f(x)$ at the trial value $x_{k}$ , having the same slope and curvature as the graph at that point, and then proceeding to the maximum or minimum of that parabola (in higher dimensions, this may also be a saddle point), see below. Note that if $f$ happens to be a quadratic function, then the exact extremum is found in one step. Applying this simple observation to simple quadratic cost functions, we obtain different behaviour of Newton's method:

- For the function $f(x)=x^{2}$ , which has a global minimum at 0, Newton's method will converge to 0 after 1 step.

- For the function $f(x)=-x^{2}$ , which has a global maximum at 0, Newton's method will converge to 0 after 1 step.

## Higher dimensions

The above iterative scheme can be generalized to $d>1$ dimensions by replacing the derivative with the gradient (different authors use different notation for the gradient, including $f'(x)=\nabla f(x)=g_{f}(x)\in \mathbb {R} ^{d}$ ), and the reciprocal of the second derivative with the inverse of the Hessian matrix (different authors use different notation for the Hessian, including $f''(x)=\nabla ^{2}f(x)=H_{f}(x)\in \mathbb {R} ^{d\times d}$ ). One thus obtains the iterative scheme

$x_{k+1}=x_{k}-[f''(x_{k})]^{-1}f'(x_{k}),\qquad k\geq 0.$ Often Newton's method is modified to include a small step size $0<\gamma \leq 1$ instead of $\gamma =1$ :

$x_{k+1}=x_{k}-\gamma [f''(x_{k})]^{-1}f'(x_{k}).$ This is often done to ensure that the Wolfe conditions, or much simpler and efficient Armijo's condition, are satisfied at each step of the method. For step sizes other than 1, the method is often referred to as the relaxed or damped Newton's method.

## Convergence

If f is a strongly convex function with Lipschitz Hessian, then provided that $x_{0}$ is close enough to $x_{*}=\arg \min f(x)$ , the sequence $x_{0},x_{1},x_{2},\dots$ generated by Newton's method will converge to the (necessarily unique) minimizer $x_{*}$ of $f$ quadratically fast.  That is,

$\|x_{k+1}-x_{*}\|\leq {\frac {1}{2}}\|x_{k}-x_{*}\|^{2},\qquad \forall k\geq 0.$ ## Computing the Newton direction

Finding the inverse of the Hessian in high dimensions to compute the Newton direction $h=-(f''(x_{k}))^{-1}f'(x_{k})$ can be an expensive operation. In such cases, instead of directly inverting the Hessian, it is better to calculate the vector $h$ as the solution to the system of linear equations

$[f''(x_{k})]h=-f'(x_{k})$ which may be solved by various factorizations or approximately (but to great accuracy) using iterative methods. Many of these methods are only applicable to certain types of equations, for example the Cholesky factorization and conjugate gradient will only work if $f''(x_{k})$ is a positive definite matrix. While this may seem like a limitation, it is often a useful indicator of something gone wrong; for example if a minimization problem is being approached and $f''(x_{k})$ is not positive definite, then the iterations are converging to a saddle point and not a minimum.

On the other hand, if a constrained optimization is done (for example, with Lagrange multipliers), the problem may become one of saddle point finding, in which case the Hessian will be symmetric indefinite and the solution of $x_{k+1}$ will need to be done with a method that will work for such, such as the $LDL^{\top }$ variant of Cholesky factorization or the conjugate residual method.

There also exist various quasi-Newton methods, where an approximation for the Hessian (or its inverse directly) is built up from changes in the gradient.

If the Hessian is close to a non-invertible matrix, the inverted Hessian can be numerically unstable and the solution may diverge. In this case, certain workarounds have been tried in the past, which have varied success with certain problems. One can, for example, modify the Hessian by adding a correction matrix $B_{k}$ so as to make $f''(x_{k})+B_{k}$ positive definite. One approach is to diagonalize the Hessian and choose $B_{k}$ so that $f''(x_{k})+B_{k}$ has the same eigenvectors as the Hessian, but with each negative eigenvalue replaced by $\epsilon >0$ .

An approach exploited in the Levenberg–Marquardt algorithm (which uses an approximate Hessian) is to add a scaled identity matrix to the Hessian, $\mu I$ , with the scale adjusted at every iteration as needed. For large $\mu$ and small Hessian, the iterations will behave like gradient descent with step size $1/\mu$ . This results in slower but more reliable convergence where the Hessian doesn't provide useful information.

## Some caveats

Newton's method, in its original version, has several caveats:

First: It does not work if the Hessian is not invertible. This is clear from the very definition of Newton's method, which requires taking the inverse of the Hessian.

Second: It may not converge at all, but can enter a cycle having more than 1 point. See the section "Failure analysis" in Newton's method.