「学习笔记」伯努利数
定义
\[B_n = [n = 0] - \frac 1{n + 1} \sum_{i=0}^{n-1} \binom {n + 1} i B_i
\]
同时有
\[\hat{B}(x) = \sum_{i \geq 0} B_i \frac {x^i} {i!} = \frac x{e^x - 1}
\]
所以可以使用多项式求逆求出伯努利数。
性质
设自然数幂和函数 \(S_k(n) = \sum_{i=0}^{n-1} i^k\),那么有:
\[S_k(n) = \frac 1{k + 1} \sum_{i=0}^k \binom{k + 1}i B_i n^{k - i + 1}
\]
设 \(\hat{S}_n(x) = \sum_{i \geq 0} \frac {x^i} {i!} S_i(n)\),那么:
\[\begin{aligned}
\hat{S}_n(x) &= \sum_{i \geq 0} \frac {x^i} {i!} \sum_{j=0}^{n-1} j^i\\
&= \sum_{j=0}^{n-1} \sum_{i \geq 0} \frac {(jx)^i} {i!}\\
&= \sum_{j=0}^{n-1} e^{jx}\\
&= \frac {e^{nx} - 1}{e^x - 1}
\end{aligned}
\]
所以
\[\begin{aligned}
S_k(n) &= k! [x^k] \frac{e^{nx} - 1}{e^x - 1}\\
&= k! \sum_{i=0}^k \frac{B_i}{i!} [x^{k-i+1}] (e^{nx} - 1)\\
&= \frac 1{k + 1} \sum_{i=0}^k \binom{k+1}i B_i n^{k - i + 1}
\end{aligned}
\]
例子
洛谷P3711 仓鼠的数学题
求多项式 \(f(x) = \sum_{k=0}^n S_k(x + 1) a_k\)。
首先考虑求出 \(g(x) = f(x - 1)\) 然后再基变换回去。
那么:
\[\begin{aligned}
g(x) &= \sum_{k=0}^n \frac {a_k} {k + 1} \sum_{i=1}^{k + 1} \binom{k + 1}i x^i B_{k - i + 1}\\
&= \sum_{k=0}^n a_k k! \sum_{i = 1}^{k + 1} \frac {x^i} {i!} \frac {B_{k - i + 1}}{(k - i + 1)!}\\
&= \sum_{i=0}^n \frac {x^{i + 1}}{(i + 1)!} \sum_{k=i}^n a_k k! \frac{B_{k - i}}{(k - i)!}
\end{aligned}
\]
显然的减法卷积形式,NTT 即可。