x² is convex
f(2) = 4 ≤ (f(1) + f(3))/2 = 5
Midpoint below the chord.
A function is convex if for : the chord lies on or above the graph. For differentiable this means .
This page is easier if you are comfortable with:
Test with , , : . The function has , so it is convex (the second derivative, concavity and inflection). But is not convex on all of : with , , , is larger than .
The key property: for a convex function every local minimum is a global minimum, and the set of minimisers is convex. That is why convex problems can be solved reliably (gradient descent, Newton's method, the KKT conditions, LP duality). Sums and maxima of convex functions are convex.
Convexity gives Jensen's inequality (Jensen's inequality) and hence AM–GM. It appears in probability (variance via ), in the KL divergence (KL divergence) and in the existence of minimisers on compact sets (Heine–Borel and compactness).
A convex function curves upwards so that any chord lies above the graph.
The chord is above the curve between the two points.
These examples are worked by hand, step by step, so you can compare your own working.
Test convexity of at , , : compare and the chord value.
Find the sign of for at .
Test at , , .
A few situations come up again and again. Knowing them saves time and helps you spot answers that cannot be right.
f(2) = 4 ≤ (f(1) + f(3))/2 = 5
Midpoint below the chord.
f(1) = 2.718 ≤ (f(0) + f(2))/2 = 4.19
Chord above the curve.
f(2) = 1.414 ≥ (f(1) + f(3))/2 = 1.366
Inequality reversed.
f″ ≥ 0 everywhere ⇒ convex
x²: f″ = 2.
f is convex if f(λx + (1 − λ)y) ≤ λf(x) + (1 − λ)f(y) for λ ∈ [0, 1]. For twice-differentiable f this holds iff f″ ≥ 0 (or the Hessian is positive semi-definite).
Check convexity of x² with points 1 and 3.
Check eˣ with points 0 and 2 at x = 1.
Is √x convex? Test points 1 and 3.
Is f = xy convex? Find the Hessian determinant.
f(mid) ≥ chord average ✗
f(mid) ≤ chord average for convex ✓
Convex curves lie below chords.
one pair proves convexity ✗
must hold for all pairs ✓
Use f″ ≥ 0.
convex if f″(0) ≥ 0 ✗
f″ ≥ 0 everywhere ✓
Global condition.
x² is concave ✗
x² is convex ✓
Convex ∪-shaped.
Try each one on paper, then open the answer. Use the solver above to see the full working.
2
12
8
4
4
-1
Unlimited fresh questions with instant marking. Choose a level, work it out on paper, then type your answer.
Solve: …
One whose chords lie above its graph.
Check f″ ≥ 0 (Hessian PSD).
Yes.
Any local minimum is global.
KKT conditions.
gradient descent.
More in Numerical methods and optimisation and the formula sheets.