TactivergeLite

Lite / Independent Engineering Research / Week 25

Convexity and local minima

Two engineers run the same optimiser on the same design problem and get different answers. Who is wrong?

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

Why should I care?

Whether a problem is convex decides whether an optimiser's answer can be trusted. Least squares, many control and resource-allocation problems are convex; neural network training, mechanical design and placement usually are not. Research engineers say which kind they solved.

Predict

On f(x, y) = (x² − 1)² + ½y², gradient descent starts at x = −0.3. Where does it end?

  1. x = 1
  2. x = −1
  3. x = 0
  4. It depends on η only
Guess first, then reveal

f has two minima, at x = ±1, separated by a hump at x = 0. Starting left of the hump, the slope leads to x = −1. Start at x = +0.3 and you reach +1. Both are equally good here; in general they need not be.

Discover

Choose the double well. Try start points from x₀ = −2 to +2. Record which minimum each reaches. Then return to the bowl and confirm every start reaches the same point. What property of the surface makes the difference?

What the interactive shows (text version)

On the double-well surface f = (x² − 1)² + ½y², paths starting with negative x end at x = −1, positive x at x = +1. On the round bowl, every start ends at the centre.

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

Understand

Convex functions

f is convex if the straight line between any two points on its graph lies on or above the graph: f(θx + (1 − θ)y) ≤ θf(x) + (1 − θ)f(y). For twice-differentiable f this means f'' ≥ 0 (in 1-D) or a positive semi-definite Hessian. x², |x|, eˣ and ½xᵀAx with A positive semi-definite are convex.

Why convexity is precious

For a convex function on a convex set, every local minimum is a global minimum, and gradient methods with a sensible step converge to it from any start. You can also certify optimality: a zero gradient proves you are done.

Living with non-convexity

Non-convex functions can have many local minima, saddle points and flat regions. Practical responses: multiple random starts (report the spread of results), good initial guesses from physics, convex relaxations that give bounds, and global methods (simulated annealing, genetic algorithms) for small problems. Never present one run of a non-convex optimiser as 'the optimum'.

Explain it another way

Intuitive

A single smooth bowl has one bottom; a landscape of hills and hollows has many. A ball rolls to whichever hollow is nearest.

Technical

Convex optimisation problems (linear, quadratic, second-order cone, semidefinite programmes) have mature solvers with optimality certificates. Non-convex problems are generally NP-hard to solve globally.

Mathematical

f(x) = (x² − 1)²: f'(x) = 4x(x² − 1), f''(x) = 12x² − 4. f'' < 0 for |x| < 1/√3 ≈ 0.577, so f is not convex there; x = 0 is a local maximum and x = ±1 are minima.

Applied

Choosing gear ratios, link lengths or PID gains for best performance is often non-convex. Engineers run many starts, plot the objective landscape when it is low-dimensional, and check that the chosen design is robust to small changes.

Worked example 1

Is f(x) = x⁴ − 2x² convex?

f''(x) = 12x² − 4, negative for |x| < 0.577. Not convex. It has minima at x = ±1 and a local maximum at x = 0, just like the double well.

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 1. Which function is convex on all real x?
Practice 2. Your optimiser returns a point with zero gradient on a convex objective. What can you conclude?

Practice 5. You tune a robot arm design with a non-convex objective. What is the honest report?

Apply it

Run gradient descent on the double well from 21 evenly spaced starts between −2 and 2 (in the explorer or the Code Lab). Make a table of start → end point. Where is the boundary between the basins, and why there?

Reflect

Which optimisation in your own work was convex, and which only looked like it?

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

← Gradient descent and the learning rateNewton's method, momentum and constraints →