A function is convex on an interval when every chord of its graph lies on or above the graph; for a twice differentiable function this means f′′≥0. Jensen's inequality says that for a convex f
Lesson 1 of 3Show all lessonsHide
Try the code and the simulations beside the lesson.
What you will be able to do
say what convex and concave mean, and test a function with its second derivative;
state Jensen's inequality, with weights, and its equality case;
use Jensen to prove AM-GM and to bound sums in a triangle.
A rope between two posts
Hang a rope between two posts. It sags below the straight line from post to post. A graph shaped like that, a bowl, is called convex. Every chord, the segment joining two points of the graph, lies on or above the graph.
Convex and concave
A function f is convex on an interval if, for any x and y in it and any t with 0≤t≤1,
f(tx+(1−t)y)≤tf(x)+(1−t)f(y).
The left side is the curve at a point between x and y; the right side is the chord above it. A function is concave if the inequality goes the other way. A word of warning: some school texts, and IB, say "concave up" for convex and "concave down" for concave.
The second derivative test. If f′′(x)≥0 on an interval, f is convex there. If f′′(x)≤0, it is concave. For example:
x2, ex, x1 (for x>0) and xlnx (for x>0) are convex;
lnx and x (for x>0), and sinx on [0,π], are concave.
The convex curve y = x squared / 4 in blue for x from -4 to 4. A red chord joins the points of the curve above x = -3 and x = 3.5. Above the midpoint of the two x values, a green dot on the chord sits higher than an orange dot on the curve, and a dashed segment between them is labelled gap.
Jensen's inequality
Let f be convex on an interval, let x1,…,xn be in it, and let w1,…,wn be weights: not negative, with sum 1. Then
f(w1x1+⋯+wnxn)≤w1f(x1)+⋯+wnf(xn).
With equal weights: f(nx1+⋯+xn)≤nf(x1)+⋯+f(xn). If f′′>0 on the interval, equality holds only when all the xi with positive weight are equal. For a concave f the sign turns round.
For two points this is the definition. For more points, induction works: combine the first n−1 points into their own weighted mean, then use the two-point case.
AM-GM in one line
The logarithm is concave, because (lnx)′′=−x21<0. Jensen for a concave function gives
ln(na1+⋯+an)≥nlna1+⋯+lnan=lnna1⋯an.
Since ln is increasing, the arithmetic mean is at least the geometric mean. With weights, the same line gives weighted AM-GM, which course 1 proved only for rational weights.
Power means. For 0<p<q, the function xq/p is convex. Jensen applied to the numbers aip gives Mp≤Mq, the power mean inequality of course 1.
Bounds in a triangle
In a triangle A+B+C=π, and sin is concave on [0,π]. Jensen gives
3sinA+sinB+sinC≤sin3A+B+C=sin3π=23.
So sinA+sinB+sinC≤233, with equality for the equilateral triangle. Many olympiad and ISI problems about triangles work this way.
Practise with new numbers
Try it in Python
The program checks Jensen's inequality for the convex function xlnx on random lists. Then it tries many random triangles and keeps the largest value of sinA+sinB+sinC.
Common mistakes
Using Jensen outside the interval.sin is concave on [0,π] only. Check that every point lies where the function has the right shape.
Getting the direction wrong. Convex: value at the mean is at most the mean of the values. Concave: at least.
Weights that do not add up to 1. Scale them first.
Mixing the words. "Convex" in this course means "concave up" in some books.
Remember these
Convex: every chord is on or above the graph; f′′≥0 is enough.
Jensen: f(∑wixi)≤∑wif(xi) for convex f.
lnx concave gives AM-GM; xq/p convex gives the power means.
In a triangle, sinA+sinB+sinC≤233.
Check yourself
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
Is f(x)=e2x convex? Use the second derivative.
Use Jensen with f(x)=x2 to show 2a2+b2≥(2a+b)2.
Where is f(x)=x3 convex, and where is it concave?
Positive numbers a, b, c add up to 3. Use Jensen with f(x)=x1 to find the least value of a1+b1+c1.
In a triangle, what is the greatest value of sinA+sinB+sinC, and for which triangle?
References
Steele, The Cauchy-Schwarz Master Class, Chapter 6, on convexity and Jensen's inequality.
OpenStax, Calculus Volume 1, Chapter 4, section 4.5 on concavity and the second derivative test.
Enroll free in Convexity, Jensen and Inequality Techniques
Every lesson is open to read. Enrolling also lets you:
Mark lessons done and carry on where you stopped.
Take the tests of this lesson and its course.
Count the course towards the certificate for its chapter.