Hexa Scholar

Why convex problems have no bad local minima

The question

Gradient descent rolls downhill from wherever it starts. On which of four curves can a bad start leave it stuck above the lowest point?

Pick the start yourself; the page runs every step.

  1. 1 SeeHunt for a start that gets stuck.
  2. 2 TryBend one curve with a single number.
  3. 3 ProveBuild the chord argument line by line.
  4. 4 ApplyProblems to check yourself.
Before you start · 3 quick checks on mixing two numbers, the chord test and the sign of a slope, about 3 min

Two ideas before you start

2 ideas

A dip is not always the bottom

Figure: a curve g on [0, 5.5] with two dips, a dashed vertical line at the chosen x and a dashed level line at the height g(x). It needs JavaScript.

Look at

Local minimum, not the lowest point: g(1) ≈ 2.786 is below every other nearby value, but g(4.5) = 1 is lower.

A local minimum is at least as low as every nearby point. A global minimum is at least as low as every point. A curve can have local minima that are not global.

Exact definition

Local and global minimizers. Let \(C\) be a subset of \(\mathbb{R}^n\) and \(f : C \to \mathbb{R}\). A point \(x^* \in C\) is a local minimizer of \(f\) on \(C\) when there is a number \(r \gt 0\) with \(f(x) \ge f(x^*)\) for every \(x \in C\) with \(|x - x^*| \lt r\). It is a global minimizer when \(f(x) \ge f(x^*)\) for every \(x \in C\); then \(f(x^*)\) is the lowest value of \(f\) on \(C\).

On this page a bad local minimum is a local minimizer that is not a global one. The card's curve is the function \(g\) with \[\begin{aligned} g'(x) &= (x - 1)(x - 2.5) \\ &\quad \cdot (x - 4.5), \end{aligned}\] shifted so that its lowest value is 1.

Gradient descent steps downhill

Figure: the parabola q(x) = (x − 3)²/2 and the first four gradient descent steps from x = 8, joined by a dashed path. It needs JavaScript.

Step size η

Step: q′(x) = x − 3 x₁ = 8 − 0.5 · 5 = 5.5

Each step multiplies x − 3 by 0.5: the steps shrink and never cross the bottom.

Gradient descent moves against the slope: the new point is x − η·f′(x), with a step size η. A step from a point with slope 0 does not move, so the method can settle in any dip, not only at the lowest point.

Exact definition

Gradient descent. Let \(f\) be differentiable and fix a step size \(\eta \gt 0\). From a start \(x_0\), gradient descent computes \(x_{k+1} = x_k - \eta f'(x_k)\) for \(k = 0, 1, 2, \dots\); in \(\mathbb{R}^n\) the derivative is replaced by the gradient \(\nabla f\), as in the lesson on the gradient. A point with \(f'(x) = 0\) is a stationary point: the method stays there once it lands on it.

The card uses \(q(x) = \tfrac{1}{2}(x - 3)^2\), so \(q'(x) = x - 3\) and each step multiplies \(x_k - 3\) by \(1 - \eta\).

Fine print: convex sets and convex functions

A set \(C \subseteq \mathbb{R}^n\) is convex when it contains \((1 - t)u + tv\) for every \(u, v \in C\) and every \(t\) with \(0 \le t \le 1\). A function \(f\) on a convex set \(C\) is convex when \[\begin{aligned} &f((1 - t)u + tv) \\ &\le (1 - t)f(u) + tf(v) \end{aligned}\] for all such \(u, v, t\): the graph lies on or below every chord. It is strictly convex when the inequality is strict for \(u \ne v\) and \(0 \lt t \lt 1\). The lesson on convex sets and convex functions has examples.

For a function that is twice differentiable on an open interval, convex is the same as \(f'' \ge 0\) on that interval. A convex problem asks for the lowest value of a convex function over a convex set.

1 See

Hunt for a start that gets stuck

How the page decides

Each round has its own curve \(f\) on \([0, 10]\) and its own step size \(\eta\), chosen so that \(f'(v) - f'(u) \le (v - u)/\eta\) for all \(u \lt v\) in \([0, 10]\). Then the map \(x \mapsto x - \eta f'(x)\) never decreases. So the steps move in one direction, downhill, and approach the nearest point with \(f' = 0\) on that side without ever passing it. In every round \(f'(0) \lt 0\) and \(f'(10) \gt 0\), so that point lies in \([0, 10]\). It is where the page says a start ends, even when the steps only reach it in the limit. The page finds it from the exact stationary points, not from rounding.

A check that fails leaves the round open, and the figure shows the run from your start. A right check, or the button, ends the round. There are four rounds; a table then compares your answers with the right ones. Start over clears everything.

2 Try

Bend one curve with a single number

Two quick questions first. The explorer below them opens once both are answered.

The explorer and its goals open after you answer both questions.

3 Prove

Why a local minimum of a convex function is global

Theorem

Assumptions. \(n \ge 1\); \(C\) is a nonempty convex subset of \(\mathbb{R}^n\); \(f : C \to \mathbb{R}\) is convex; and \(x^* \in C\) is a local minimizer: there is \(r \gt 0\) with \(f(x) \ge f(x^*)\) for every \(x \in C\) with \(|x - x^*| \lt r\).

Conclusion. \(f(y) \ge f(x^*)\) for every \(y \in C\), so \(x^*\) is a global minimizer. Also, the set of global minimizers of \(f\) on \(C\) is convex.

Setup. Points \(y \in C\) with \(|y - x^*| \lt r\) already have \(f(y) \ge f(x^*)\). So fix \(y \in C\) with \(|y - x^*| \ge r\), put \[t = \frac{r}{2\,|y - x^*|},\] so that \(0 \lt t \le \tfrac{1}{2}\), and let \(z = (1 - t)x^* + ty\), a point on the segment from \(x^*\) to \(y\).

Each option is one step about the \(C\), \(f\), \(x^*\), \(r\), \(y\), \(t\) and \(z\) of the theorem. Pick the one that is true for every set, function and point the theorem covers.

4 Apply

Problems

Each problem has hints and a full solution. Exact answers can be typed as a decimal or a fraction.

Key point Before you trust a local minimum, check convexity: of the set you search over and of the function. Then any local minimum, found by a zero of the derivative, by gradient descent or by checking a boundary point, is the lowest value. Without convexity a method that only looks nearby can stop in a dip above the lowest point.
Level Advanced undergraduate Prerequisites Convex sets and convex functions; gradient descent (explained on the Start tab) Time ~40 min

Related lessons: Critical points classifies a stationary point by its second derivatives, which says what happens nearby; convexity is what turns that into a statement about the whole set. Lagrange multipliers finds candidates on a constraint curve. Jensen's inequality uses the same chord inequality with expectations.

Further reading