Mathwords logoMathwords

Log Sum Inequality — Definition, Formula & Example

The log sum inequality is a bound for weighted sums of logarithms of ratios. If you add up the terms ailog⁡(ai/bi)a_i \log(a_i/b_i) one at a time, the total is never less than the single term you get from pooling all the aa's and all the bb's first.

For nonnegative reals a1,…,ana_1, \dots, a_n and b1,…,bnb_1, \dots, b_n, with A=∑aiA = \sum a_i and B=∑biB = \sum b_i, the inequality states ∑i=1nailog⁡aibi≥Alog⁡AB\sum_{i=1}^{n} a_i \log \frac{a_i}{b_i} \ge A \log \frac{A}{B}. The logarithm may have any base greater than 1. By convention 0log⁡0b=00 \log \frac{0}{b} = 0 and alog⁡a0=+∞a \log \frac{a}{0} = +\infty for a>0a > 0. Equality holds if and only if ai/bia_i / b_i is the same constant for every ii. Proof idea: f(x)=xlog⁡xf(x) = x \log x is convex. Apply Jensen's inequality to ff at the points xi=ai/bix_i = a_i / b_i with weights bi/Bb_i / B. This gives ∑biBf ⁣(aibi)≥f ⁣(AB)\sum \frac{b_i}{B} f\!\left(\frac{a_i}{b_i}\right) \ge f\!\left(\frac{A}{B}\right), and multiplying both sides by BB gives the inequality.

Key Formula

∑i=1nailog⁡aibi  ≥  (∑i=1nai)log⁡∑i=1nai∑i=1nbi\sum_{i=1}^{n} a_i \log \frac{a_i}{b_i} \;\ge\; \left(\sum_{i=1}^{n} a_i\right) \log \frac{\sum_{i=1}^{n} a_i}{\sum_{i=1}^{n} b_i}
Where:
  • aia_i = Nonnegative numbers, often probabilities or counts from one distribution
  • bib_i = Nonnegative numbers, often probabilities or counts from a second distribution
  • nn = Number of terms being summed
  • log⁡\log = Logarithm in any base greater than 1. Base 2 measures in bits and base e measures in nats.

Worked Example

Problem: Let a=(2,8)a = (2, 8) and b=(4,1)b = (4, 1). Using base-2 logarithms, compute both sides of the log sum inequality and decide whether equality holds.
Step 1: Pool the numbers by finding the two totals.
A=2+8=10,B=4+1=5A = 2 + 8 = 10, \qquad B = 4 + 1 = 5
Step 2: Compute the left side term by term. The first term is negative, but the sum is still large.
2log⁡224+8log⁡281=2(−1)+8(3)=222\log_2\frac{2}{4} + 8\log_2\frac{8}{1} = 2(-1) + 8(3) = 22
Step 3: Compute the right side from the pooled totals, then compare the two sides.
10log⁡2105=10log⁡22=10,22≥1010\log_2\frac{10}{5} = 10\log_2 2 = 10, \qquad 22 \ge 10
Answer: The left side is 22 and the right side is 10, so the inequality holds. It is strict because the ratios ai/bia_i/b_i are 12\tfrac{1}{2} and 88, which are not equal.

Why It Matters

In an information theory course, this inequality is the standard proof of Gibbs' inequality. If pp and qq are probability distributions, then A=B=1A = B = 1, the right side becomes 00, and so the KL divergence D(p ∥ q)≥0D(p\,\|\,q) \ge 0. Applied to mixtures, the same inequality shows that KL divergence is jointly convex in the pair (p,q)(p, q). That convexity underlies cross-entropy loss in machine learning and the cost of using the wrong code in data compression.

Common Mistakes

Mistake: Assuming every term ailog⁡(ai/bi)a_i \log(a_i/b_i) must be nonnegative, or trying to prove the inequality one term at a time.
Correction: A single term can be negative. In the example above, the first term is −2-2. The inequality concerns only the total. A negative term appears whenever ai<bia_i < b_i, and the bound comes from convexity applied to the whole weighted sum.

Related Terms

  • Coding Theory — Uses relative entropy bounds that this inequality proves
  • Inequality — Explains the order statements this result is built from
  • Cauchy's Inequality — Another sum inequality where equality needs proportional terms
  • Jensen's Inequality — Standard tool used to prove the log sum inequality
  • Logarithm — Function whose weighted sums the inequality bounds