TactivergeLite

Lite / Independent Engineering Research / Week 25

Newton's method, momentum and constraints

Gradient descent takes 200 steps down a narrow valley. Newton's method takes one. What is it using that gradient descent ignores?

About 45 min · 3 goals · Checked by automated tests · Full interactive version

Why should I care?

Real optimisation problems are ill-conditioned and constrained: a motor's current is limited, a beam's stress must stay below yield. Second-order methods, momentum and penalties are the standard tools, and knowing their costs lets you choose one sensibly.

Predict

Newton's method on f(x) = ½·a·x² from any starting point takes how many steps to reach the minimum?

  1. One
  2. About 1/a
  3. About a
  4. It never reaches it exactly
Guess first, then reveal

Newton fits a quadratic to f at the current point and jumps to its minimum. If f is itself quadratic, the fit is exact: x₁ = x₀ − a·x₀/a = 0. For other functions it converges quadratically near the minimum: the number of correct digits roughly doubles each step.

Discover

In the Code Lab, minimise f(x, y) = ½(x² + 10y²) three ways from (2, 1): gradient descent with the best stable η, gradient descent with momentum (β = 0.8), and Newton's method. Count iterations to reach f < 10⁻⁶. Then add a penalty μ·max(0, x − 0.5)² and see how the answer depends on μ.

What the interactive shows (text version)

The derivation fits a quadratic at the current point and jumps to its minimum: x ← x − f'(x)/f''(x). The penalty example gives x* = (2 + μ)/(1 + μ), approaching the constraint x = 1 as μ grows.

You can also open the interactive on the full site when you have a faster connection.

Understand

Second-order methods

Newton's method uses curvature to scale the step in every direction, so ill-conditioning disappears: the narrow valley looks round to it. Quasi-Newton methods (BFGS, L-BFGS) build an approximation of H⁻¹ from gradients, keeping most of the benefit at a fraction of the cost, and are the default for medium-sized smooth problems.

Momentum

Momentum keeps a running velocity: v ← βv − η∇f, x ← x + v. Along a consistent shallow direction the steps add up; across a steep gully they cancel. It is cheap, first-order, and widely used in training neural networks.

Constraints by penalty

To minimise f subject to g(x) ≤ 0, minimise f(x) + μ·max(0, g(x))². Small μ: the constraint is violated a little. Large μ: closer to feasible, but the problem becomes ill-conditioned and slow. Increase μ gradually, or use exact methods (Lagrange multipliers, projection, interior-point solvers) when feasibility is non-negotiable, such as a safety limit.

Explain it another way

Intuitive

Gradient descent feels the slope; Newton also feels how the slope is changing, so it can guess where the bottom is and jump there.

Technical

Convergence: gradient descent is linear with rate depending on κ; Newton is locally quadratic; momentum (heavy ball) improves the dependence from κ to roughly √κ on quadratics. Penalty methods converge to the constrained optimum as μ → ∞.

Mathematical

1-D penalty: minimise (x − 2)² subject to x ≤ 1, using (x − 2)² + μ(x − 1)² for x > 1. Setting the derivative to zero: x* = (2 + μ)/(1 + μ). μ = 1: 1.5; μ = 10: 1.09; μ = 100: 1.0099 → 1 as μ → ∞.

Applied

Model-predictive controllers solve a small constrained quadratic programme every few milliseconds, with actuator limits as constraints, using interior-point or active-set solvers designed for exactly this structure.

Derivation: Newton's step from a quadratic model
  1. Near x_k, approximate f by its second-order Taylor expansion: f(x_k + d) ≈ f(x_k) + f'(x_k)·d + ½f''(x_k)·d².

  2. Minimise the model over d: derivative f'(x_k) + f''(x_k)·d = 0, so d = −f'(x_k)/f''(x_k).

  3. Newton update: x_{k+1} = x_k − f'(x_k)/f''(x_k). In n dimensions: x ← x − H⁻¹∇f, with H the Hessian.

  4. It is Newton–Raphson root-finding applied to f' = 0, which you met for solving equations.

  5. Cost: forming and solving with H is O(n²) memory and O(n³) time per step, versus O(n) for a gradient step. Trade: few expensive steps versus many cheap ones.

  6. Caution: if f'' ≤ 0 the step can go uphill; practical methods add a line search or modify H.

Worked example 1

Newton's method on f(x) = x⁴ from x₀ = 1. Find x₁ and x₂.

f' = 4x³, f'' = 12x². Step: x − 4x³/12x² = x − x/3 = (2/3)x. x₁ = 0.667, x₂ = 0.444. Only linear here, because f'' = 0 at the minimum: Newton's quadratic speed needs f'' > 0 there.

Common mix-ups

Practice

Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.

Practice 3. For a problem with a million variables, why is plain Newton's method rarely used?
Practice 4. A motor current must never exceed its rating. Which constraint method suits that best?

Apply it

Write a short comparison table (method, iterations, cost per iteration, total work) for the three methods you ran in the Code Lab. Then argue which you would use for 10, 10,000 and 10 million variables.

Reflect

Which method would you trust for a safety-critical constraint, and what evidence would convince a reviewer?

Write your answer on paper or in your own notes. Lite never stores what you write.

← Convexity and local minimaBenchmarking computer systems fairly →