Skip to content
Tactiverge

School/✦ Research Engineer/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

1.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.

  • ◇ Derive Newton's step x ← x − f'(x)/f''(x) from a quadratic model and compare its convergence with gradient descent.
  • ◇ Explain momentum as a fix for ill-conditioned valleys.
  • ◇ Handle a constraint with a penalty term and explain the trade-off in the penalty weight.

2.Predict

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

Guess first. Being wrong here is how the surprise works.

3.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 μ.

Can't use the interactive? Read a description instead

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.

4.Checkpoint: guided practice

Check what you just discovered before going on. Hints appear after a wrong answer.

Practice 1

Apply one step of Newton's method to f(x) = 3x² − 12x + 1 from x₀ = 10. What is x₁?

5.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

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

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

  • Second-order methods are always better.
    ✓ They take fewer steps, but each costs far more; for huge problems cheap first-order steps win.
  • A penalty enforces the constraint exactly.
    ✓ Only in the limit μ → ∞; at finite μ the solution sits slightly outside.

6.Practice on your own

Practice, not a test. Wrong answers get a hint and another try.

Practice 2

Minimise (x − 2)² subject to x ≤ 1 with the penalty μ(x − 1)² for x > 1 and μ = 9. What x does the penalised problem give?

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?

Practice 5 · a fresh version every time

Minimise f(x) = 2(x − 1)² by gradient descent with learning rate η = 0.05, starting from x₀ = 5. What is x after 4 steps?

7.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.

8.Reflect

Concepts: Optimisation and gradient descent · Root finding and iterative methods · Matrices and linear transformations