Newton’s method

Also known as: Newton-Raphson method

On this page 7

Newton’s method, also called the Newton-Raphson method, is an iterative algorithm that finds a root of an equation or a stationary point of a function by repeatedly solving a local quadratic approximation built from the first and second derivatives. Optimization in machine learning and statistics uses it to minimize an objective function: at each step it moves to the minimum of the second-order Taylor model, which gives quadratic convergence near a well-behaved solution.

In artificial intelligence, the pure method is rarely applied to deep networks with millions of parameters, because the Hessian matrix is too large to store and invert. It remains the reference point for a whole family of second-order methods, including quasi-Newton methods, L-BFGS, natural gradient and the iteratively reweighted least squares solver used to fit logistic regression.

How Newton’s method computes each step

Each iteration replaces the objective with a quadratic model around the current point and jumps to that model’s minimum. For a twice-differentiable function f with gradient g and Hessian H at the point x, the model is f(x) + g·d + ½ d·H·d, and setting its derivative to zero gives the Newton step d = −H⁻¹g.

In practice the inverse is never formed explicitly. Software solves the linear system H·d = −g, typically with a Cholesky factorization when H is positive definite. The cost of that solve grows as O(n³) in the number of parameters n, while storing H needs O(n²) memory, which is the central scaling limit of the method.

The table below lists the ingredients of one iteration and what each contributes.

ComponentRole in the stepTypical cost
Gradient gDirection of steepest increaseO(n) storage
Hessian HLocal curvature in every directionO(n²) storage
Linear solveComputes the step d from H and gO(n³) for dense H
Step lengthScales d to guarantee progressA few function evaluations
Stopping testChecks gradient norm or step sizeNegligible
Components of a Newton iteration

Convergence behavior and its conditions

Near a minimum with a positive definite Hessian, Newton’s method converges quadratically: the number of correct digits roughly doubles with every iteration. A solution that gradient descent approaches over thousands of steps is often reached in five to twenty Newton iterations.

This guarantee is local only. Far from the solution the quadratic model can be a poor guide, and the full step may overshoot, oscillate or diverge. When the Hessian is indefinite, as it is near a saddle point of a non-convex objective, the Newton step can point uphill or toward the saddle itself, because the method seeks any stationary point rather than a minimum.

The following comparison places the method among its neighbors in the optimization toolbox.

MethodCurvature informationConvergence rateCost per iteration
Gradient descentNoneLinearO(n)
Newton’s methodExact HessianQuadratic (local)O(n³)
Quasi-Newton (BFGS)Approximated from gradientsSuperlinearO(n²)
L-BFGSLimited-memory approximationSuperlinear in practiceO(mn) with m about 5-20
Conjugate gradientImplicit via search directionsSuperlinear on quadraticsO(n)
Newton’s method compared with related optimizers

Globalization: line search and trust regions

Practical implementations add a globalization strategy so that the method makes progress from poor starting points. The two standard choices are a line search, which shortens the step until a sufficient-decrease rule such as the Armijo or Wolfe conditions holds, and a trust region, which minimizes the quadratic model only inside a radius that grows or shrinks with the model’s accuracy.

Curvature problems need separate treatment. Damped or regularized Newton adds a multiple of the identity, H + λI, which makes the matrix positive definite and interpolates between a Newton step and a gradient step. This is the idea behind the Levenberg-Marquardt algorithm for nonlinear least squares.

VariantKey modificationBest suited to
Damped NewtonStep length from line searchConvex smooth problems
Trust-region NewtonStep limited to a radiusNonconvex or ill-conditioned problems
Levenberg-MarquardtAdds λI to the HessianNonlinear least squares
Gauss-NewtonUses JᵀJ instead of HCurve fitting with small residuals
Newton-CG (truncated)Solves H·d = −g approximatelyLarge sparse problems
Interior-point NewtonNewton steps on barrier problemsConstrained convex optimization
Common Newton variants and when they apply

Uses of Newton’s method in machine learning

The method is most valuable when the parameter count is moderate, from a few to several thousand, and the objective is smooth and convex. Logistic regression is the classic case: its iteratively reweighted least squares solver is exactly Newton’s method on the log-likelihood, and statistical libraries rely on it to produce precise estimates and standard errors.

Further applications include generalized linear models, Gaussian process hyperparameter fitting, interior-point solvers for linear and quadratic programming, and the inner loops of constrained optimization. In deep learning, curvature ideas survive in Hessian-free optimization, which uses conjugate gradient with Hessian-vector products, and in approximations such as K-FAC and the Shampoo optimizer.

  • Choose Newton’s method when n is small, the objective is smooth and high accuracy matters.
  • Choose L-BFGS when n reaches tens of thousands and full-batch gradients are affordable.
  • Choose stochastic gradient methods when data is massive and only noisy gradients are practical.

Limitations and common mistakes

The main drawbacks are cubic cost, quadratic memory and sensitivity to curvature. Stochastic mini-batch estimates of the Hessian are noisy, so the method also fits poorly with the stochastic training that dominates modern neural networks.

SymptomLikely causeRemedy
Iterates divergeFull step from a distant startAdd line search or trust region
Step increases the lossIndefinite HessianRegularize with H + λI
Solve fails or is unstableSingular or ill-conditioned HUse damping or a pseudo-inverse
Runs out of memoryDense Hessian for large nSwitch to L-BFGS or Newton-CG
Converges to a saddleMethod seeks any stationary pointCheck eigenvalues and use negative curvature
Typical failures and their remedies

A frequent misconception is that fast convergence means fast training. Each Newton iteration can cost more than thousands of gradient steps, so the total time is lower only when the Hessian solve is cheap relative to the accuracy gained.

The idea in brief

Imagine standing on a hilly field in fog, looking for the lowest point. A simple strategy is to step downhill a little at a time. Newton’s method is smarter. It measures both the slope and how the ground curves. Then it pictures a smooth bowl that fits the ground nearby and walks straight to the bottom of that bowl.

When you are already close to the valley floor, this works remarkably well. A handful of jumps is often enough. The catch is that measuring the curve in every direction is expensive when there are many directions. Far from the valley, the imagined bowl can also mislead you, so careful versions limit how far each jump may go.

A practical scenario

A credit risk team fits a logistic regression model to predict loan default from 40 features and 200,000 historical loans. The statistical software uses iteratively reweighted least squares, which is Newton’s method applied to the log-likelihood. Each iteration builds a 40 by 40 Hessian from the weighted data, solves one small linear system and updates all coefficients at once.

Starting from zero coefficients, the gradient norm falls from about 10³ to below 10⁻⁸ in seven iterations, and the whole fit takes under a second. The inverse of the final Hessian also gives the standard errors the team needs for regulatory documentation. When the same team later trains a neural network with two million weights, it switches to Adam with mini-batches, because a two-million-square Hessian would never fit in memory.