Convex Function
Statement
A function is convex if for all and :
Geometrically: the chord joining to lies on or above the graph of .
Key example: is convex on all of because . Mathlib records this as Even.convexOn_pow: for any even , is convex on (univ).
Visualization
Chord above curve for between and :
f(x) = x²
4 | * (2, 4)
| /|
3 | / | chord from (0,0) to (2,4)
| / | slope = 2, chord value at x=1: 2
2 | / |
| * | graph value at x=1: 1
1 | /· | chord (2) ≥ graph (1) ✓
| / · |
0 *--------+---
0 1 2
| chord at (from to ) | chord graph? | ||
|---|---|---|---|
| 0 | 0 | 0 | yes |
| 1 | 1 | 2 | yes |
| 2 | 4 | 4 | yes (equal) |
At : . Convexity holds.
Second-derivative test: everywhere, so is strictly convex.
Proof Sketch
- Expand the convexity inequality for : need .
- Rearrange: , which holds since .
- Mathlib path:
Even.convexOn_pow(for even, applied with ,hn : Even 2) provesConvexOn ℝ Set.univ (fun x ↦ x ^ 2). The lemma is inMathlib.Analysis.Convex.Mul.
Connections
- Jensen's Inequality (Convex)Jensen's Inequality (Convex)For a convex function, the image of a weighted sum is at most the weighted sum of imagesRead more → — Jensen's inequality is the direct extension of convexity to weighted sums and expectations
- KKT ConditionsKKT ConditionsNecessary optimality conditions for constrained optimization via Lagrangian gradient and complementary slacknessRead more → — KKT conditions are sufficient for constrained optimality when is convex
- AM–GM InequalityAM–GM InequalityThe arithmetic mean is always at least as large as the geometric meanRead more → — AM–GM follows from the convexity of
- Cauchy–Schwarz InequalityCauchy–Schwarz InequalityThe inner product of two vectors is bounded by the product of their normsRead more → — Cauchy–Schwarz can be proved using the convexity of
Lean4 Proof
import Mathlib.Analysis.Convex.Mul
/-- x² is convex on all of ℝ, via Even.convexOn_pow with n = 2. -/
theorem sq_convexOn : ConvexOn ℝ Set.univ (fun x : ℝ ↦ x ^ 2) :=
even_two.convexOn_powReferenced by
- von Neumann MinimaxOptimization
- Jensen's Inequality (Convex)Optimization
- Gradient Descent ConvergenceOptimization
- KKT ConditionsOptimization