定义等差数列 { a n } \{a_n\} {an},公差为 d d d。
例如数列 1 , 3 , 5 , 7 1,3,5,7 1,3,5,7就是等差数列,其中 a 1 = 1 a_1=1 a1=1为首项。
a n = a 1 + ( n − 1 ) ⋅ d a_n=a_1+(n-1)\cdot d an=a1+(n−1)⋅d
∑ n i = 1 i = n ( n + 1 ) 2 \underset{i=1}{\overset{n}{\sum}}i=\frac{n(n+1)}{2} i=1∑ni=2n(n+1)
∑ n i = 1 a i = ( 首项 + 末项 ) × 项数 2 = n ⋅ a 1 + d ⋅ n ( n − 1 ) 2 \underset{i=1}{\overset{n}{\sum}}a_i=\frac{(首项+末项)\times 项数}{2}=n\cdot a_1+d\cdot \frac{n(n-1)}2 i=1∑nai=2(首项+末项)×项数=n⋅a1+d⋅2n(n−1)
证明方法有很多,这里就直接从和式的变换出发作为证明:
先证明 ∑ n i = 1 i = n ( n + 1 ) 2 \underset{i=1}{\overset{n}{\sum}}i=\frac{n(n+1)}{2} i=1∑ni=2n(n+1)
∑ n i = 1 i = 1 2 ⋅ 2 ∑ n i = 1 i = 1 2 ( ∑ n i = 1 i + ∑ n i = 1 n − i + 1 ) = 1 2 ∑ n i = 1 n + 1 = n ( n + 1 ) 2 \underset{i=1}{\overset{n}{\sum}}i=\frac 12\cdot{2}\underset{i=1}{\overset{n}{\sum}}i=\frac 12\left(\underset{i=1}{\overset{n}{\sum}}i+\underset{i=1}{\overset{n}{\sum}}n-i+1\right)=\frac 12 \underset{i=1}{\overset{n}{\sum}}n+1=\frac {n(n+1)}2 i=1∑ni=21⋅2i=1∑ni=21(i=1∑ni+i=1∑nn−i+1)=21i=1∑nn+1=2n(n+1)
就可以证明:
∑ n i = 1 a i = ∑ n i = 1 a 1 + ( i − 1 ) ⋅ d = ∑ n i = 1 a 1 + d ∑ n i = 1 ( i − 1 ) \underset{i=1}{\overset{n}{\sum}}a_i=\underset{i=1}{\overset{n}{\sum}}a_1+(i-1)\cdot d=\underset{i=1}{\overset{n}{\sum}}a_1+d\underset{i=1}{\overset{n}{\sum}}(i-1) i=1∑nai=i=1∑na1+(i−1)⋅d=i=1∑na1+di=1∑n(i−1)
= n ⋅ a 1 + d ∑ n − 1 i = 0 i = n ⋅ a 1 + d ⋅ n ( n − 1 ) 2 =n\cdot a_1+d\underset{i=0}{\overset{n-1}{\sum}}i=n\cdot a_1+d\cdot\frac {n(n-1)}2 =n⋅a1+di=0∑n−1i=n⋅a1+d⋅2n(n−1)
= n ⋅ 2 a 1 + d ( n − 1 ) 2 = n ⋅ ( a 1 ) + ( a 1 + ( n − 1 ) ⋅ d ) 2 = 项数 × 首项 + 末项 2 =n\cdot\frac{2a_1+d(n-1)}{2}=n\cdot\frac{(a_1)+(a_1+(n-1)\cdot d)}{2}=项数\times\frac{首项+末项}{2} =n⋅22a1+d(n−1)=n⋅2(a1)+(a1+(n−1)⋅d)=项数×2首项+末项
QED.
后续证明常用和式的变换。
二阶、三阶等差数列求和往往使用和式的变换把式子展开,借助 K K K次方数求和。更高阶等差数列求和较复杂。
定义等比数列 { a n } \{a_n\} {an},公比为 q ( q ≠ 0 ) q(q\neq0) q(q=0)
a n = a 1 ⋅ q n − 1 a_n=a_1\cdot q^{n-1} an=a1⋅qn−1
∑ n i = 1 q i − 1 = 公 比 n − 1 公比 − 1 = q n − 1 q − 1 \underset{i=1}{\overset{n}{\sum}}q^{i-1}=\frac {公比^n-1}{公比-1}=\frac {q^n-1}{q-1} i=1∑nqi−1=公比−1公比n−1=q−1qn−1
∑ n i = 1 a 1 q i − 1 = a 1 ⋅ 公 比 n − 1 公比 − 1 = a 1 ⋅ q n − 1 q − 1 \underset{i=1}{\overset{n}{\sum}}a_1q^{i-1}=a_1\cdot\frac {公比^n-1}{公比-1}=a_1\cdot\frac {q^n-1}{q-1} i=1∑na1qi−1=a1⋅公比−1公比n−1=a1⋅q−1qn−1
证明:
设 ∑ n i = 1 q i − 1 = A \underset{i=1}{\overset{n}{\sum}}q^{i-1}=A i=1∑nqi−1=A:
则: q ∑ n i = 1 q i − 1 = ∑ n i = 1 q i q\underset{i=1}{\overset{n}{\sum}}q^{i-1}=\underset{i=1}{\overset{n}{\sum}}q^i qi=1∑nqi−1=i=1∑nqi
就会有 q A − A = ( q − 1 ) A qA-A=(q-1)A qA−A=(q−1)A,因此:
A = 1 q − 1 ( q A − A ) A=\frac{1}{q-1}\left(qA-A\right) A=q−11(qA−A)
= 1 q − 1 ( ∑ n i = 1 q i − ∑ n i = 1 q i − 1 ) =\frac{1}{q-1}\left(\underset{i=1}{\overset{n}{\sum}}q^i-\underset{i=1}{\overset{n}{\sum}}q^{i-1}\right) =q−11(i=1∑nqi−i=1∑nqi−1)
= 1 q − 1 ( ∑ n i = 1 q i − ∑ n − 1 i = 0 q i ) =\frac 1{q-1}\left(\underset{i=1}{\overset{n}{\sum}}q^i-\underset{i=0}{\overset{n-1}{\sum}}q^i\right) =q−11(i=1∑nqi−i=0∑n−1qi)
= q n − q 0 q − 1 = q n − 1 q − 1 =\frac{q^n-q^0}{q-1}=\frac{q^n-1}{q-1} =q−1qn−q0=q−1qn−1
第二个式子容易证明。
QED.
∑ n i = 1 p i 2 + i \underset{i=1}{\overset{n}{\sum}}p^{i^2+i} i=1∑npi2+i等较复杂,更高阶等比数列求和较复杂。
∑ n i = 1 i K \underset{i=1}{\overset{n}{\sum}}i^K i=1∑niK表示 K K K次方数求和。
一次方数求和就是等差求和。
∑ n i = 1 i = n ( n + 1 ) 2 \underset{i=1}{\overset{n}{\sum}}i=\frac {n(n+1)}2 i=1∑ni=2n(n+1)
∑ n i = 1 i 2 = n ( n + 1 ) ( 2 n + 1 ) 6 \underset{i=1}{\overset{n}{\sum}}i^2=\frac{n(n+1)(2n+1)}{6} i=1∑ni2=6n(n+1)(2n+1)
∑ n i = 1 i 3 = ( n ( n + 1 ) 2 ) 2 \underset{i=1}{\overset{n}{\sum}}i^3=\left(\frac{n(n+1)}{2}\right)^2 i=1∑ni3=(2n(n+1))2
下面给出证明。
∑ i = 1 n i k = ∑ i = 1 k + 1 ( − 1 ) δ i k ( k + 1 i ) B k + 1 − i n i k + 1 \overset{n}{\underset{i=1}\sum}i^k=\frac {\overset{k+1}{\underset{i=1}\sum}(-1)^{\delta _{ik}}\begin{pmatrix}k+1\\ i\end{pmatrix}B_{k+1-i}n^i}{k+1} i=1∑nik=k+1i=1∑k+1(−1)δik(k+1i)Bk+1−ini
伯努利数求起来慢,基本上没什么用。
∑ i = 0 n i K = ∑ j = 0 K { K j } j ! ( n + 1 j + 1 ) \overset{n}{\underset{i=0}\sum}i^K=\overset{K}{\underset{j=0}\sum}\begin{Bmatrix}K\\ j\end{Bmatrix}j!\begin{pmatrix}n+1\\ j+1\end{pmatrix} i=0∑niK=j=0∑K{Kj}j!(n+1j+1)
应用第二类斯特林数求值可以做到 O ( K log K ) O(K\log K) O(KlogK)。
证明:
∑ i = 0 n i K = ∑ i = 0 n ∑ j = 0 K { K j } ( i j ) j ! = ∑ j = 0 K { K j } j ! ∑ i = 0 n ( i j ) \overset{n}{\underset{i=0}\sum}i^K=\overset{n}{\underset{i=0}\sum}\overset{K}{\underset{j=0}\sum}\begin{Bmatrix}K\\ j\end{Bmatrix}\begin{pmatrix}i\\ j\end{pmatrix}j!=\overset{K}{\underset{j=0}\sum}\begin{Bmatrix}K\\ j\end{Bmatrix}j!\overset{n}{\underset{i=0}\sum}\begin{pmatrix}i\\ j\end{pmatrix} i=0∑niK=i=0∑nj=0∑K{Kj}(ij)j!=j=0∑K{Kj}j!i=0∑n(ij)
最后一个式子是朱世杰恒等式。
= ∑ j = 0 K { K j } j ! ( n + 1 j + 1 ) =\overset{K}{\underset{j=0}\sum}\begin{Bmatrix}K\\ j\end{Bmatrix}j!\begin{pmatrix}n+1\\ j+1\end{pmatrix} =j=0∑K{Kj}j!(n+1j+1)
伸缩级数常用于各类数列问题的探索中。
其实就是对差分数组求前缀和那个意思。
伸缩级数:
∑ i = l r f ( i ) − f ( i − 1 ) = f ( r ) − f ( l − 1 ) \overset{r}{\underset{i=l}\sum}f(i)-f(i-1)=f(r)-f(l-1) i=l∑rf(i)−f(i−1)=f(r)−f(l−1)
先来推导平方数求和公式。
∑ i = 1 n i 2 = n ( n + 1 ) ( 2 n + 1 ) 6 \overset{n}{\underset{i=1}\sum}i^2=\frac {n(n+1)(2n+1)}6 i=1∑ni2=6n(n+1)(2n+1)
证明:
根据伸缩级数,会有:
∑ i = 1 n i 3 − ( i − 1 ) 3 = n 3 \overset{n}{\underset{i=1}\sum}i^3-(i-1)^3=n^3 i=1∑ni3−(i−1)3=n3
∑ i = 1 n i 3 − i 3 + 3 i 2 + 3 i + 1 = n 3 \overset{n}{\underset{i=1}\sum}i^3-i^3+3i^2+3i+1=n^3 i=1∑ni3−i3+3i2+3i+1=n3
∑ i = 1 n 3 i 2 + 3 i + 1 = n 3 \overset{n}{\underset{i=1}\sum}3i^2+3i+1=n^3 i=1∑n3i2+3i+1=n3
3 ∑ i = 1 n i 2 − 3 ∑ i = 1 n i + ∑ i = 1 n 1 = n 3 3\overset{n}{\underset{i=1}\sum}i^2-3\overset{n}{\underset{i=1}\sum}i+\overset{n}{\underset{i=1}\sum}1=n^3 3i=1∑ni2−3i=1∑ni+i=1∑n1=n3
3 ∑ i = 1 n i 2 − 3 ∑ i = 1 n i + n = n 3 3\overset{n}{\underset{i=1}\sum}i^2-3\overset{n}{\underset{i=1}\sum}i+n=n^3 3i=1∑ni2−3i=1∑ni+n=n3
3 ∑ i = 1 n i 2 − 3 n ( n + 1 ) 2 + n = n 3 3\overset{n}{\underset{i=1}\sum}i^2-\frac{3n(n+1)}{2}+n=n^3 3i=1∑ni2−23n(n+1)+n=n3
∑ i = 1 n i 2 = n 3 + 3 n ( n + 1 ) 2 − n 3 = n ( n + 1 ) ( 2 n + 1 ) 6 \overset{n}{\underset{i=1}\sum}i^2=\frac{n^3+\frac{3n(n+1)}{2}-n}3=\frac{n(n+1)(2n+1)}6 i=1∑ni2=3n3+23n(n+1)−n=6n(n+1)(2n+1)
∑ i = 1 n i 3 = ( n ( n + 1 ) 2 ) 2 \overset{n}{\underset{i=1}\sum}i^3=\left(\frac{n(n+1)}{2}\right)^2 i=1∑ni3=(2n(n+1))2
证明同理。
∑ i = 1 n i K = n K + 1 + ∑ i = 1 n ∑ j = 1 K − 1 ( K + 1 j ) i j ( − 1 ) K + 1 − j ( K + 1 K ) \overset{n}{\underset{i=1}\sum}i^{K}=\frac{n^{K+1}+\overset{n}{\underset{i=1}\sum}\overset{K-1}{\underset{j=1}\sum}{\bigl(\begin{smallmatrix}K+1\\ j\end{smallmatrix}\bigr)}i^j(-1)^{K+1-j}}{\bigl(\begin{smallmatrix}K+1\\ K\end{smallmatrix}\bigr)} i=1∑niK=(K+1K)nK+1+i=1∑nj=1∑K−1(K+1j)ij(−1)K+1−j
直接运用这个公式实用性不足,通常需要提前在纸上化简,再进行运用,因此在次数较高时少有作用。
但说明了一个重要的结论: K K K次方数求和的结果可以被表示为一个 K + 1 K+1 K+1次函数。
证明:
∑ i = 1 n i K − ( i − 1 ) K = n K \overset{n}{\underset{i=1}\sum}i^K-(i-1)^K=n^K i=1∑niK−(i−1)K=nK
把 ( i − 1 ) K (i-1)^K (i−1)K用二项式定理展开:
= ∑ i = 1 n i K − ∑ j = 1 K ( K j ) i j ( − 1 ) K − j =\overset{n}{\underset{i=1}\sum}i^K-\overset{K}{\underset{j=1}\sum}\begin{pmatrix}K\\ j\end{pmatrix}i^j(-1)^{K-j} =i=1∑niK−j=1∑K(Kj)ij(−1)K−j
把 i i i的 K , K − 1 K,K-1 K,K−1次项分离出来:
= ∑ i = 1 n i K − i K + ( K K − 1 ) i K − 1 − ∑ j = 1 K − 2 ( K j ) i j ( − 1 ) K − j =\overset{n}{\underset{i=1}\sum}i^K-i^K+\begin{pmatrix}K\\ K-1\end{pmatrix}i^{K-1}-\overset{K-2}{\underset{j=1}\sum}\begin{pmatrix}K\\ j\end{pmatrix}i^j(-1)^{K-j} =i=1∑niK−iK+(KK−1)iK−1−j=1∑K−2(Kj)ij(−1)K−j
和式的变换:
= ( K K − 1 ) ∑ i = 1 n i K − 1 − ∑ i = 1 n ∑ j = 1 K − 2 ( K j ) i j ( − 1 ) K − j =\begin{pmatrix}K\\ K-1\end{pmatrix}\overset{n}{\underset{i=1}\sum}i^{K-1}-\overset{n}{\underset{i=1}\sum}\overset{K-2}{\underset{j=1}\sum}\begin{pmatrix}K\\ j\end{pmatrix}i^j(-1)^{K-j} =(KK−1)i=1∑niK−1−i=1∑nj=1∑K−2(Kj)ij(−1)K−j
因而有:
( K K − 1 ) ∑ i = 1 n i K − 1 − ∑ i = 1 n ∑ j = 1 K − 2 ( K j ) i j ( − 1 ) K − j = n K \begin{pmatrix}K\\ K-1\end{pmatrix}\overset{n}{\underset{i=1}\sum}i^{K-1}-\overset{n}{\underset{i=1}\sum}\overset{K-2}{\underset{j=1}\sum}\begin{pmatrix}K\\ j\end{pmatrix}i^j(-1)^{K-j}=n^K (KK−1)i=1∑niK−1−i=1∑nj=1∑K−2(Kj)ij(−1)K−j=nK
整理一下:
∑ i = 1 n i K − 1 = n K + ∑ i = 1 n ∑ j = 1 K − 2 ( K j ) i j ( − 1 ) K − j ( K K − 1 ) \overset{n}{\underset{i=1}\sum}i^{K-1}=\frac{n^K+\overset{n}{\underset{i=1}\sum}\overset{K-2}{\underset{j=1}\sum}{\bigl(\begin{smallmatrix}K\\ j\end{smallmatrix}\bigr)}i^j(-1)^{K-j}}{\bigl(\begin{smallmatrix}K\\ K-1\end{smallmatrix}\bigr)} i=1∑niK−1=(KK−1)nK+i=1∑nj=1∑K−2(Kj)ij(−1)K−j
这就是说:
∑ i = 1 n i K = n K + 1 + ∑ i = 1 n ∑ j = 1 K − 1 ( K + 1 j ) i j ( − 1 ) K + 1 − j ( K + 1 K ) \overset{n}{\underset{i=1}\sum}i^{K}=\frac{n^{K+1}+\overset{n}{\underset{i=1}\sum}\overset{K-1}{\underset{j=1}\sum}{\bigl(\begin{smallmatrix}K+1\\ j\end{smallmatrix}\bigr)}i^j(-1)^{K+1-j}}{\bigl(\begin{smallmatrix}K+1\\ K\end{smallmatrix}\bigr)} i=1∑niK=(K+1K)nK+1+i=1∑nj=1∑K−1(K+1j)ij(−1)K+1−j
QED.
前面说到: K K K次方数求和的结果可以被表示为一个 K + 1 K+1 K+1次函数。
K K K次方数求和可以用拉格朗日插值法处理,复杂度 O ( K ) O(K) O(K)。
与 K K K次普通幂求和一样, K K K次上升幂求和也可以有类似的做法,如斯特林反演,但是上升幂求和的性质太好了,完全不需要。
.
∑ i = 1 n i 2 ‾ = ∑ i = 1 n i ( i + 1 ) = n ( n + 1 ) ( n + 2 ) 3 \overset{n}{\underset{i=1}\sum}i^{\overline 2}=\overset{n}{\underset{i=1}\sum}{i(i+1)}=\frac {n(n+1)(n+2)}3 i=1∑ni2=i=1∑ni(i+1)=3n(n+1)(n+2)
证明:
∑ i = 1 n i ( i + 1 ) = ∑ i = 1 n i 2 + ∑ i = 1 n i = n ( n + 1 ) ( 2 n + 1 ) 6 + n ( n + 1 ) 2 = n ( n + 1 ) ( n + 2 ) 3 \overset{n}{\underset{i=1}\sum}i(i+1)=\overset{n}{\underset{i=1}\sum}i^2+\overset{n}{\underset{i=1}\sum}i=\frac {n(n+1)(2n+1)}{6}+\frac {n(n+1)} 2=\frac {n(n+1)(n+2)}3 i=1∑ni(i+1)=i=1∑ni2+i=1∑ni=6n(n+1)(2n+1)+2n(n+1)=3n(n+1)(n+2)
∑ i = 1 n i K ‾ = n K + 1 ‾ K + 1 \overset{n}{\underset{i=1}\sum}i^{\overline K}=\frac{n^{\overline{K+1}}}{K+1} i=1∑niK=K+1nK+1
证明:
第一想法是组合,但是组合不太好做。第二想法是归纳,但是归纳不太好做。于是又是伸缩级数:
∑ i = 1 n i K ‾ − ( i − 1 ) K ‾ = n K ‾ \overset{n}{\underset{i=1}\sum}i^{\overline K}-(i-1)^{\overline{K}}=n^{\overline K} i=1∑niK−(i−1)K=nK
∑ i = 1 n i K − 1 ‾ ( i + k − 1 ) − i K − 1 ‾ ( i − 1 ) = n K ‾ \overset{n}{\underset{i=1}\sum}i^{\overline{K-1}}(i+k-1)-i^{\overline {K-1}}(i-1)=n^{\overline K} i=1∑niK−1(i+k−1)−iK−1(i−1)=nK
K ∑ i = 1 n i K − 1 ‾ = n K ‾ K\overset{n}{\underset{i=1}\sum}i^{\overline{K-1}}=n^{\overline K} Ki=1∑niK−1=nK
∑ i = 1 n i K − 1 ‾ = n K ‾ K \overset{n}{\underset{i=1}\sum}i^{\overline{K-1}}=\frac {n^{\overline K}}{K} i=1∑niK−1=KnK
于是有:
∑ i = 1 n i K ‾ = n K + 1 ‾ K + 1 \overset{n}{\underset{i=1}\sum}i^{\overline{K}}=\frac {n^{\overline {K+1}}}{K+1} i=1∑niK=K+1nK+1
QED.
复杂度 O ( K ) O(K) O(K)
∑ n i = 1 1 i \underset{i=1}{\overset{n}{\sum}}\frac 1i i=1∑ni1称为调和级数。
公式:
∑ n i = 1 1 i ≈ ln ( n + 1 ) + γ = O ( log n ) \underset{i=1}{\overset{n}{\sum}}\frac 1i\approx \ln(n+1)+γ=O(\log n) i=1∑ni1≈ln(n+1)+γ=O(logn)
其中 γ γ γ表示欧拉-马歇罗尼常数,约为0.5772156649。
要注意到公式是极限意义下的,因此只有在 n n n很大时才可以使用公式,在 n n n小的时候可以直接计算。
复杂度 O ( 1 ) O(1) O(1)
∑ n i = 1 1 i K \underset{i=1}{\overset{n}{\sum}}\frac 1{i^K} i=1∑niK1情况较复杂,但我们知道:
∑ + ∞ i = 1 1 i 2 = π 2 6 \underset{i=1}{\overset{+\infty}{\sum}}\frac 1{i^2}=\frac {\pi^2}{6} i=1∑+∞i21=6π2
∑ n i = 1 1 i ( i + 1 ) = 1 − 1 n + 1 \underset{i=1}{\overset{n}{\sum}}\frac 1{i(i+1)}=1-\frac 1{n+1} i=1∑ni(i+1)1=1−n+11
引理: 1 i ( i + 1 ) = 1 i − 1 i − 1 \frac{1}{i(i+1)}=\frac 1 i-\frac 1{i-1} i(i+1)1=i1−i−11
证明显而易见。
∑ n i = 1 1 i ( i + k ) = 1 k ( ∑ k i = 1 1 i − ∑ n + k i = n + 1 1 i ) \underset{i=1}{\overset{n}{\sum}}\frac 1{i(i+k)}=\frac 1k\left(\underset{i=1}{\overset{k}{\sum}}\frac 1i-\underset{i=n+1}{\overset{n+k}{\sum}}\frac 1i\right) i=1∑ni(i+k)1=k1(i=1∑ki1−i=n+1∑n+ki1)
引理:
1 i ( i + k ) = 1 k ( 1 i − 1 i + k ) \frac 1{i(i+k)}=\frac 1k\left(\frac 1i-\frac 1{i+k}\right) i(i+k)1=k1(i1−i+k1)
证明显然。
时间复杂度 O ( 1 ) O(1) O(1)。
∑ n i = 1 1 i K ‾ = 1 K − 1 ( 1 1 K − 1 ‾ − 1 ( n + 1 ) K − 1 ‾ ) \underset{i=1}{\overset{n}{\sum}}\frac 1{i^{\overline{K}}}=\frac 1{K-1}\left(\frac 1{1^{\overline{K-1}}}-\frac{1}{(n+1)^{\overline{K-1}}}\right) i=1∑niK1=K−11(1K−11−(n+1)K−11)
证明还是伸缩级数(伸缩级数杀疯了):
1 1 K ‾ + ∑ n i = 2 1 i K ‾ − 1 ( i − 1 ) K ‾ = 1 n K ‾ \frac 1{1^{\overline{K}}}+\underset{i=2}{\overset{n}{\sum}}\frac 1{i^{\overline K}}-\frac{1}{(i-1)^{\overline{K}}}=\frac{1}{n^{\overline{K}}} 1K1+i=2∑niK1−(i−1)K1=nK1
之所以不从第一项开始求和,是为了规避分母为0的情况,也可以认为伸缩级数求和起点改变。
∑ n i = 2 1 i K ‾ − 1 ( i − 1 ) K ‾ = 1 n K ‾ − 1 1 K ‾ \underset{i=2}{\overset{n}{\sum}}\frac 1{i^{\overline K}}-\frac{1}{(i-1)^{\overline{K}}}=\frac{1}{n^{\overline{K}}}-\frac 1{1^{\overline{K}}} i=2∑niK1−(i−1)K1=nK1−1K1
现在处理左边:
∑ n i = 2 i − 1 ( i − 1 ) ⋅ i K ‾ − i + K − 1 ( i − 1 ) ⋅ i K ‾ \underset{i=2}{\overset{n}{\sum}}\frac{i-1}{(i-1)\cdot i^{\overline{K}}}-\frac{i+K-1}{(i-1)\cdot{i^{\overline{K}}}} i=2∑n(i−1)⋅iKi−1−(i−1)⋅iKi+K−1
= ∑ n i = 2 1 i K ‾ ⋅ ( i − 1 i − 1 − i + K − 1 i − 1 ) =\underset{i=2}{\overset{n}{\sum}}\frac 1{i^{\overline{K}}}\cdot \left(\frac {i-1}{i-1}-\frac{i+K-1}{i-1}\right) =i=2∑niK1⋅(i−1i−1−i−1i+K−1)
= − K ∑ n i = 2 1 i K ‾ ⋅ 1 i − 1 =-K\underset{i=2}{\overset{n}{\sum}}\frac 1{i^{\overline{K}}}\cdot\frac{1}{i-1} =−Ki=2∑niK1⋅i−11
= − K ∑ n i = 2 1 ( i − 1 ) K + 1 ‾ =-K\underset{i=2}{\overset{n}{\sum}}\frac{1}{(i-1)^{\overline{K+1}}} =−Ki=2∑n(i−1)K+11
左右相等:
− K ∑ n i = 2 1 ( i − 1 ) K + 1 ‾ = 1 n K ‾ − 1 1 K ‾ -K\underset{i=2}{\overset{n}{\sum}}\frac{1}{(i-1)^{\overline{K+1}}}=\frac{1}{n^{\overline{K}}}-\frac 1{1^{\overline{K}}} −Ki=2∑n(i−1)K+11=nK1−1K1
∑ n i = 2 1 ( i − 1 ) K + 1 ‾ = − 1 n K ‾ − 1 1 K ‾ K \underset{i=2}{\overset{n}{\sum}}\frac{1}{(i-1)^{\overline{K+1}}}=-\frac{\frac{1}{n^{\overline{K}}}-\frac 1{1^{\overline{K}}}}{K} i=2∑n(i−1)K+11=−KnK1−1K1
这就是说:
∑ n i = 1 1 i K ‾ = 1 K − 1 ( 1 1 K − 1 ‾ − 1 ( n + 1 ) K − 1 ‾ ) \underset{i=1}{\overset{n}{\sum}}\frac{1}{i^{\overline{K}}}=\frac 1{K-1}\left(\frac 1{1^{\overline{K-1}}}-\frac{1}{(n+1)^{\overline{K-1}}}\right) i=1∑niK1=K−11(1K−11−(n+1)K−11)
QED.
时间复杂度 O ( K ) O(K) O(K)
定义符号 x ( n ‾ + k ) = ∏ n − 1 i = 0 ( x + k ⋅ i ) x^{\left(\overline{n}+k\right)}=\underset{i=0}{\overset{n-1}{\prod}}(x+k\cdot i) x(n+k)=i=0∏n−1(x+k⋅i),其中 k k k是一固定的常数,这为我们的推理提供很大的方便。我们可以简记为 x ( n ‾ ) x^{(\overline{n})} x(n)
也就会有 x ( n ‾ + f ) = ∏ n − 1 i = 0 ( x + f ( i ) ) x^{\left(\overline{n}+f\right)}=\underset{i=0}{\overset{n-1}{\prod}}(x+f(i)) x(n+f)=i=0∏n−1(x+f(i)),也可以简记为 x ( n ‾ ) x^{(\overline n)} x(n)
探索类 K K K次上升幂求和问题,使用伸缩级数是不太行的了,我们用广义伸缩级数:
∑ r i = l f ( i ) − f ( i − k ) = ∑ r i = r − k + 1 f ( i ) − ∑ l − 1 i = l − k f ( i ) \underset{i=l}{\overset{r}{\sum}}f(i)-f(i-k)=\underset{i=r-k+1}{\overset{r}{\sum}}f(i)-\underset{i=l-k}{\overset{l-1}{\sum}}f(i) i=l∑rf(i)−f(i−k)=i=r−k+1∑rf(i)−i=l−k∑l−1f(i)
∑ n i = 1 i ( K ‾ ) = 1 c ⋅ ( K + 1 ) ( ∑ n i = n − c + 1 i ( K + 1 ‾ ) − ∑ 0 i = 1 − c i ( K + 1 ‾ ) ) \underset{i=1}{\overset{n}{\sum}}i^{\left(\overline {K} \right)}=\frac{1}{c\cdot (K+1)}\left(\underset{i=n-c+1}{\overset{n}{\sum}}i^{\left(\overline {K+1}\right)}-\underset{i=1-c}{\overset{0}{\sum}}i^{\left(\overline{K+1}\right)}\right) i=1∑ni(K)=c⋅(K+1)1(i=n−c+1∑ni(K+1)−i=1−c∑0i(K+1))
其中 n ( x ‾ ) = n ( x ‾ + c ) n^{(\overline x)}=n^{(\overline x+c)} n(x)=n(x+c)。
证明:
根据广义伸缩级数:
∑ n i = 1 i ( K ‾ ) − ( i − c ) ( K ‾ ) = ∑ n i = n − c + 1 i ( K ‾ ) − ∑ 0 i = 1 − c i ( K ‾ ) \underset{i=1}{\overset{n}{\sum}}i^{\left(\overline K \right)}-(i-c)^{\left(\overline{K}\right)}=\underset{i=n-c+1}{\overset{n}{\sum}}i^{\left(\overline K\right)}-\underset{i=1-c}{\overset{0}{\sum}}i^{\left(\overline{K}\right)} i=1∑ni(K)−(i−c)(K)=i=n−c+1∑ni(K)−i=1−c∑0i(K)
研究左边:
= ∑ n i = 1 ( i + c ( K − 1 ) ) i ( K − 1 ‾ ) − ( i − c ) i ( K − 1 ‾ ) =\underset{i=1}{\overset{n}{\sum}}\left(i+c(K-1)\right)i^{\left(\overline {K-1} \right)}-(i-c)i^{\left(\overline{K-1}\right)} =i=1∑n(i+c(K−1))i(K−1)−(i−c)i(K−1)
= ∑ n i = 1 c ⋅ K ⋅ i ( K − 1 ‾ ) =\underset{i=1}{\overset{n}{\sum}}c\cdot K\cdot i^{\left(\overline {K-1} \right)} =i=1∑nc⋅K⋅i(K−1)
= c ⋅ K ∑ n i = 1 i ( K − 1 ‾ ) =c\cdot K\underset{i=1}{\overset{n}{\sum}}i^{\left(\overline {K-1} \right)} =c⋅Ki=1∑ni(K−1)
左右相等,就是:
c ⋅ K ∑ n i = 1 i ( K − 1 ‾ ) = ∑ n i = n − c + 1 i ( K ‾ ) − ∑ 0 i = 1 − c i ( K ‾ ) c\cdot K\underset{i=1}{\overset{n}{\sum}}i^{\left(\overline {K-1} \right)}=\underset{i=n-c+1}{\overset{n}{\sum}}i^{\left(\overline K\right)}-\underset{i=1-c}{\overset{0}{\sum}}i^{\left(\overline{K}\right)} c⋅Ki=1∑ni(K−1)=i=n−c+1∑ni(K)−i=1−c∑0i(K)
∑ n i = 1 i ( k − 1 ‾ ) = 1 c ⋅ k ( ∑ n i = n − c + 1 i ( K ‾ ) − ∑ 0 i = 1 − c i ( K ‾ ) ) \underset{i=1}{\overset{n}{\sum}}i^{\left(\overline {k-1} \right)}=\frac{1}{c\cdot k}\left(\underset{i=n-c+1}{\overset{n}{\sum}}i^{\left(\overline K\right)}-\underset{i=1-c}{\overset{0}{\sum}}i^{\left(\overline{K}\right)}\right) i=1∑ni(k−1)=c⋅k1(i=n−c+1∑ni(K)−i=1−c∑0i(K))
∑ n i = 1 i ( K ‾ ) = 1 c ⋅ ( K + 1 ) ( ∑ n i = n − c + 1 i ( K + 1 ‾ ) − ∑ 0 i = 1 − c i ( K + 1 ‾ ) ) \underset{i=1}{\overset{n}{\sum}}i^{\left(\overline {K} \right)}=\frac{1}{c\cdot (K+1)}\left(\underset{i=n-c+1}{\overset{n}{\sum}}i^{\left(\overline {K+1}\right)}-\underset{i=1-c}{\overset{0}{\sum}}i^{\left(\overline{K+1}\right)}\right) i=1∑ni(K)=c⋅(K+1)1(i=n−c+1∑ni(K+1)−i=1−c∑0i(K+1))
QED.
时间复杂度 O ( c ⋅ K ) O\left( c\cdot K\right) O(c⋅K)。
∑ n i = 1 1 i ( K ‾ ) = ∑ n + c i = n + 1 1 i ( K − 1 ‾ ) − ∑ c i = 1 1 i ( K − 1 ‾ ) \underset{i=1}{\overset{n}{\sum}}\frac{1}{i^{\left(\overline K\right)}}=\underset{i=n+1}{\overset{n+c}{\sum}}\frac{1}{i^{\left(\overline{K-1}\right)}}-\underset{i=1}{\overset{c}{\sum}}\frac{1}{i^{\left(\overline{K-1}\right)}} i=1∑ni(K)1=i=n+1∑n+ci(K−1)1−i=1∑ci(K−1)1
其中 n ( x ‾ ) = n ( x ‾ + c ) n^{(\overline x)}=n^{(\overline x+c)} n(x)=n(x+c)。
证明一下:
根据广义伸缩级数:
∑ n i = c + 1 1 i ( K ‾ ) − 1 ( i − c ) ( K ‾ ) = ∑ n i = n − c + 1 1 i ( K ‾ ) − ∑ c i = 1 1 i ( K ‾ ) \underset{i=c+1}{\overset{n}{\sum}}\frac{1}{i^{\left(\overline K\right)}}-\frac{1}{(i-c)^{\left(\overline K\right)}}=\underset{i=n-c+1}{\overset{n}{\sum}}\frac 1{i^{\left(\overline K\right)}}-\underset{i=1}{\overset{c}{\sum}}\frac{1}{i^{\left(\overline K\right)}} i=c+1∑ni(K)1−(i−c)(K)1=i=n−c+1∑ni(K)1−i=1∑ci(K)1
研究左边:
= ∑ n i = c + 1 1 ( i + c ( K − 1 ) ) ⋅ i ( K − 1 ‾ ) − 1 ( i − c ) ⋅ i ( K − 1 ‾ ) =\underset{i=c+1}{\overset{n}{\sum}}\frac{1}{(i+c(K-1))\cdot i^{\left(\overline {K-1}\right)}}-\frac{1}{(i-c)\cdot i^{\left(\overline {K-1}\right)}} =i=c+1∑n(i+c(K−1))⋅i(K−1)1−(i−c)⋅i(K−1)1
= ∑ n i = c + 1 1 i ( K − 1 ‾ ) ( 1 ( i + c ( K − 1 ) ) − 1 ( i − c ) ) =\underset{i=c+1}{\overset{n}{\sum}} \frac{1}{i^{\left(\overline {K-1}\right)}}\left(\frac{1}{(i+c(K-1))}-\frac{1}{(i-c)}\right) =i=c+1∑ni(K−1)1((i+c(K−1))1−(i−c)1)
= ∑ n i = c + 1 1 i ( K − 1 ‾ ) ( 1 ( i + c ( K − 1 ) ) − 1 ( i − c ) ) =\underset{i=c+1}{\overset{n}{\sum}} \frac{1}{i^{\left(\overline {K-1}\right)}}\left(\frac{1}{(i+c(K-1))}-\frac{1}{(i-c)}\right) =i=c+1∑ni(K−1)1((i+c(K−1))1−(i−c)1)
= ∑ n i = c + 1 1 i ( K − 1 ‾ ) ( − c ⋅ K ( i + c ( K − 1 ) ) ( i − c ) ) =\underset{i=c+1}{\overset{n}{\sum}} \frac{1}{i^{\left(\overline {K-1}\right)}}\left(\frac{-c\cdot K}{\left(i+c(K-1)\right)(i-c)}\right) =i=c+1∑ni(K−1)1((i+c(K−1))(i−c)−c⋅K)
= − c ⋅ K ∑ n i = c + 1 1 ( i − c ) ( K + 1 ‾ ) =-c\cdot K\underset{i=c+1}{\overset{n}{\sum}} \frac{1}{(i-c)^{\left(\overline {K+1}\right)}} =−c⋅Ki=c+1∑n(i−c)(K+1)1
左右相等:
− c ⋅ K ∑ n i = c + 1 1 ( i − c ) ( K + 1 ‾ ) = ∑ n i = n − c + 1 1 i ( K ‾ ) − ∑ c i = 1 1 i ( K ‾ ) -c\cdot K\underset{i=c+1}{\overset{n}{\sum}} \frac{1}{(i-c)^{\left(\overline {K+1}\right)}}=\underset{i=n-c+1}{\overset{n}{\sum}}\frac 1{i^{\left(\overline K\right)}}-\underset{i=1}{\overset{c}{\sum}}\frac{1}{i^{\left(\overline K\right)}} −c⋅Ki=c+1∑n(i−c)(K+1)1=i=n−c+1∑ni(K)1−i=1∑ci(K)1
∑ n i = c + 1 1 ( i − c ) ( K + 1 ‾ ) = 1 c ⋅ K ( ∑ c i = 1 1 i ( K ‾ ) − ∑ n i = n − c + 1 1 i ( K ‾ ) ) \underset{i=c+1}{\overset{n}{\sum}} \frac{1}{(i-c)^{\left(\overline {K+1}\right)}}=\frac{1}{c\cdot K}{\left(\underset{i=1}{\overset{c}{\sum}}\frac{1}{i^{\left(\overline K\right)}}-\underset{i=n-c+1}{\overset{n}{\sum}}\frac 1{i^{\left(\overline K\right)}}\right)} i=c+1∑n(i−c)(K+1)1=c⋅K1(i=1∑ci(K)1−i=n−c+1∑ni(K)1)
即:
∑ n − c i = 1 1 i ( K + 1 ‾ ) = 1 c ⋅ K ( ∑ c i = 1 1 i ( K ‾ ) − ∑ n i = n − c + 1 1 i ( K ‾ ) ) \underset{i=1}{\overset{n-c}{\sum}} \frac{1}{i^{\left(\overline {K+1}\right)}}=\frac{1}{c\cdot K}{\left(\underset{i=1}{\overset{c}{\sum}}\frac{1}{i^{\left(\overline K\right)}}-\underset{i=n-c+1}{\overset{n}{\sum}}\frac 1{i^{\left(\overline K\right)}}\right)} i=1∑n−ci(K+1)1=c⋅K1(i=1∑ci(K)1−i=n−c+1∑ni(K)1)
∑ n i = 1 1 i ( K ‾ ) = 1 c ⋅ ( K − 1 ) ( ∑ c i = 1 1 i ( K − 1 ‾ ) − ∑ n + c i = n + 1 1 i ( K − 1 ‾ ) ) \underset{i=1}{\overset{n}{\sum}} \frac{1}{i^{\left(\overline {K}\right)}}=\frac{1}{c\cdot (K-1)}{\left(\underset{i=1}{\overset{c}{\sum}}\frac{1}{i^{\left(\overline {K-1}\right)}}-\underset{i=n+1}{\overset{n+c}{\sum}}\frac 1{i^{\left(\overline {K-1}\right)}}\right)} i=1∑ni(K)1=c⋅(K−1)1(i=1∑ci(K−1)1−i=n+1∑n+ci(K−1)1)
QED.
时间复杂度 O ( c ⋅ K ) O(c\cdot K) O(c⋅K)
计算 ⨁ n i = 1 ⨂ m j = 1 ( a j ⊙ i ) \underset{i=1}{\overset{n}\bigoplus} \underset{j=1}{\overset{m}\bigotimes}(a_j \odot i) i=1⨁nj=1⨂m(aj⊙i)
这里只讨论 ⊕ , ⊗ , ⊙ \oplus,\otimes,\odot ⊕,⊗,⊙为加法和乘法的情况的做法。
其他一些问题,往往采用科技来实现。
如 ∑ n i = 1 1 ∏ m j = 1 ( a j + i ) \underset{i=1}{\overset{n}\sum} \frac{1}{\underset{j=1}{\overset{m}\prod}(a_j+i)} i=1∑nj=1∏m(aj+i)1,可用多项式求逆。
如计算 n n n个数中选 k k k个数的乘积之和,可用分治NTT。
如任意多项式函数都可用拉格朗日插值法,但也需考虑到原始点值是否容易计算。
其他较复杂问题,不再一一讨论。
于是皆大欢喜。