Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.The shortest path
You want to walk from your house to the park. You can walk straight there, or stop at a friend’s house on the way. The detour can never be shorter than walking straight. At best it’s equal, if your friend lives exactly on the straight line. This simple idea is the triangle inequality.
The best fence
You have 16 metres of fence and want to make a rectangular garden with the most space inside.
| Shape | Sides | Space inside |
|---|---|---|
| Long and thin | 7 × 1 | 7 |
| Rectangle | 6 × 2 | 12 |
| Rectangle | 5 × 3 | 15 |
| Square | 4 × 4 | 16 ← the most! |
For a fixed amount of fence, the square always wins. This is the idea behind the AM–GM inequality.
Averages of bowls
Some shapes curve upward like a bowl. Pick two points on the bowl and connect them with a straight string. The string always sits above the bowl. That’s Jensen’s inequality, and AI uses it to make hard calculations easier.
- 1. Going from A to B directly is 5 km. Going through C is 3 km + 4 km. Which is shorter?
- 2. With 20 metres of fence, which rectangle holds the most space?
- 3. A string between two points on a bowl-shaped curve is…
Level 1: Beginner
★★☆☆☆ Basic⏱ 15 minSecondary-school mathematics: arithmetic and elementary algebra.AM–GM for two numbers
For any two non-negative numbers :
with equality exactly when . Example: . AM = 6.5, GM = 6.
The fence, explained. With perimeter , the sides satisfy . AM–GM gives , so the area . Equality needs : a square.
The triangle inequality
For numbers: . For example, .
For distances between points: . In any triangle, each side is shorter than the other two combined. So if two sides are 3 and 5, the third is less than 8 (and more than 2).
Cauchy–Schwarz in 2D
For vectors and :
The left side is the dot product. The right side is the product of the two lengths. In words, the dot product can never be bigger than the lengths multiplied.
- 1. AM and GM of 2 and 8?
- 2. Two sides of a triangle are 4 and 7. The third side must be…
- 3. When does AM = GM?
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 35 minUndergraduate students and practising engineers.The general forms
AM–GM–HM. For positive :
with equality exactly when all the are equal.
Cauchy–Schwarz. For vectors in :
with equality exactly when one vector is a multiple of the other.
Triangle inequality for vectors. . Its “reverse” form is .
Jensen’s inequality. A function is convex if every chord lies above its graph. For convex , weights with :
For a concave function such as , the inequality flips: .
Why ML needs these
| Inequality | Where it’s used |
|---|---|
| Cauchy–Schwarz | Cosine similarity in search, embeddings and RAG |
| Triangle inequality | Makes distance a metric. Lets kNN and vector search skip far-away candidates (ball trees, D4) |
| Jensen | The ELBO in variational autoencoders. Proving KL divergence ≥ 0. Why , so variance is ≥ 0 |
| AM–GM | Bounding products by sums in convergence proofs. The fence problem is a tiny constrained optimization |
- 1. What is the minimum of x + 1/x for x > 0?
- 2. Cosine similarity of (1, 0) and (1, 1)?
- 3. For the convex f(x) = x², Jensen says…
Level 3: Advanced
★★★★☆ Advanced⏱ 50 minGraduate level, with full derivations and proofs.Proofs
For : , with equality if and only if .
Proof. . Rearrange. Equality holds exactly when . ∎
For : .
Proof. If , both sides are 0. Otherwise, for every real :
A quadratic in that’s never negative has discriminant : . ∎ Equality means for some , so the vectors are parallel.
.
Proof. , using Cauchy–Schwarz. ∎
If is convex, and , then .
Proof by induction on . is the definition of convexity. For points with , write , where . Apply the two-point case, then the induction hypothesis to . ∎
is concave, so . Exponentiate. ∎
Two generalizations
- Hölder’s inequality. For with : , where . With , this is Cauchy–Schwarz.
- Minkowski’s inequality. for . It’s why the “norms” really are norms when . For it fails (Practice Code 3).
Exercise 3.1: Maximise xyz subject to x + y + z = 12 with x, y, z positive
AM–GM: , so , with equality at . The answer is 64.
Exercise 3.2: Prove (a + b)(1/a + 1/b) ≥ 4 for positive a and b
Apply Cauchy–Schwarz to and : . Equality holds when .
- 1. In the Cauchy–Schwarz proof, which fact gives the inequality?
- 2. Hölder with p = 3 pairs with q = …
- 3. Is ‖x‖₀.₅ = (Σ|xᵢ|^0.5)² a norm?
Level 4: Expert
★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.Jensen powers variational inference
For a model with hidden variables , the likelihood is usually impossible to compute. Pick any distribution and use Jensen with the concave :
The gap is exactly . Maximizing the ELBO is the training objective of variational autoencoders (Kingma and Welling, 2014) and of variational inference in general (Jordan et al., 1999). It’s also the basis of diffusion-model training losses (H3, H7).
KL divergence is non-negative (Gibbs’ inequality). . This one line underlies much of information theory (A7).
From inequalities to probability bounds
- Markov: for , .
- Chebyshev: .
- These lead to the concentration inequalities (Hoeffding, Bernstein; A4.3) that power generalization bounds in learning theory (B2).
Inequalities that keep robots safe
- Safety certificates. A control barrier function requires . An inequality on the dynamics guarantees the robot never leaves the safe set (S6).
- Lyapunov stability. Show the “energy” satisfies . Then , an exponential decay guarantee (S3).
- Collision checking. Bounding volumes and the triangle inequality let planners rule out collisions quickly without exact geometry (U1).
Open directions
Many deep-learning theory results are inequalities that are true but too loose to be useful. Making them tight, for example PAC-Bayes and compression bounds for large networks, is active research. In robotics, verifying neural network controllers means proving inequalities over every possible input in a region (M2).
References
- A.-L. Cauchy (1821). Cours d’analyse de l’École Royale Polytechnique.
- V. Bunyakovsky (1859). Mémoires de l’Académie impériale des sciences de St-Pétersbourg, 1(9). (The integral form.)
- H. A. Schwarz (1888). “Über ein die Flächen kleinsten Flächeninhalts betreffendes Problem der Variationsrechnung.” Acta Societatis Scientiarum Fennicae, 15.
- J. L. W. V. Jensen (1906). “Sur les fonctions convexes et les inégalités entre les valeurs moyennes.” Acta Mathematica, 30.
- G. H. Hardy, J. E. Littlewood, G. Pólya (1934). Inequalities. Cambridge University Press.
- M. Jordan, Z. Ghahramani, T. Jaakkola, L. Saul (1999). “An introduction to variational methods for graphical models.” Machine Learning, 37.
- J. M. Steele (2004). The Cauchy–Schwarz Master Class. Cambridge University Press.
- D. Kingma and M. Welling (2014). “Auto-encoding variational Bayes.” ICLR.
- A. Ames et al. (2019). “Control barrier functions: theory and applications.” European Control Conference.