Module 9 · Lesson 9.1
Convexity — Why Some Bowls Have Only One Bottom
Learn what makes a function "convex," and why that single property guarantees gradient descent will find the true minimum instead of getting stuck.
Intuition
Picture a mixing bowl sitting on a table. No matter where you drop a marble in, it rolls down to the same single lowest point. Now picture an egg carton lying on its side. Drop a marble in and it settles into whichever dimple it happened to land near — there are many "lowest points," and most of them aren't the lowest point overall.
Core concept
A function is convex when its graph looks like the bowl: exactly one valley, and it curves upward everywhere. A function is non-convex when its graph looks like the egg carton: several valleys, and rolling downhill only promises you'll reach a low point, not the lowest one. This distinction matters enormously in AI: training a model is just rolling a ball downhill on a loss surface. If that surface is convex, you're guaranteed to reach the best possible answer. If it isn't, you might get stuck in a mediocre dip and never know a better one exists elsewhere.
That's the whole test. Pick any two points on the curve, draw a straight line (a "chord") between them. If that chord never dips below the curve — for every pair of points, not just this one — the function is convex.
Interactive Lab
Drag the two point sliders to pick different spots on the curve, and drag the bumpiness slider to warp the bowl into an egg carton. Watch when the chord starts dipping below the curve — that's the moment convexity breaks.
Chord lies above the curve everywhere between x₁ and x₂ — convex here.
Key Idea
This is the formal definition of convexity. The left side is the function's actual value at some blend of two points. The right side is the same blend applied to the two function outputs — in other words, the chord. The inequality says the curve is never above its own chord. If this holds for every possible pair of points and every blend between them, the function is convex, and any point where the slope is zero is guaranteed to be the single global minimum.
Think Further
- Why does having "only one bottom" make gradient descent's job so much easier for a convex loss function compared to a non-convex one?
- A straight line, $f(x) = 3x + 1$, technically satisfies the convexity inequality with equality. Is a straight line convex? What does this tell you about the difference between convex and "strictly convex"?
- Modern neural network loss landscapes are famously non-convex, yet training still often works well in practice. What does that suggest about the relationship between "guaranteed to find the global minimum" and "good enough in practice"?
Show suggested answers
- Because there's no risk of settling into a "good enough" valley that isn't the best one — every downhill step leads toward the same unique minimum, so the algorithm can't get trapped.
- Yes, a straight line is convex (the chord and the curve are literally the same line, so the inequality holds as an equality). It just isn't strictly convex, which would require the curve to bend strictly upward, ruling out flat stretches and guaranteeing a genuinely unique minimum rather than a whole flat region of equally good minima.
- It suggests that in very high-dimensional spaces, most of the "dips" a network finds during training tend to be nearly as good as the true global minimum, even without a convexity guarantee — so practitioners often accept "very good" over provably optimal.