Algebra, Geometry and Trigonometry at a Glance
Convexity, a Simple Idea With Far-Reaching Results
Learn what makes a set or function convex and why that one condition delivers inequalities, separation theorems and easy optima.
Key takeaways
- A set is convex when it contains every segment joining two of its points.
- Overlaps of convex sets are convex, which makes them easy to build from simple constraints.
- A function is convex when its graph never rises above the chord between two of its points.
- For a convex function on a convex set, every local minimum is also a global minimum.
- Separation theorems and corner-point results underpin linear programming and much of economics.
A set is convex if, whenever you pick two points in it, the whole straight segment between them stays inside. A filled disk, a triangle and a cube pass the test. A crescent, a star and a ring fail, because some segment leaves the shape.
That one condition rules out dents and holes, and the payoff is large. Convex sets can be separated by flat boundaries, convex functions have no misleading local valleys, and many hard questions become manageable.
The segment test
The points of the segment from P to Q can be written as (1 − t)P + tQ, with t running from 0 to 1. At t = 0 you are at P, at t = 1 at Q, and at t = 1/2 at the midpoint. So a set S is convex if (1 − t)P + tQ belongs to S whenever P and Q do.
This definition works in a plane, in space or in a space with any number of coordinates. It needs only the ability to add points and scale them, with no mention of length or angle. Convexity therefore survives affine transformations: stretch or shear a convex set and it stays convex.
Note that the condition concerns the filled set. A circle drawn as a thin curve is not convex, while the disk it encloses is. A single point, a line, a half-plane and the whole plane are all convex too.
Building convex sets
The most useful closure property is that the intersection of any collection of convex sets is convex. The proof is one sentence: if two points lie in all the sets, then so does the segment between them, because each set is convex.
A half-plane, such as all points with x + 2y ≤ 4, is convex. So any system of linear inequalities describes a convex region, which, if bounded, is a polygon or polyhedron (possibly a degenerate one).
Unions behave badly. Two separate disks together are not convex. But every set has a convex hull, the smallest convex set containing it. For points on a table, picture a rubber band stretched around pins and released. Constantin Carathéodory showed that in n dimensions, each point of the hull is a weighted average of at most n + 1 of the original points. In the plane, three always suffice.
Convex functions
A function f defined on an interval, or on any convex set, is convex if for all x and y in the domain and all t from 0 to 1:
f((1 − t)x + ty) ≤ (1 − t)·f(x) + t·f(y) In words, the graph lies on or below each chord. The functions x², |x| and eˣ are convex. The sine function is not convex on the whole line. A function whose negative is convex is called concave, like √x for x ≥ 0.
For a function with a second derivative on an interval, convexity is equivalent to f″ ≥ 0 throughout. For differentiable convex functions, the graph also lies above every tangent line.
Test the chord rule with f(x) = x², x = 2, y = 6 and t = 1/2. The left side is 4² = 16. The right side is (4 + 36)/2 = 20. The inequality holds.
Sets and functions are two views of one idea. Take the region on and above the graph of f, called its epigraph. The function is convex exactly when that region is a convex set. For f(x) = x², the region y ≥ x² is the inside of a parabolic bowl, and any segment joining two of its points stays within it.
The second derivative gives quick verdicts. For x⁴ it is 12x², never negative, so the function is convex. For x³ it is 6x, which changes sign, so x³ is convex for x ≥ 0 and concave for x ≤ 0 but neither on the whole line. A function is called strictly convex when the chord inequality is strict for distinct points and 0 < t < 1. Such a function has at most one minimizer.
Inequalities for free
Extending the definition to many points gives Jensen's inequality: for a convex f, the value of f at a weighted average is at most the weighted average of the values, where the weights are nonnegative and add to 1.
Apply it to the convex function −ln x, for positive numbers a and b with equal weights. It says ln((a + b)/2) ≥ (ln a + ln b)/2, and exponentiating gives (a + b)/2 ≥ √(ab). That is the inequality between arithmetic and geometric means, a relative of the comparison in the three classical means.
In probability the same statement reads f(E[X]) ≤ E[f(X)], where E denotes expected value and the expectations exist. With f(x) = x² it shows that a variance can never be negative.
Why optimizers love it
Suppose f is convex on a convex set and a point p is a local minimum, meaning nothing nearby is lower. Then nothing anywhere is lower.
suppose f(q) < f(p) for some q
points near p on the segment to q: x = (1 − t)p + tq, t small and positive
f(x) ≤ (1 − t)·f(p) + t·f(q) < f(p) (convexity)
so p was not a local minimum: contradiction A method that only walks downhill therefore cannot be trapped in a false valley. A minimum might still fail to exist, as for eˣ on the whole line, and there may be many minimizers, forming a convex set. The practical consequences are explored in why convexity helps optimization so much.
Corners and linear programs
Consider a small problem: maximize 3x + 2y subject to x + y ≤ 4, x ≤ 3, x ≥ 0 and y ≥ 0. The allowed region is a convex polygon with four corners.
| Corner | Value of 3x + 2y |
|---|---|
| (0, 0) | 0 |
| (3, 0) | 9 |
| (3, 1) | 11 |
| (0, 4) | 8 |
The maximum is 11, at (3, 1). No interior point can do better, since a linear quantity keeps increasing in some direction until you hit the boundary, and along an edge it is largest at one end. This fact drives linear programming, where the regions may have thousands of dimensions and far too many corners to check one by one.
Separation and common points
If two nonempty convex sets in ordinary space do not overlap, some flat boundary (a line in the plane, a plane in space) has one set on each side. If both sets are closed and at least one is bounded, you can arrange a gap on both sides. Without convexity this fails: no straight line separates a dot from a ring that surrounds it.
At a boundary point of a convex set there is also a supporting line, which touches the set while leaving all of it on one side. Economists read such lines as prices, and the idea reappears as duality in optimization.
Eduard Helly's theorem is another gem. Take finitely many convex sets in the plane, at least three of them. If every three have a point in common, then all of them do. In n dimensions, replace three by n + 1.
Reaching into number theory and beyond
Hermann Minkowski turned convexity on whole numbers. In the plane, a convex region that is symmetric about the origin and has area greater than 4 must contain a point with integer coordinates other than the origin. In n dimensions the threshold is 2ⁿ. This statement gives short proofs of facts such as which primes are sums of two squares.
Convexity also appears in thermodynamics, in the design of statistical estimators, in game theory and in collision detection for computer graphics.
When convexity is missing
Seeing what goes wrong without the condition shows how much it does. A function with two valleys of different depths can trap a downhill search in the shallower one, and no inspection of the nearby ground reveals that a better point exists. A feasible region split into separate pieces forces you to examine the pieces one by one.
Requiring whole-number answers destroys convexity, since the midpoint of two integer points need not be an integer point. That is a basic reason integer programs are generally much harder than their continuous versions. Rounding the continuous answer can give a poor result or even one that breaks a constraint.
A common response is to replace a hard problem by a convex relaxation: enlarge the allowed set to something convex, solve that, and use the answer as a bound. If the relaxed solution happens to satisfy the original requirements, it is optimal for the original problem too, because nothing in the smaller set could beat the best point of the larger one. Much practical optimization alternates between such relaxations and a systematic search.
Common questions
Is every polygon convex?
No. A polygon with an interior angle above 180° has a dent. A simple polygon is convex exactly when every interior angle is at most 180°.
How can I test whether a function is convex?
Check the second derivative if it exists. Otherwise build the function from known convex pieces: sums with nonnegative weights and the maximum of several convex functions are again convex. A product of convex functions need not be.