Binomial Inversion
Symmetric Inversion
The main content of binomial inversion is:
\[ f_n = \sum_{i = 0}^n (-1)^i {n \choose i} g_i \longleftrightarrow g_n = \sum_{i = 0}^n (-1)^i {n \choose i} f_i \]
This inversion formula is really beautiful: in this form, the two sides are symmetric. Of course, it can also be written as:
\[ f_n = \sum_{i = 0}^n {n \choose i} g_i \longleftrightarrow g_n = \sum_{i = 0}^n (-1)^{n - i} {n \choose i} f_i \]
Proof
Consider proving it by the ever-popular brute-force substitution:
\[ \begin{gathered} \begin{aligned} f_n &= \sum_{i = 0}^n (-1)^i {n \choose i} \sum_{j = 0}^i (-1)^j {i \choose j} f_j \\ &= \sum_{i = 0}^n \sum_{j = 0}^n (-1)^{i + j} {n \choose i} {i \choose j} f_j [j \leq i] \end{aligned} \\ \text{where} \\ \begin{aligned} {n \choose i} {i \choose j} &= \frac{n!i!}{i!(n - i)!(i - j)!j!} \\ &= \frac{n!}{j!(n - j)!} \frac{(n - j)!}{(n - i)!((n - j) - (n - i))!} \\ &= {n \choose j} {n - j \choose n - i} \end{aligned} \\ \text{substituting back into the original} \\ \begin{aligned} f_n &= \sum_{i = 0}^n \sum_{j = 0}^n (-1)^{i + j} {n \choose i} {i \choose j} f_j [j \leq i] \\ &= \sum_{i = 0}^n \sum_{j = 0}^n (-1)^{i + j} {n - j \choose n - i} f_j [j \leq i] \\ &= \sum_{j = 0}^n {n \choose j} f_j \sum_{i = j}^n (-1)^{i + j} {n - j \choose n - i} \end{aligned} \\ \text{now we need to prove } \sum_{i = j}^n (-1)^{i + j} {n - j \choose n - i} = [j = n] \\ \begin{aligned} \sum_{i = j}^n (-1)^{i + j} {n - j \choose n - i} &= (-1)^j \sum_{i = j}^n (-1)^i {n - j \choose n - i} \\ &= (-1)^j \sum_{i = 0}^{n - j} (-1)^{i + j} {n - j \choose n - (i + j)} \\ &= (-1)^j \sum_{i = 0}^{n - j} (-1)^{n - i} {n - j \choose i} \\ &= (-1)^{n + j} (1 - 1)^{n - j} = [j = n] \end{aligned} \\ \text{substituting back into the original, the result is just } f_n \end{gathered} \]
Applications of Binomial Inversion
At Least to Exactly
A lot of problems that use binomial inversion are, roughly, solved by converting “at least” into “exactly”. For an ordinary at-least-to-exactly conversion, you can usually just write it out and invert directly:
\[ g(x) = \sum_{i = 0}^n {n \choose i} f(i) \]
Sometimes you have to convert to “at least \(k\)”. When converting to this, binomial inversion needs a few adjustments. In this case we write:
\[ g(k) = \sum_{i = k}^n {i \choose k} f(i) \]
This needs a special form of the inversion:
\[ f(k) = \sum_{i = k}^n (-1)^{i - k} {i \choose k} g(i) \]
This is the solution to the example problem BZOJ 3622. Use at least \(k\) to convert to exactly \(k\). At heart it's just inclusion–exclusion, that's all.