Convex Functions

This scene studies functions whose chords float above the graph. Convexity turns out to be the derivative increasing.

Picture a bowl shape opening upward. A curve whose slope keeps growing is convex. The middle height never exceeds the average of the end heights.

For example, stretch a 🧡 string taut between two points on a bowl-shaped curve and it always floats above the curve. The string's middle sits higher than the curve's middle.

f(tx+(1βˆ’t)y)≀tf(x)+(1βˆ’t)f(y)f(tx+(1-t)y) \le tf(x)+(1-t)f(y)
fΒ convexΒ β€…β€ŠβŸΊβ€…β€Šfβ€²Β increasing,fβ€²β€²β‰₯0β€…β€ŠβŸΉβ€…β€Šconvexf \text{ convex } \iff f' \text{ increasing}, \quad f'' \ge 0 \implies \text{convex}

Part of these learning paths

Examples & Exercises

Prove directly that f(x)=x2f(x) = x^2 is convex.

(tx+(1βˆ’t)y)2≀tx2+(1βˆ’t)y2β€…β€ŠβŸΊβ€…β€Št(1βˆ’t)(xβˆ’y)2β‰₯0(tx+(1-t)y)^2 \le tx^2+(1-t)y^2 \iff t(1-t)(x-y)^2 \ge 0
a=βˆ’1,b=1a=-1, b=1 β€” the chord floats above the parabola
Show proof
  1. Expanding the difference gives tx2+(1βˆ’t)y2βˆ’(tx+(1βˆ’t)y)2=t(1βˆ’t)(xβˆ’y)2tx^2+(1-t)y^2-(tx+(1-t)y)^2 = t(1-t)(x-y)^2. (Squaring (tx+(1βˆ’t)y)(tx+(1-t)y) and collecting terms factors t(1βˆ’t)t(1-t) out of the x2x^2 and y2y^2 coefficients.)

  2. Since t∈[0,1]t \in [0,1], we have t(1βˆ’t)β‰₯0t(1-t) \ge 0, and (xβˆ’y)2β‰₯0(x-y)^2 \ge 0 as a square. So the right-hand side is nonnegative.

  3. That is, (tx+(1βˆ’t)y)2≀tx2+(1βˆ’t)y2(tx+(1-t)y)^2 \le tx^2+(1-t)y^2 β€” the definition of convexity holds, so x2x^2 is convex. This is also why the max gap is 11 for a=βˆ’1,b=1a=-1, b=1 in the picture above.

Prove that if ff is differentiable and fβ€²f' is increasing, then ff is convex.

f(x2)βˆ’f(x1)x2βˆ’x1=fβ€²(c1)≀fβ€²(c2)=f(x3)βˆ’f(x2)x3βˆ’x2\frac{f(x_2)-f(x_1)}{x_2-x_1} = f'(c_1) \le f'(c_2) = \frac{f(x_3)-f(x_2)}{x_3-x_2}
exe^x β€” an example with fβ€²β€²>0f'' > 0
Show proof
  1. Take x1<x2<x3x_1 < x_2 < x_3.

    The mean value theorem on [x1,x2][x_1, x_2] and [x2,x3][x_2, x_3] gives c1∈(x1,x2)c_1 \in (x_1, x_2) and c2∈(x2,x3)c_2 \in (x_2, x_3) with fβ€²(c1)=f(x2)βˆ’f(x1)x2βˆ’x1f'(c_1) = \frac{f(x_2)-f(x_1)}{x_2-x_1} and fβ€²(c2)=f(x3)βˆ’f(x2)x3βˆ’x2f'(c_2) = \frac{f(x_3)-f(x_2)}{x_3-x_2}.

    Since c1<c2c_1 < c_2 and fβ€²f' is increasing, fβ€²(c1)≀fβ€²(c2)f'(c_1) \le f'(c_2).

  2. Rearranging the slope inequality f(x2)βˆ’f(x1)x2βˆ’x1≀f(x3)βˆ’f(x2)x3βˆ’x2\frac{f(x_2)-f(x_1)}{x_2-x_1} \le \frac{f(x_3)-f(x_2)}{x_3-x_2} gives f(x2)≀(x3βˆ’x2)f(x1)+(x2βˆ’x1)f(x3)x3βˆ’x1f(x_2) \le \frac{(x_3-x_2)f(x_1)+(x_2-x_1)f(x_3)}{x_3-x_1} β€” the middle value lies below the chord joining the endpoints.

  3. With x2=tx1+(1βˆ’t)x3x_2 = tx_1+(1-t)x_3 we have x3βˆ’x2x3βˆ’x1=t\frac{x_3-x_2}{x_3-x_1} = t and x2βˆ’x1x3βˆ’x1=1βˆ’t\frac{x_2-x_1}{x_3-x_1} = 1-t, so the inequality becomes f(tx1+(1βˆ’t)x3)≀tf(x1)+(1βˆ’t)f(x3)f(tx_1+(1-t)x_3) \le tf(x_1)+(1-t)f(x_3) β€” the definition of convexity.

    The degenerate cases are trivial: t=0t = 0 or t=1t = 1 gives equality on both sides, and equal points (x1=x3x_1 = x_3) likewise leave only equality.

    Note that fβ€²β€²β‰₯0f'' \ge 0 makes fβ€²f' increasing β€” under an extra hypothesis: if ff is twice differentiable (so fβ€²f' is continuous and differentiable on the interior with derivative fβ€²β€²f''), the mean value theorem applied to fβ€²f' gives this.

Derive the AM–GM inequality for two numbers a,b>0a, b > 0 from the concavity of log.

log⁑a+b2β‰₯log⁑a+log⁑b2=log⁑ab\log\frac{a+b}{2} \ge \frac{\log a + \log b}{2} = \log\sqrt{ab}
the chord picture applies to log just the same
Show proof
  1. log⁑\log is C2C^2 on (0,∞)(0, \infty), and (log⁑)β€²(x)=1x(\log)'(x) = \frac{1}{x} is decreasing (0<x1<x20 < x_1 < x_2 gives 1x1>1x2\frac{1}{x_1} > \frac{1}{x_2}). Problem 2's proof, with every inequality reversed, shows a function with decreasing derivative is concave β€” applying it to log⁑\log makes log⁑\log concave: the chord lies below the graph. (In fact C1C^1 with decreasing derivative suffices.)

  2. Jensen's inequality (concave version) with t=12t = \frac12 gives log⁑a+b2β‰₯log⁑a+log⁑b2\log\frac{a+b}{2} \ge \frac{\log a + \log b}{2}.

  3. The right-hand side is 12(log⁑a+log⁑b)=log⁑ab\frac12(\log a + \log b) = \log\sqrt{ab}, so exponentiating gives a+b2β‰₯ab\frac{a+b}{2} \ge \sqrt{ab} β€” the AM–GM inequality. (Exponentiation is increasing, so the inequality is preserved.)

10. Differentiation