HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →
Live examsInternational live exams are comingTell us which exam you want first. Timed practice papers are open now.See what is coming →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Space Science and Astronomy
  • Earth and Environmental Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
Convexity, Jensen and Inequality Techniques
  1. 1Convex functions and Jensen's inequality
  2. 2The tangent line trick and sums of squares
  3. 3The triangle inequality and polynomial bounds
  1. Mathematics
  2. /Convexity, Jensen and Inequality Techniques
  3. /Convex functions and Jensen's inequality

Course 29.3·Lesson 1 of 3

Convex functions and Jensen's inequality

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′′≥0f'' \ge 0f′′≥0. Jensen's inequality says that for a convex fff

Lesson 1 of 3Show all lessonsHide
Convexity, Jensen and Inequality Techniques
  1. 1Convex functions and Jensen's inequality
  2. 2The tangent line trick and sums of squares
  3. 3The triangle inequality and polynomial bounds

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 fff is convex on an interval if, for any xxx and yyy in it and any ttt with 0≤t≤10 \le t \le 10≤t≤1,

f(tx+(1−t)y) ≤ tf(x)+(1−t)f(y).\displaystyle f\big(tx + (1 - t)y\big) \ \le\ t f(x) + (1 - t) f(y).f(tx+(1−t)y) ≤ tf(x)+(1−t)f(y).

The left side is the curve at a point between xxx and yyy; 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)≥0f''(x) \ge 0f′′(x)≥0 on an interval, fff is convex there. If f′′(x)≤0f''(x) \le 0f′′(x)≤0, it is concave. For example:

  • x2x^2x2, exe^xex, 1x\dfrac{1}{x}x1​ (for x>0x > 0x>0) and xln⁡xx\ln xxlnx (for x>0x > 0x>0) are convex;
  • ln⁡x\ln xlnx and x\sqrt{x}x​ (for x>0x > 0x>0), and sin⁡x\sin xsinx on [0,π][0, \pi][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 fff be convex on an interval, let x1,…,xnx_1, \dots, x_nx1​,…,xn​ be in it, and let w1,…,wnw_1, \dots, w_nw1​,…,wn​ be weights: not negative, with sum 111. Then

f(w1x1+⋯+wnxn) ≤ w1f(x1)+⋯+wnf(xn).\displaystyle f(w_1 x_1 + \dots + w_n x_n) \ \le\ w_1 f(x_1) + \dots + w_n f(x_n).f(w1​x1​+⋯+wn​xn​) ≤ w1​f(x1​)+⋯+wn​f(xn​).

With equal weights: f(x1+⋯+xnn)≤f(x1)+⋯+f(xn)nf\left(\dfrac{x_1 + \dots + x_n}{n}\right) \le \dfrac{f(x_1) + \dots + f(x_n)}{n}f(nx1​+⋯+xn​​)≤nf(x1​)+⋯+f(xn​)​. If f′′>0f''> 0f′′>0 on the interval, equality holds only when all the xix_ixi​ with positive weight are equal. For a concave fff the sign turns round.

For two points this is the definition. For more points, induction works: combine the first n−1n - 1n−1 points into their own weighted mean, then use the two-point case.

AM-GM in one line

The logarithm is concave, because (ln⁡x)′′=−1x2<0(\ln x)'' = -\dfrac{1}{x^2} < 0(lnx)′′=−x21​<0. Jensen for a concave function gives

ln⁡(a1+⋯+ann) ≥ ln⁡a1+⋯+ln⁡ann=ln⁡a1⋯ann.\displaystyle \ln\left(\dfrac{a_1 + \dots + a_n}{n}\right) \ \ge\ \dfrac{\ln a_1 + \dots + \ln a_n}{n} = \ln\sqrt[n]{a_1 \cdots a_n}.ln(na1​+⋯+an​​) ≥ nlna1​+⋯+lnan​​=lnna1​⋯an​​.

Since ln⁡\lnln 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<q0 < p < q0<p<q, the function xq/px^{q/p}xq/p is convex. Jensen applied to the numbers aipa_i^paip​ gives Mp≤MqM_p \le M_qMp​≤Mq​, the power mean inequality of course 1.

Bounds in a triangle

In a triangle A+B+C=πA + B + C = \piA+B+C=π, and sin⁡\sinsin is concave on [0,π][0, \pi][0,π]. Jensen gives

sin⁡A+sin⁡B+sin⁡C3 ≤ sin⁡A+B+C3=sin⁡π3=32.\displaystyle \dfrac{\sin A + \sin B + \sin C}{3} \ \le\ \sin\dfrac{A + B + C}{3} = \sin\dfrac{\pi}{3} = \dfrac{\sqrt{3}}{2}.3sinA+sinB+sinC​ ≤ sin3A+B+C​=sin3π​=23​​.

So sin⁡A+sin⁡B+sin⁡C≤332\sin A + \sin B + \sin C \le \dfrac{3\sqrt{3}}{2}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 xln⁡xx\ln xxlnx on random lists. Then it tries many random triangles and keeps the largest value of sin⁡A+sin⁡B+sin⁡C\sin A + \sin B + \sin CsinA+sinB+sinC.

Read it first. Then run it. Is the largest sum of sines close to 332≈2.598\dfrac{3\sqrt{3}}{2} \approx 2.598233​​≈2.598?

1. Change f to the concave function math.log(x). Which way does the gap go now?

2. In the triangle part, replace math.sin by math.cos. What largest value do you find? Is it 1.51.51.5?

Common mistakes

  • Using Jensen outside the interval. sin⁡\sinsin is concave on [0,π][0, \pi][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′′≥0f'' \ge 0f′′≥0 is enough.
  • Jensen: f(∑wixi)≤∑wif(xi)f\left(\sum w_i x_i\right) \le \sum w_i f(x_i)f(∑wi​xi​)≤∑wi​f(xi​) for convex fff.
  • ln⁡x\ln xlnx concave gives AM-GM; xq/px^{q/p}xq/p convex gives the power means.
  • In a triangle, sin⁡A+sin⁡B+sin⁡C≤332\sin A + \sin B + \sin C \le \dfrac{3\sqrt{3}}{2}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.

  1. Is f(x)=e2xf(x) = e^{2x}f(x)=e2x convex? Use the second derivative.
  1. Use Jensen with f(x)=x2f(x) = x^2f(x)=x2 to show a2+b22≥(a+b2)2\dfrac{a^2 + b^2}{2} \ge \left(\dfrac{a + b}{2}\right)^22a2+b2​≥(2a+b​)2.
  1. Where is f(x)=x3f(x) = x^3f(x)=x3 convex, and where is it concave?
  1. Positive numbers aaa, bbb, ccc add up to 333. Use Jensen with f(x)=1xf(x) = \dfrac{1}{x}f(x)=x1​ to find the least value of 1a+1b+1c\dfrac{1}{a} + \dfrac{1}{b} + \dfrac{1}{c}a1​+b1​+c1​.
  1. In a triangle, what is the greatest value of sin⁡A+sin⁡B+sin⁡C\sin A + \sin B + \sin CsinA+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.
No payment. You can leave at any time.

Problems (3)

A surveyor marks a triangular plot with angles A, B and C…Hard · High School (11–12) · by StemPy Lab
Positive numbers a, b and c add up to 1…Hard · High School (11–12) · by StemPy Lab
Non-negative numbers a, b and c satisfy a² + b² + c² = 12…Advanced · High School (11–12) · by StemPy Lab
Next: lesson 2The tangent line trick and sums of squares
← Convexity, Jensen and Inequality Techniques
← PreviousThe tangent line trick and sums of squares →

Discussion (0)

Log in to join the discussion.

Loading…

the value at an average is at most the average of the values:
f(∑wixi)≤∑wif(xi)f\left(\sum w_i x_i\right) \le \sum w_i f(x_i)f(∑wi​xi​)≤∑wi​f(xi​)
. For a concave function it turns round. One inequality gives AM-GM, the power means and bounds in a triangle.
about 25 min1 simulation1 practice question1 Python program5 questions to check yourself

This lesson is free to read. Enroll free to keep your place and take the tests.

Python Labs (1)

Convexity on a gridPython Lab · by StemPy Lab