二項式反演
阿新 • • 發佈:2021-09-04
萌新終於學會二項式反演啦!
\[\begin{aligned}
f_{i}&=\sum^{n}_{j=i}\binom{j}{i}g_{j}\\
&\sum^{n}_{j=i}(-1)^{j-i}\binom{j}{i}f_{j}\\
&=\sum^{n}_{j=i}(-1)^{j-i}\binom{j}{i}\sum^{n}_{k=j}\binom{k}{j}g_{k}\\
&=\sum^{n}_{k=i}g_{k}\sum^{k}_{j=i}(-1)^{j-i}\binom{j}{i}\binom{k}{j}\\
&=\sum^{n}_{k=i}g_{k}\sum^{k}_{j=i}(-1)^{j-i}\binom{j}{i}\binom{k-i}{j-i}\frac{k!(j-i)!}{(k-i)!j!}\\
&=\sum^{n}_{k=i}g_{k}\sum^{k}_{j=i}(-1)^{j-i}\binom{k}{i}\binom{k-i}{j-i}\\
&=\sum^{n}_{k=i}\binom{k}{i}g_{k}\sum^{k-i}_{j=0}(-1)^{j}\binom{k-i}{j}\\
&=\sum^{n}_{k=i}\binom{k}{i}g_{k}(1-1)^{k-i}\\
&=g_{i}
\end{aligned}
\]
老是記反,存一下推導過程。
至少轉恰好。
\[\begin{aligned} f_{i}&=\sum^{i}_{j=0}\binom{i}{j}g_{j}\\ &\sum^{i}_{j=0}(-1)^{j-i}\binom{i}{j}f_{j}\\ &=\sum^{i}_{j=0}(-1)^{j-i}\binom{i}{j}\sum^{j}_{k=0}g_{k}\binom{j}{k}\\ &=\sum^{i}_{j=0}\sum^{j}_{k=0}(-1)^{j-i}\binom{i}{j}\binom{j}{k}g_{k}\\ &=\sum^{i}_{k=0}g_{k}\sum^{i}_{j=k}(-1)^{j-i}\binom{i}{j}\binom{j}{k}\\ &=\sum^{i}_{k=0}g_{k}\sum^{i-k}_{j=0}(-1)^{j+i}\binom{i-k}{j}\frac{i!j!}{(i-k)!(j+k)!}\binom{j+k}{k}\\ &=\sum^{i}_{k=0}g_{k}\sum^{i-k}_{j=0}(-1)^{j+i}\binom{i-k}{j}\binom{i}{k}\\ &=\sum^{i}_{k=0}\binom{i}{k}g_{k}\sum^{i-k}_{j=0}(-1)^{j+i}\binom{i-k}{j}\\ &=\sum^{i}_{k=0}\binom{i}{k}g_{k}(1-1)^{i-k}\\ &=g_{i} \end{aligned} \]至多轉恰好。