Supposedly the Hermite-Hadamard inequality is quite classical, as its name would suggest, but I hadn’t encountered it until browsing a probability book the other day. Well, what what does this inequality say? If $f: [a,b] \rightarrow \mathbb{R}$ is a convex function, then

$\displaystyle f\left(\frac{a+b}{2}\right) \leq \frac{1}{b-a}\int_{a}^{b}f(x)dx \leq \frac{f(a)+f(b)}{2}$

The reader may ask how we know that $f$ is integrable (in the Riemann or Lebesgue sense). Recall from my previous post on convexity that a convex function defined on an interval of $\mathbb{R}$ is continuous, hence bounded. So integrability is not a problem.

We now turn to the proof of this inequality. First, the RHS. For $x \in [a,b]$, we can write

$\displaystyle x = \lambda a + (1-\lambda)b \Rightarrow x-b=\lambda(a-b) \Rightarrow \lambda = \frac{b-x}{b-a}$

so by convexity,

$\displaystyle f\left(x\right) = f\left(\frac{b-x}{b-a}a + \frac{x-a}{b-a}b\right)\leq \frac{b-x}{b-a}f(a)+\frac{x-a}{b-a}f(b)$

Integrating both sides over $[a,b]$, we obtain the inequality

$\displaystyle \begin{array}{lcl}\int_{a}^{b}f(x)\leq\int_{a}^{b}\left[\frac{b-x}{b-a}f(a) +\frac{x-a}{b-a}f(b)\right]dx&=&\frac{f(a)}{b-a}\frac{(b-a)^{2}}{2}+\frac{f(b)}{b-a}\frac{(b-a)^{2}}{2}\\&=&\frac{f(a)+f(b)}{2}(b-a)\end{array}$

Recall that a convex function has left- and right-derivatives at each point of its domain:

$\displaystyle f'(x^{+}) := \lim_{x \rightarrow \frac{a+b}{2}^{+}}\frac{f(x) - f(\frac{a+b}{2})}{x-\frac{a+b}{2}} \geq \lim_{x \rightarrow \frac{a+b}{2}^{-}}\frac{f(x)-f(\frac{a+b}{2})}{x-\frac{a+b}{2}} =: f'(x^{-})$

Using the nondecreasing monotonicity of the function $R(x,y) := \frac{f(x)-f(y)}{x-y}$ in both arguments, we obtain

$\displaystyle \frac{f(x)-f(\frac{a+b}{2})}{x-\frac{a+b}{2}} \geq f'(x^{+}) \Longleftrightarrow f(x) \geq f(\frac{a+b}{2})+f'(x^{+})(x-\frac{a+b}{2})$

for all $\frac{a+b}{2} < x \leq b$ and

$\displaystyle \frac{f(x)-f(\frac{a+b}{2})}{x-\frac{a+b}{2}} \leq f'(x^{-})\Longleftrightarrow f(x)\geq f(\frac{a+b}{2})+f'(x^{-})(x-\frac{a+b}{2})$

for all $a \leq x < \frac{a+b}{2}$. Integrating the first inequality over $[\frac{a+b}{2},b]$ and the second inequality over $[a,\frac{a+b}{2}]$, we see that

$\displaystyle \int_{\frac{a+b}{2}}^{b}f(x)dx \geq f(\frac{a+b}{2})\frac{b-a}{2} + \frac{1}{2}f'(x^{+})\left(\frac{b-a}{2}\right)^{2}$

and

$\displaystyle \int_{a}^{\frac{a+b}{2}}f(x)dx \geq f(\frac{a+b}{2})\frac{b-a}{2} - \frac{1}{2}f'(x^{-})\left(\frac{b-a}{2}\right)^{2}$

Summing these two integrals, we obtain the inequality

$\displaystyle\begin{array}{lcl}\int_{a}^{b}f(x)dx=\int_{a}^{\frac{a+b}{2}}f(x)dx+\int_{\frac{a+b}{2}}^{b}f(x)dx&\geq&f\left(\frac{a+b}{2}\right)\frac{b-a}{2}+\frac{1}{2}f'(x^{+})\left(\frac{b-a}{2}\right)^{2}+f\left(\frac{a+b}{2}\right)\frac{b-a}{2}-\frac{1}{2}f'(x^{-})\left(\frac{b-a}{2}\right)^{2}\\&=& f\left(\frac{a+b}{2}\right)\frac{f'(x^{+})-f'(x^{-})}{2}\left(\frac{b-a}{2}\right)^{2}\\&\geq&f\left(\frac{a+b}{2}\right)\end{array}$

since $f'(x^{+})\geq f'(x^{-})$.

We now consider some examples of applications of the Hermite-Hadamard Inequality to calculus. The first example concerns the proof of Stirling’s formula:

$\displaystyle n!\sim\sqrt{2\pi}n^{n+\frac{1}{2}}e^{-n}$

Consider the real-valued function $f: [0,\infty) \rightarrow \mathbb{R}, f(x) := \frac{1}{1+x}$. $f$ is convex since $f'(x) = \frac{2}{(1+x)^{2}} > 0$. Applying the Hermite-Hadamard inequality with $a = 0, b = x$, we obtain

$\displaystyle \begin{array}{lcl}x-\frac{x^{2}}{2+x}=x\frac{1}{1+\frac{x}{2}} < \int_{0}^{x}f(t)dt = \ln(1+x) < \frac{x}{2}\left[1+\frac{1}{1+x}\right]&=&\frac{x}{2}+\frac{x}{2(1+x)}\\&=&x-\frac{x^{2}}{2(1+x)}\end{array}$

The preceding inequalities can be used to establish for a positive integer $n$ that

$\displaystyle \frac{1}{n+\frac{1}{2}}<\ln(n+1)-\ln(n)<\frac{1}{2}\left(\frac{1}{n}+\frac{1}{n+1}\right)$

In our second example, let $f: \mathbb{R}\rightarrow \mathbb{R}, f(x):=e^{x}$. It is evident that $f$ is strictly convex. Hence, for $-\infty ,

$\displaystyle e^{\frac{a+b}{2}} <\frac{1}{b-a}\int_{a}^{b}e^{x} = \frac{e^{b}-e^{a}}{b-a}<\frac{e^{a}+e^{b}}{2}$

Taking $a = \ln(x), b =\ln(y)$, for positive $x < y$, we see that

$\displaystyle \sqrt{xy}=e^{\ln(\sqrt{xy})}=e^{\frac{\ln(x) + \ln(y)}{2}} < \frac{y-x}{\ln(y)-\ln(x)} < \frac{x+y}{2},$

which yields the geometric, logarithmic, and arithmetic mean inequalities. For more on the Hermite-Hadamard inequality, including extensions and applications, see the paper “Old and New on the Hermite-Hadamard Inequality” by Niculescu and Persson.