Convexity and Optimisation Landscapes

One slider turns a bowl into a mountain range. Watch gradient descent succeed, then watch the same algorithm get stuck.

Convexity and Optimisation Landscapes

This module needs JavaScript: the numbers are computed in the page rather than recorded.

Worth knowing

A function is convex if the straight line between any two points on it never dips below the curve.
Convex means every local minimum is the global minimum. There is nowhere to get stuck.
Set bumpiness to zero and every starting point finds the same answer. Raise it and the starting point decides.
Neural network losses are wildly non-convex, and train well anyway — which needed explaining, and largely has been.

Overview

The chord condition

A set is convex when the line segment between any two of its points stays inside it. A function f is convex when its graph lies at or below every chord between two points:

f(tx + (1−t)y) ≤ tf(x) + (1−t)f(y),   0 ≤ t ≤ 1

For a twice-differentiable one-variable function, f″(x) ≥ 0 everywhere on an interval is sufficient for convexity there. For a multivariable function, the Hessian must be positive semidefinite throughout the convex domain.

In this guide
  1. Why it helps—and what it cannot promise
  2. Test convexity and understand the guarantee
  3. Try this above
  4. Sources and next steps

Convexity and Optimisation

Convexity rules out hidden local minima: for a convex objective, every local minimum is global.

Why it helps—and what it cannot promise

For a convex objective, any local minimum is global. This makes optimisation easier to reason about, though a minimum may still be non-unique and an algorithm may converge slowly. Many deep-learning objectives are non-convex; gradient methods can still find useful solutions, but convex guarantees do not apply. See gradients and Hessians.

A learning rate controls update size, not convexity. On a simple quadratic, too large a step can oscillate or diverge even though the objective is convex.

Test convexity and understand the guarantee

For one variable, a nonnegative second derivative throughout an interval implies convexity there. For a twice-differentiable multivariable function, a positive-semidefinite Hessian throughout a convex domain is a sufficient test. For f(x)=x², f″=2, so every chord lies above the bowl and any local minimum is global. By contrast, a function with multiple dips can have local minima that are not global.

Convexity is a property of both the objective and its domain. A convex objective on a non-convex feasible set does not automatically give the same global guarantee. Even when the problem is convex, the minimum can be non-unique, lie at a boundary, or be difficult for a poor algorithm to reach. Gradient descent can diverge on a convex quadratic if its step size is too large. Convexity gives a landscape guarantee; it does not guarantee that a particular numerical procedure succeeds. Constrained problems introduce additional conditions; see Lagrange multipliers.

Try this above

Compare a bowl-shaped curve with a curve that has multiple dips. Move the optimiser step size and observe convergence separately from the shape of the objective.

For a convex differentiable function, the tangent at x lies below the function everywhere in its domain: f(y)≥f(x)+∇f(x)·(y−x). This gives a supporting lower bound that helps prove optimality. If ∇f(x)=0, then f(y)≥f(x) for all y, so x is a global minimiser. For a non-convex objective, zero gradient alone gives no such guarantee. This distinction is why a stationary point check is enough in some convex problems but only a candidate check in general optimisation.

For a convex differentiable function, a point with zero gradient is a global minimum, but a boundary-constrained optimum may have a nonzero gradient pointing outside the feasible set. This is why constraints require additional conditions such as Lagrange multipliers or KKT conditions. A convex function may also have a flat valley of multiple minimisers. Separate the geometry of the objective from the geometry of the feasible set before applying an optimisation guarantee.

Sources and next steps

Check yourself

0 of 3

Answer without scrolling back up.

  1. What is the defining consequence of convexity for optimisation?

  2. Why are saddle points more common than local minima in high dimensions?

  3. Descent diverges on a perfectly convex bowl. What is the likely cause?

Cheat sheet

Convexity and Optimisation Landscapes

See why a convex loss surface has one minimum and gradient descent always finds it. Then watch what happens when convexity disappears.

MATHS · vizlearn.in/maths/convexity_and_optimisation.html

About the author

Ashish Jangra builds and maintains VizLearn. Every module here is written and the visualisation behind it hand-built, so the numbers in a readout come from the same code that draws the picture. Corrections are genuinely welcome and get priority over everything else — if a page states something wrong, or an animation misrepresents what the algorithm does, get in touch.

Teaching a course with this? Individual teachers can use it freely; for a whole department or programme, see institutional licences.