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. /The triangle inequality and polynomial bounds

Course 29.3·Lesson 3 of 3

The triangle inequality and polynomial bounds

The triangle inequality ∣a+b∣≤∣a∣+∣b∣|a + b| \le |a| + |b|∣a+b∣≤∣a∣+∣b∣

Lesson 3 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

  • use the triangle inequality for numbers, distances and vectors;
  • find the point that minimises a sum of distances, on a line and in the plane;
  • bound a variable with the discriminant, and find a polynomial from AM-GM on its roots.

A detour is never shorter

Walking from home to school through a shop is never shorter than walking straight there. For real numbers, vectors and complex numbers this is the triangle inequality:

∣a+b∣ ≤ ∣a∣+∣b∣,∣a−b∣ ≥ ∣∣a∣−∣b∣∣.\displaystyle |a + b| \ \le\ |a| + |b|, \qquad |a - b| \ \ge\ \big||a| - |b|\big|.∣a+b∣ ≤ ∣a∣+∣b∣,∣a−b∣ ≥ ​∣a∣−∣b∣​.

Equality in the first holds when aaa and bbb point the same way (for real numbers, when ab≥0ab \ge 0ab≥0).

Least total distance on a line

Three houses stand at 111 km, 444 km and 999 km along a straight road. Where should a well be dug so that the total walking distance f(x)=∣x−1∣+∣x−4∣+∣x−9∣f(x) = |x - 1| + |x - 4| + |x - 9|f(x)=∣x−1∣+∣x−4∣+∣x−9∣ is least?

Pair the outer houses: ∣x−1∣+∣x−9∣≥∣(x−1)−(x−9)∣=8|x - 1| + |x - 9| \ge |(x - 1) - (x - 9)| = 8∣x−1∣+∣x−9∣≥∣(x−1)−(x−9)∣=8, with equality for 1≤x≤91 \le x \le 91≤x≤9. The middle term ∣x−4∣|x - 4|∣x−4∣ is least at x=4x = 4x=4. So the best place is the middle house, the median, and the least total is 888 km. For an even number of points, any point between the two middle ones is best.

A broken-line graph of the total distance |x - 1| + |x - 4| + |x - 9| for x from 0 to 10. It falls in straight pieces, reaches its lowest value 8 at x = 4, the middle house, and rises again. Three markers on the x axis show the houses at 1, 4 and 9.

Sums of square roots in the plane

Find the least value of g(x)=x2+1+(x−3)2+9g(x) = \sqrt{x^2 + 1} + \sqrt{(x - 3)^2 + 9}g(x)=x2+1​+(x−3)2+9​.

Read each root as a distance. x2+1\sqrt{x^2 + 1}x2+1​ is the distance from (x,0)(x, 0)(x,0) to (0,1)(0, 1)(0,1), and (x−3)2+9\sqrt{(x - 3)^2 + 9}(x−3)2+9​ is the distance from (x,0)(x, 0)(x,0) to (3,3)(3, 3)(3,3). Reflect (3,3)(3, 3)(3,3) in the xxx-axis to (3,−3)(3, -3)(3,−3): the distance to (x,0)(x, 0)(x,0) does not change. By the triangle inequality, the path from (0,1)(0, 1)(0,1) to (x,0)(x, 0)(x,0) to (3,−3)(3, -3)(3,−3) is at least the straight distance 32+42=5\sqrt{3^2 + 4^2} = 532+42​=5. So the least value of ggg is 555, where the straight line crosses the axis.

The x axis with the point (0, 1) above it and the point (3, 3) above it. The point (3, 3) is reflected to (3, -3) below the axis, drawn hollow. A straight green line from (0, 1) to (3, -3) crosses the axis at x = 0.75. A dashed path from (0, 1) to a point on the axis and on to (3, 3) is shown as a longer detour.

Sides of a triangle

Three positive numbers aaa, bbb, ccc are the sides of a triangle exactly when each is less than the sum of the other two. Then x=b+c−a2x = \dfrac{b + c - a}{2}x=2b+c−a​, y=c+a−b2y = \dfrac{c + a - b}{2}y=2c+a−b​ and z=a+b−c2z = \dfrac{a + b - c}{2}z=2a+b−c​ are positive, and

a=y+z,b=z+x,c=x+y.\displaystyle a = y + z, \quad b = z + x, \quad c = x + y.a=y+z,b=z+x,c=x+y.

This is the Ravi substitution. It turns a triangle inequality into an inequality about any positive numbers. For example, abc≥(b+c−a)(c+a−b)(a+b−c)abc \ge (b + c - a)(c + a - b)(a + b - c)abc≥(b+c−a)(c+a−b)(a+b−c) becomes (y+z)(z+x)(x+y)≥8xyz(y + z)(z + x)(x + y) \ge 8xyz(y+z)(z+x)(x+y)≥8xyz, which is AM-GM from course 1.

Bounds from a discriminant

A quadratic ax2+bx+cax^2 + bx + cax2+bx+c with a>0a > 0a>0 is never negative for real xxx exactly when b2−4ac≤0b^2 - 4ac \le 0b2−4ac≤0. Turn this round to bound a variable.

Real numbers satisfy x+y+z=4x + y + z = 4x+y+z=4 and xy+yz+zx=5xy + yz + zx = 5xy+yz+zx=5. How large can zzz be?

  1. Fix zzz. Then x+y=4−zx + y = 4 - zx+y=4−z and xy=5−z(4−z)xy = 5 - z(4 - z)xy=5−z(4−z).
  2. Real roots. xxx and yyy are roots of u2−(4−z)u+5−z(4−z)=0u^2 - (4 - z)u + 5 - z(4 - z) = 0u2−(4−z)u+5−z(4−z)=0, so the discriminant is not negative: (4−z)2−4(5−z(4−z))≥0(4 - z)^2 - 4\big(5 - z(4 - z)\big) \ge 0(4−z)2−4(5−z(4−z))≥0.
  3. Simplify. This is 3z2−8z+4≤03z^2 - 8z + 4 \le 03z2−8z+4≤0, that is (3z−2)(z−2)≤0(3z - 2)(z - 2) \le 0(3z−2)(z−2)≤0, so 23≤z≤2\dfrac{2}{3} \le z \le 232​≤z≤2.

Polynomials with positive roots

If a polynomial has only positive real roots, AM-GM links its coefficients. The cubic x3−9x2+px−27=0x^3 - 9x^2 + px - 27 = 0x3−9x2+px−27=0 has three positive real roots. By Vieta, the roots add up to 999 and multiply to 272727. Their arithmetic mean is 333 and their geometric mean is 273=3\sqrt[3]{27} = 3327​=3. Equal means force equal roots, so every root is 333. Then ppp, the sum of the three products in pairs, is 3×9=273 \times 9 = 273×9=27.

Practise with new numbers

Try it in Python

The program samples many real triples with x+y+z=4x + y + z = 4x+y+z=4 and xy+yz+zx=5xy + yz + zx = 5xy+yz+zx=5, and prints the smallest and largest zzz it finds.

Read it first. Then run it. Do the smallest and largest zzz agree with 23\dfrac{2}{3}32​ and 222?

1. Change the conditions to x+y+z=5x + y + z = 5x+y+z=5 and xy+yz+zx=3xy + yz + zx = 3xy+yz+zx=3 by setting s = 5 and t = 3. Predict the range of zzz with the discriminant first.

Common mistakes

  • Forgetting the equality case of the triangle inequality. The bound is reached only when the pieces line up.
  • Reflecting the wrong point. Reflect one point so that the two points lie on opposite sides of the line.
  • Mixing strict and weak signs. A quadratic is positive for all xxx when D<0D < 0D<0, and not negative when D≤0D \le 0D≤0.
  • Using AM-GM on roots that may be negative or complex. Vieta plus AM-GM needs positive real roots.

Remember these

  • ∣a+b∣≤∣a∣+∣b∣|a + b| \le |a| + |b|∣a+b∣≤∣a∣+∣b∣; a sum of distances on a line is least at the median.
  • A sum of square roots can be a path length: reflect and draw a straight line.
  • Ravi: triangle sides are y+zy + zy+z, z+xz + xz+x, x+yx + yx+y with x,y,z>0x, y, z > 0x,y,z>0.
  • Real roots of a quadratic need D≥0D \ge 0D≥0; use it to bound a variable.

Check yourself

Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.

  1. Find the least value of ∣x−3∣+∣x+2∣|x - 3| + |x + 2|∣x−3∣+∣x+2∣.
  1. Can 333, 444 and 888 be the sides of a triangle?
  1. For which real kkk is x2+kx+4>0x^2 + kx + 4 > 0x2+kx+4>0 for every real xxx?
  1. For the triangle with sides 555, 666, 777, find xxx, yyy, zzz of the Ravi substitution.
  1. A cubic x3−12x2+qx−64=0x^3 - 12x^2 + qx - 64 = 0x3−12x2+qx−64=0 has three positive real roots. Find qqq.

References

  • Engel, Problem-Solving Strategies, Chapter 7, on the triangle inequality and the Ravi substitution.
  • OpenStax, College Algebra 2e, Chapter 5, on polynomial functions and the relation between roots and coefficients.

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 (4)

Real numbers x and y satisfy x² + xy + y² = 3.…Advanced · High School (11–12) · by StemPy Lab
Real numbers x, y and z satisfy x + y + z = 5 and xy + yz + zx = 3.…Hard · High School (11–12) · by StemPy Lab
Nine houses stand along a straight road at the marks 1, 2, 3, …, 9 km…Hard · High School (11–12) · by StemPy Lab
That was the last lessonBack to the course: take the test
← Convexity, Jensen and Inequality Techniques
← The tangent line trick and sums of squaresNext →

Discussion (0)

Log in to join the discussion.

Loading…

says that a detour is never shorter than the straight path. It finds the point that minimises a total distance and bounds sums of square roots. The sides of any triangle can be written as
y+zy + zy+z
,
z+xz + xz+x
,
x+yx + yx+y
with positive
x,y,zx, y, zx,y,z
. A quadratic that keeps one sign has a discriminant that is not positive, and real roots of a polynomial obey AM-GM through Vieta's formulas.
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.

The equation x⁴ - 12x³ + ax² - bx + 81 = 0; has four positive real roots…Advanced · High School (11–12) · by StemPy Lab

Python Labs (1)

The point that minimises total distancePython Lab · by StemPy Lab

Question Sets (1)

Convexity and Inequality Techniques: Practice Questions10 questions · by StemPy Lab

Notes (1)

Convexity and Inequality Techniques: Quick RevisionNote · by StemPy Lab