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 SeeHunt for a start that gets stuck.
- 2 TryBend one curve with a single number.
- 3 ProveBuild the chord argument line by line.
- 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 ideasA 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.
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: 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.
Hunt for a start that gets stuck
- Drag the round handle along the curve to choose a start x₀, or focus it and use the arrow keys (steps of 0.1; Page Up and Page Down move by 1).
- Press Check: this start gets stuck when you think gradient descent from x₀ ends above the lowest value of the curve.
- Think no start can get stuck on this curve? Press No start 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.
| Round | Your answer | Right answer | Match |
|---|
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.
Explorer: change a
Move \(a\) with the slider. The page draws \(f(x) = x^4 + ax^2 + x\), shades where \(f'' \lt 0\), and marks the points where \(f' = 0\).
Goals
How the page finds the stationary points
The stationary points solve \(f'(x) = 4x^3 + 2ax + 1 = 0\). This cubic has three different real zeros exactly when its discriminant is positive, which here means \(-\tfrac{1}{2}a^3 - \tfrac{27}{16} \gt 0\). The page finds the zeros with the trigonometric formula for a cubic, polishes them with Newton steps, and rounds the values in the tiles to three decimals.
Why a local minimum of a convex function is global
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.
- At most one lowest point when \(f\) is strictly convex. If \(u \ne w\) were two global minimizers with value \(m\), strict convexity would give \[\begin{aligned} &f(\tfrac{1}{2}u + \tfrac{1}{2}w) \\ &\lt \tfrac{1}{2}f(u) + \tfrac{1}{2}f(w) = m, \end{aligned}\] a value below the lowest one.
- A zero of the gradient is enough. Let \(C\) be open and convex and \(f\) convex and differentiable on \(C\). The convexity inequality of line 3, written for any \(x, y \in C\) and \(0 \lt t \le 1\), rearranges to \[\begin{aligned} &\frac{f(x + t(y - x)) - f(x)}{t} \\ &\le f(y) - f(x). \end{aligned}\] Letting \(t\) decrease to 0 gives \(f(y) \ge f(x) + \nabla f(x)\cdot(y - x)\). So a point with \(\nabla f(x) = 0\) is a global minimizer. On a set that is not open, the lowest point can sit on the boundary with \(\nabla f \ne 0\), as in the scratch work.
- Without convexity. The second-derivative test of the lesson on critical points certifies a local minimum only. Rounds 2 and 4 of stage 1, and \(a \lt -\tfrac{3}{2}\) in stage 2, have local minima that are not global.
- Constraints. Let \(C\) be the set of points \(x\) with \(g_1(x) \le 0, \dots, g_k(x) \le 0\), where every \(g_i\) is convex. Then \(C\) is convex, because each set \(\{g_i \le 0\}\) is convex and an intersection of convex sets is convex. A curved equality constraint such as \(x^2 + y^2 = 1\), as in the lesson on Lagrange multipliers, does not give a convex set, so the theorem says nothing there; the candidates have to be compared.
Problems
Each problem has hints and a full solution. Exact answers can be typed as a decimal or a fraction.
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
- S. Boyd and L. Vandenberghe, Convex Optimization, section 4.2, “Convex optimization.”
- J. Nocedal and S. J. Wright, Numerical Optimization, chapter 2, “Fundamentals of unconstrained optimization.”