Skip to main content
© 2026 ePowerAI. All rights reserved.
CoursesContact
eAI
CoursesContact
Week 8: Newton and Quasi-Newton
Adv. Optimization
01Week 1: Optimality Conditions Revisited
02Week 2: Lagrangian Duality in Depth
03Week 3: KKT and Sensitivity
04Week 4: LP, QP, and Conic Form
05Week 5: Semidefinite Programming
06Week 6: Interior-Point Methods
07Week 7: Proximal Methods and ADMM
08Week 8: Newton and Quasi-Newton
09Week 9: Variance Reduction
10Week 10: Large-Batch and Distributed Training
11Week 11: Automatic Differentiation
12Week 12: Sharpness and SAM
13Week 13: Landscapes and Implicit Bias
14Week 14: Capstone — Structure Meets Scale
Week 08· Adv. Optimization· Second-order & scale22 min read

Week 8: Newton and Quasi-Newton

✦Learning Outcomes
  • Write the Newton iteration for smooth unconstrained problems
  • Explain why damping and line search are needed when the pure Newton step fails
  • Describe BFGSBroyden–Fletcher–Goldfarb–Shanno (quasi-Newton) Hessian approximation and the L-BFGS memory trade-off
  • Decide when second-order methods beat AdamAdaptive Moment Estimation (optimizer)
◆Prerequisites

Background: Week 1 (Hessian PSD conditions, strong convexity). Intermediate Optim Week 11 (Newton's method concept). Week 6 (Newton-on-barrier in IPM context). Comfort with solving linear systems.

Later weeks: Newton is the reference method for convergence rate discussions in Weeks 9 (variance reduction) and 14 (scale path).

Newton Step#

Gradient descent uses a first-order Taylor expansion: f(x+Δx)≈f(x)+∇f(x)TΔxf(x + \Delta x) \approx f(x) + \nabla f(x)^T \Delta xf(x+Δx)≈f(x)+∇f(x)TΔx. The model is linear in Δx\Delta xΔx; the step direction is −∇f(x)-\nabla f(x)−∇f(x), independent of curvature.

Newton's method uses a second-order Taylor expansion:

f(x+Δx)≈f(x)+∇f(x)TΔx+12ΔxT∇2f(x)Δxf(x + \Delta x) \approx f(x) + \nabla f(x)^T \Delta x + \tfrac{1}{2} \Delta x^T \nabla^2 f(x) \Delta xf(x+Δx)≈f(x)+∇f(x)TΔx+21​ΔxT∇2f(x)Δx

Minimising this quadratic model in Δx\Delta xΔx (setting derivative to zero) gives the Newton step:

∇2f(x) Δxnt=−∇f(x)\nabla^2 f(x) \, \Delta x_{\text{nt}} = -\nabla f(x)∇2f(x)Δxnt​=−∇f(x)

The Newton step Δxnt\Delta x_{\text{nt}}Δxnt​ is the solution to an n×nn \times nn×n linear system — it incorporates both the gradient direction and the local curvature (Hessian). When ∇2f(x)≻0\nabla^2 f(x) \succ 0∇2f(x)≻0, the step is guaranteed to be a descent direction.

Worked 1D example. f(x)=12ax2f(x) = \tfrac{1}{2}a x^2f(x)=21​ax2 with a>0a > 0a>0. The Newton step from x0x_0x0​ solves f′′(x0)Δx=−f′(x0)f''(x_0) \Delta x = -f'(x_0)f′′(x0​)Δx=−f′(x0​), i.e., a⋅Δx=−ax0a \cdot \Delta x = -a x_0a⋅Δx=−ax0​, giving Δx=−x0\Delta x = -x_0Δx=−x0​. Hence x1=x0+Δx=0x_1 = x_0 + \Delta x = 0x1​=x0​+Δx=0 — the exact minimiser in one step. For quadratic functions with a>0a > 0a>0, Newton converges in one iteration from any starting point.

Worked 2D example. f(x,y)=x2+10y2f(x, y) = x^2 + 10y^2f(x,y)=x2+10y2. The Hessian is ∇2f=(20020)\nabla^2 f = \begin{pmatrix} 2 & 0 \\ 0 & 20 \end{pmatrix}∇2f=(20​020​). The condition number is 20/2=1020/2 = 1020/2=10.

Starting from (10,1)(10, 1)(10,1), the gradient is (20,20)(20, 20)(20,20) and GD with η=0.05\eta = 0.05η=0.05 takes many iterations. Newton: Δx=−(2)−1⋅20=−10\Delta x = -(2)^{-1} \cdot 20 = -10Δx=−(2)−1⋅20=−10, Δy=−(20)−1⋅20=−1\Delta y = -(20)^{-1} \cdot 20 = -1Δy=−(20)−1⋅20=−1, so x1=(0,0)x_1 = (0, 0)x1​=(0,0) — exact in one step. Newton is scale-invariant: the Hessian automatically corrects for differing curvatures along each coordinate.

Quadratic Convergence Intuition#

Newton exhibits quadratic convergence near a minimiser: there exists a constant MMM such that

∥xk+1−x∗∥≤M∥xk−x∗∥2\|x_{k+1} - x^*\| \leq M \|x_k - x^*\|^2∥xk+1​−x∗∥≤M∥xk​−x∗∥2

The error squares at each iteration. If ∥xk−x∗∥=10−2\|x_k - x^*\| = 10^{-2}∥xk​−x∗∥=10−2, the next iterate has error ≈10−4\approx 10^{-4}≈10−4, then 10−810^{-8}10−8, and so on — doubling the number of correct digits per step. Gradient descent, by contrast, is linear: ∥xk+1−x∗∥≤ρ∥xk−x∗∥\|x_{k+1} - x^*\| \leq \rho \|x_k - x^*\|∥xk+1​−x∗∥≤ρ∥xk​−x∗∥ with ρ<1\rho < 1ρ<1, gaining a fixed number of digits per step.

Requirements for quadratic convergence:

  • ∇2f\nabla^2 f∇2f is Lipschitz continuous near x∗x^*x∗
  • ∇2f(x∗)≻0\nabla^2 f(x^*) \succ 0∇2f(x∗)≻0 (the optimum is non-degenerate)
  • The initial point is "close enough" to x∗x^*x∗

The last condition is the catch. Far from the optimum, the Hessian may be indefinite or poorly conditioned, and the pure Newton step can increase the objective. This is why damping and line search are essential in practice.

Damping and Line Search#

Damped Newton modifies the pure step with a line search:

xk+1=xk+αkΔxnt,αk∈(0,1]x_{k+1} = x_k + \alpha_k \Delta x_{\text{nt}}, \quad \alpha_k \in (0, 1]xk+1​=xk​+αk​Δxnt​,αk​∈(0,1]

where αk\alpha_kαk​ is chosen via backtracking to satisfy the Armijo condition:

f(xk+αΔxnt)≤f(xk)+cα∇f(xk)TΔxntf(x_k + \alpha \Delta x_{\text{nt}}) \leq f(x_k) + c \alpha \nabla f(x_k)^T \Delta x_{\text{nt}}f(xk​+αΔxnt​)≤f(xk​)+cα∇f(xk​)TΔxnt​

with c∈(0,0.5)c \in (0, 0.5)c∈(0,0.5). When ∇2f(xk)≻0\nabla^2 f(x_k) \succ 0∇2f(xk​)≻0, ∇f(xk)TΔxnt=−∇f(xk)T(∇2f(xk))−1∇f(xk)<0\nabla f(x_k)^T \Delta x_{\text{nt}} = -\nabla f(x_k)^T (\nabla^2 f(x_k))^{-1} \nabla f(x_k) < 0∇f(xk​)TΔxnt​=−∇f(xk​)T(∇2f(xk​))−1∇f(xk​)<0, so the directional derivative is negative — a descent direction exists, and backtracking finds a stepsize. When close to x∗x^*x∗, αk=1\alpha_k = 1αk​=1 is accepted (full Newton step), and the quadratic convergence kicks in.

When the Hessian is not PD. If ∇2f(xk)\nabla^2 f(x_k)∇2f(xk​) has negative or zero eigenvalues, the Newton direction may point uphill. Practical Newton solvers modify the Hessian:

  • Add a multiple of identity: ∇2f+μI\nabla^2 f + \mu I∇2f+μI (Levenberg–Marquardt).
  • Use a modified Cholesky that perturbs negative eigenvalues to positive.
  • Fall back to gradient descent when the Newton decrement is too large.

BFGS and L-BFGS#

The Hessian is expensive: storing n2n^2n2 entries and solving an n×nn \times nn×n linear system costs O(n3)O(n^3)O(n3) per iteration. Quasi-Newton methods avoid the Hessian entirely, building an approximation Bk≈∇2f(xk)B_k \approx \nabla^2 f(x_k)Bk​≈∇2f(xk​) from gradient changes observed during optimisation.

BFGSBroyden–Fletcher–Goldfarb–Shanno (quasi-Newton) update. Given sk=xk+1−xks_k = x_{k+1} - x_ksk​=xk+1​−xk​ (step) and yk=∇f(xk+1)−∇f(xk)y_k = \nabla f(x_{k+1}) - \nabla f(x_k)yk​=∇f(xk+1​)−∇f(xk​) (gradient change), the BFGS formula updates the inverse Hessian approximation Hk≈(∇2f(xk))−1H_k \approx (\nabla^2 f(x_k))^{-1}Hk​≈(∇2f(xk​))−1:

Hk+1=(I−skykTykTsk)Hk(I−ykskTykTsk)+skskTykTskH_{k+1} = \left(I - \frac{s_k y_k^T}{y_k^T s_k}\right) H_k \left(I - \frac{y_k s_k^T}{y_k^T s_k}\right) + \frac{s_k s_k^T}{y_k^T s_k}Hk+1​=(I−ykT​sk​sk​ykT​​)Hk​(I−ykT​sk​yk​skT​​)+ykT​sk​sk​skT​​

This is a rank-2 update — computationally cheap (O(n2)O(n^2)O(n2)). The direction is dk=−Hk∇f(xk)d_k = -H_k \nabla f(x_k)dk​=−Hk​∇f(xk​). BFGS preserves positive definiteness of HkH_kHk​ when ykTsk>0y_k^T s_k > 0ykT​sk​>0 (the curvature condition), which holds under convexity or with a suitable line search.

L-BFGS (Limited-memory BFGS). Storing the n×nn \times nn×n matrix HkH_kHk​ is still too expensive for large nnn. L-BFGS stores only the last mmm pairs (sk,yk)(s_k, y_k)(sk​,yk​) (typically m=10m = 10m=10–202020), and computes Hk∇f(xk)H_k \nabla f(x_k)Hk​∇f(xk​) implicitly via a two-loop recursion in O(mn)O(mn)O(mn) time and O(mn)O(mn)O(mn) memory. For n=107n = 10^7n=107 (a large deep net), m=10m = 10m=10 pairs cost 10810^8108 doubles (~800 MB) — manageable; n2=1014n^2 = 10^{14}n2=1014 is not.

vs Adam#

| Property | Newton / L-BFGS | AdamAdaptive Moment Estimation (optimizer) | |---|---|---| | Uses curvature | Full or approximated Hessian | Diagonal (element-wise) second-moment estimate | | Per-iteration cost | O(n2)O(n^2)O(n2) (BFGS) or O(mn)O(mn)O(mn) (L-BFGS) | O(n)O(n)O(n) | | Convergence near optimum | Quadratic (Newton) or superlinear (BFGS) | Linear (no acceleration without momentum tuning) | | Works well when | n≲104n \lesssim 10^4n≲104 (Newton) or n≲107n \lesssim 10^7n≲107 (L-BFGS), accurate gradients | nnn is huge, gradients are stochastic, nonconvex | | Sensitive to | Ill-conditioning, nondifferentiability | Learning rate, β1,β2\beta_1, \beta_2β1​,β2​ |

In practice, L-BFGS is competitive with Adam for moderate-scale problems where gradients are computed accurately (full batch or large minibatch). Deep nets with stochastic gradients and n>107n > 10^7n>107 still favour AdamAdaptive Moment Estimation (optimizer) or SGDStochastic Gradient Descent with momentum because L-BFGS's curvature approximation degrades under gradient noise. However, for scientific computing, logistic regression, and moderate-scale ML, L-BFGS is often the faster and more reliable choice.

Exercise · Fill in the blank

For $f(x) = \tfrac{1}{2}a x^2$ with $a > 0$, one Newton step from $x_0 = b$ gives $x_1 = ____$.

Question 1 of 3

The Newton step solves the linear system $ abla^2 f(x) , Delta x = - abla f(x)$. When $ abla^2 f(x) succ 0$, the direction is guaranteed to be a ____ direction.

Browser lab#

Compare Newton's method vs gradient descent on a well-conditioned quadratic (f1f_1f1​) and an ill-conditioned one (f2f_2f2​). Count iterations to reach a tolerance.

python · runs in browser
import numpy as np
import matplotlib.pyplot as plt

def newton_quadratic(Q, x0, tol=1e-8, max_iter=50):
    """Newton on f(x) = 0.5 * x^T Q x."""
    x = x0.copy().astype(float)
    path = [x.copy()]
    for _ in range(max_iter):
        g = Q @ x
        if np.linalg.norm(g) < tol:
            break
        dx = np.linalg.solve(Q, -g)
        x = x + dx
        path.append(x.copy())
    return np.array(path)

def gd_quadratic(Q, x0, eta, tol=1e-8, max_iter=500):
    """Gradient descent on f(x) = 0.5 * x^T Q x."""
    x = x0.copy().astype(float)
    path = [x.copy()]
    for _ in range(max_iter):
        g = Q @ x
        if np.linalg.norm(g) < tol:
            break
        x = x - eta * g
        path.append(x.copy())
    return np.array(path)

# Well-conditioned: Q1 = diag(1, 1)
Q1 = np.diag([1.0, 1.0])
# Ill-conditioned: Q2 = diag(1, 100)
Q2 = np.diag([1.0, 100.0])

x0 = np.array([10.0, 1.0])

# Newton
path_n1 = newton_quadratic(Q1, x0)
path_n2 = newton_quadratic(Q2, x0)

# GD with optimal step size for quadratics
eta1 = 2.0 / (1.0 + 1.0)  # 2/(L+mu)
eta2 = 2.0 / (1.0 + 100.0)

path_g1 = gd_quadratic(Q1, x0, eta1)
path_g2 = gd_quadratic(Q2, x0, eta2)

print(f"Well-conditioned: Newton {len(path_n1)-1} iters, GD {len(path_g1)-1} iters")
print(f"Ill-conditioned: Newton {len(path_n2)-1} iters, GD {len(path_g2)-1} iters")

fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5))

def plot_path(ax, paths, labels, colors, title):
    for path, lbl, clr in zip(paths, labels, colors):
        ax.plot(path[:, 0], path[:, 1], f"{clr}o-", markersize=3, linewidth=1, label=lbl)
    ax.plot(0, 0, "kx", markersize=10)
    ax.set_xlabel("x1")
    ax.set_ylabel("x2")
    ax.set_title(title)
    ax.legend()
    ax.set_aspect("equal")

plot_path(ax1, [path_n1, path_g1], [f"Newton ({len(path_n1)-1})", f"GD ({len(path_g1)-1})"],
          ["b", "r"], "Well-conditioned: $Q = \mathrm{diag}(1,1)$")
plot_path(ax2, [path_n2, path_g2], [f"Newton ({len(path_n2)-1})", f"GD ({len(path_g2)-1})"],
          ["b", "r"], "Ill-conditioned: $Q = \mathrm{diag}(1,100)$")

plt.tight_layout()
plt.show()
← Previous
Week 7: Proximal Methods and ADMM
Next →
Week 9: Variance Reduction
On this page
  • Newton Step
  • Quadratic Convergence Intuition
  • Damping and Line Search
  • BFGS and L-BFGS
  • vs Adam
  • Browser lab