Bootstrap

各类多项式操作的暴力递推法

一.一些约定.

对于接下来的所有操作,我们都是给出 F ( x ) F(x) F(x),求 G ( x ) = T ( F ( x ) ) G(x)=T(F(x)) G(x)=T(F(x)),其中 T ( ) T() T()是操作函数,我们的目标是在 O ( n 2 ) O(n^{2}) O(n2)的时间复杂度内完成所有操作.

多项式 F ( x ) , G ( x ) F(x),G(x) F(x),G(x)的系数分别为 f i , g i f_i,g_i fi,gi.


二.多项式求逆.

对于一个多项式 F ( x ) F(x) F(x),我们要求 G ( x ) G(x) G(x)满足 F ( x ) G ( x ) = 1 F(x)G(x)=1 F(x)G(x)=1.

那么有:
G ( x ) F ( x ) = 1 ∑ j = 0 i g j f i − j = 0 g i = − 1 f 0 ∑ j = 0 i − 1 g j f i − j G(x)F(x)=1\\ \sum_{j=0}^{i}g_jf_{i-j}=0\\ g_i=-\frac{1}{f_0}\sum_{j=0}^{i-1}g_{j}f_{i-j} G(x)F(x)=1j=0igjfij=0gi=f01j=0i1gjfij

其中初项 g 0 = 1 f 0 g_0=\frac{1}{f_0} g0=f01.


三.多项式ln.

对于一个常数项为 0 0 0的多项式 F ( x ) F(x) F(x),我们要求 G ( x ) G(x) G(x)满足 G ( x ) = ln ⁡ ( 1 + F ( x ) ) G(x)=\ln (1+F(x)) G(x)=ln(1+F(x)).

那么有:
G ( x ) = ln ⁡ ( 1 + F ( x ) ) G ′ ( x ) = F ′ ( x ) 1 + F ( x ) G ′ ( x ) ( 1 + F ( x ) ) = F ′ ( x ) G ′ ( x ) = F ′ ( x ) − G ′ ( x ) F ( x ) ( i + 1 ) g i + 1 = ( i + 1 ) f i + 1 − ∑ j = 0 i − 1 ( j + 1 ) g j + 1 f i − j g i + 1 = f i + 1 − 1 i + 1 ∑ j = 0 i − 1 ( j + 1 ) g j + 1 f i − j g i = f i − 1 i ∑ j = 1 i − 1 j g j f i − j G(x)=\ln(1+F(x))\\ G'(x)=\frac{F'(x)}{1+F(x)}\\ G'(x)(1+F(x))=F'(x)\\ G'(x)=F'(x)-G'(x)F(x)\\ (i+1)g_{i+1}=(i+1)f_{i+1}-\sum_{j=0}^{i-1}(j+1)g_{j+1}f_{i-j}\\ g_{i+1}=f_{i+1}-\frac{1}{i+1}\sum_{j=0}^{i-1}(j+1)g_{j+1}f_{i-j}\\ g_i=f_i-\frac{1}{i}\sum_{j=1}^{i-1}jg_{j}f_{i-j} G(x)=ln(1+F(x))G(x)=1+F(x)F(x)G(x)(1+F(x))=F(x)G(x)=F(x)G(x)F(x)(i+1)gi+1=(i+1)fi+1j=0i1(j+1)gj+1fijgi+1=fi+1i+11j=0i1(j+1)gj+1fijgi=fii1j=1i1jgjfij

其中初项 g 0 = 0 g_0=0 g0=0.


四.多项式exp.

对于一个常数项为 0 0 0的多项式 F ( x ) F(x) F(x),我们要求 G ( x ) G(x) G(x)满足 G ( x ) = e F ( x ) G(x)=e^{F(x)} G(x)=eF(x).

那么有:
G ( x ) = e F ( x ) G ′ ( x ) = e F ( x ) F ′ ( x ) G ′ ( x ) = F ′ ( x ) G ( x ) ( i + 1 ) g i + 1 = ∑ j = 0 i ( j + 1 ) f j + 1 g i − j g i + 1 = 1 i + 1 ∑ j = 0 i ( j + 1 ) f j + 1 g i − j g i = 1 i ∑ j = 1 i j f j g i − j G(x)=e^{F(x)}\\ G'(x)=e^{F(x)}F'(x)\\ G'(x)=F'(x)G(x)\\ (i+1)g_{i+1}=\sum_{j=0}^{i}(j+1)f_{j+1}g_{i-j}\\ g_{i+1}=\frac{1}{i+1}\sum_{j=0}^{i}(j+1)f_{j+1}g_{i-j}\\ g_{i}=\frac{1}{i}\sum_{j=1}^{i}jf_{j}g_{i-j} G(x)=eF(x)G(x)=eF(x)F(x)G(x)=F(x)G(x)(i+1)gi+1=j=0i(j+1)fj+1gijgi+1=i+11j=0i(j+1)fj+1gijgi=i1j=1ijfjgij

其中初项 g 0 = 1 g_0=1 g0=1.


五.多项式开方.

对于一个多项式 F ( x ) F(x) F(x),我们要求 G ( x ) G(x) G(x)满足 G 2 ( x ) = F ( x ) G^{2}(x)=F(x) G2(x)=F(x).

那么有:
G 2 ( x ) = F ( x ) ∑ j = 0 i g j g i − j = f i 2 g 0 g i = f i − ∑ j = 1 i − 1 g j g i − j g i = 1 2 g 0 ( f i − ∑ j = 1 i − 1 g j g i − j ) G^{2}(x)=F(x)\\ \sum_{j=0}^{i}g_{j}g_{i-j}=f_i\\ 2g_{0}g_{i}=f_i-\sum_{j=1}^{i-1}g_{j}g_{i-j}\\ g_i=\frac{1}{2g_0}\left(f_i-\sum_{j=1}^{i-1}g_{j}g_{i-j}\right) G2(x)=F(x)j=0igjgij=fi2g0gi=fij=1i1gjgijgi=2g01(fij=1i1gjgij)

其中初项 g 0 = f 0 g_0=\sqrt{f_0} g0=f0 .


六.多项式求幂.

对于一个多项式 F ( x ) F(x) F(x),我们要求 G ( x ) G(x) G(x)满足 G ( x ) = F k ( x ) G(x)=F^{k}(x) G(x)=Fk(x),其中 k k k是一个常数.

那么有:
G ( x ) = F k ( x ) G ′ ( x ) = k F ′ ( x ) F k − 1 ( x ) G ′ ( x ) = k F ′ ( x ) G ( x ) F ( x ) G ′ ( x ) F ( x ) = k G ( x ) F ′ ( x ) ∑ j = 0 i ( j + 1 ) g j + 1 f i − j = k ∑ j = 0 i g j ( i − j + 1 ) f i − j + 1 ( i + 1 ) f 0 g i + 1 = k ∑ j = 0 i g j ( i − j + 1 ) f i − j + 1 − ∑ j = 0 i − 1 ( j + 1 ) g j + 1 f i − j ( i + 1 ) f 0 g i + 1 = k ∑ j = 0 i ( i − j + 1 ) g j f i − j + 1 − ∑ j = 1 i j g j f i − j + 1 ( i + 1 ) f 0 g i + 1 = k ( i + 1 ) g 0 f i + 1 + ∑ j = 1 i g j f i − j + 1 ( k i − k j + k − j ) g i + 1 = 1 f 0 ( k g 0 f i + 1 + 1 i + 1 ∑ j = 1 i g j f i − j + 1 ( k i − k j + k − j ) ) g i = 1 f 0 ( k g 0 f i + 1 i ∑ j = 1 i − 1 g j f i − j ( k i − k j − j ) ) G(x)=F^{k}(x)\\ G'(x)=kF'(x)F^{k-1}(x)\\ G'(x)=kF'(x)\frac{G(x)}{F(x)}\\ G'(x)F(x)=kG(x)F'(x)\\ \sum_{j=0}^{i}(j+1)g_{j+1}f_{i-j}=k\sum_{j=0}^{i}g_{j}(i-j+1)f_{i-j+1}\\ (i+1)f_{0}g_{i+1}=k\sum_{j=0}^{i}g_{j}(i-j+1)f_{i-j+1}-\sum_{j=0}^{i-1}(j+1)g_{j+1}f_{i-j}\\ (i+1)f_{0}g_{i+1}=k\sum_{j=0}^{i}(i-j+1)g_{j}f_{i-j+1}-\sum_{j=1}^{i}jg_{j}f_{i-j+1}\\ (i+1)f_{0}g_{i+1}=k(i+1)g_0f_{i+1}+\sum_{j=1}^{i}g_{j}f_{i-j+1}(ki-kj+k-j)\\ g_{i+1}=\frac{1}{f_0}\left(kg_0f_{i+1}+\frac{1}{i+1}\sum_{j=1}^{i}g_jf_{i-j+1}(ki-kj+k-j)\right)\\ g_{i}=\frac{1}{f_0}\left(kg_0f_{i}+\frac{1}{i}\sum_{j=1}^{i-1}g_{j}f_{i-j}(ki-kj-j)\right) G(x)=Fk(x)G(x)=kF(x)Fk1(x)G(x)=kF(x)F(x)G(x)G(x)F(x)=kG(x)F(x)j=0i(j+1)gj+1fij=kj=0igj(ij+1)fij+1(i+1)f0gi+1=kj=0igj(ij+1)fij+1j=0i1(j+1)gj+1fij(i+1)f0gi+1=kj=0i(ij+1)gjfij+1j=1ijgjfij+1(i+1)f0gi+1=k(i+1)g0fi+1+j=1igjfij+1(kikj+kj)gi+1=f01(kg0fi+1+i+11j=1igjfij+1(kikj+kj))gi=f01(kg0fi+i1j=1i1gjfij(kikjj))

其中初项 g 0 = f 0 k g_0=f_0^{k} g0=f0k.

对于 f 0 = 0 f_0=0 f0=0的情况,我们可以先把最后面的几个 0 0 0去掉,算完之后再添加回去.

;