# FFT

## 常数优化1——IDFT

$<(\omega_n^0,A(\omega_n^0)),(\omega_n^1,A(\omega_n^1)),\cdots,(\omega_n^{n-1},A(\omega_n^{n-1}))>$

$[x^{rev(k)}]A(x)=\frac{1}{n}\sum_{i=0}^{n-1}\omega_n^{ki}A(\omega_n^i)$

$rev(k)=\begin{cases} 0 & k=0\\ n-k-1 & k\not= 0 \end{cases}$

$A(x)=\sum_{i=0}^{n-1}a_ix^i$

$[x^{rev(k)}]A(x)=\frac{1}{n}\sum_{i=0}^{n-1}\omega_n^{ki}\sum_{j=0}^{n-1}a_j\omega_n^{ij}$

$[x^{rev(k)}]A(x)=\frac{1}{n}\sum_{i=0}^{n-1}a_i\sum_{j=0}^{n-1}\omega_n^{ij}\omega_n^{kj}$

$[x^{rev(k)}]A(x)=\frac{1}{n}\sum_{i=0}^{n-1}a_i\sum_{j=0}^{n-1}\omega_n^{(i+k)j}$

$\omega_n^{(i+k)j}=1$

$\sum_{j=0}^{n-1}\omega_n^{(i+k)j}=n$

$\sum_{j=0}^{n-1}\omega_n^{(i+k)j}=\frac{1-\omega_n^{(i+k)n}}{1-\omega_n^{i+k}}=0$

$[x^{rev(k)}]A(x)=\frac{1}{n}a_{rev(k)}n=a_{rev(k)}$

## 常数优化2

$P(x)=A(x)+iB(x)$

$A(\omega_n^k)=\frac{P(\omega_n^k)+\mathrm{conj}(P(\omega_n^{rev(k)}))}{2}\\ B(\omega_n^k)=i\frac{P(\omega_n^k)-\mathrm{conj}(P(\omega_n^{rev(k)}))}{2}$

$\mathrm{conj}(P(\omega_n^{rev(k)}))=A(\omega_n^k)-iB(\omega_n^k)$

$A(x)=\sum_{i=0}^{n-1}a_ix^i\\ B(x)=\sum_{i=0}^{n-1}b_ix^i$

$A(\omega_n^k)-iB(\omega_n^k)=\sum_{j=0}^{n-1}a_j\omega_n^{kj}-i\sum_{j=0}^{n-1}b_j\omega_n^{kj}$

$\omega_n^k=\cos\frac{2\pi k}{n}+i\sin\frac{2\pi k}{n}$

$A(\omega_n^k)-iB(\omega_n^k)=\sum_{j=0}^{n-1}a_j(\cos \frac{2\pi kj}{n}+i\sin\frac{2\pi kj}{n})+\sum_{j=0}^{n-1}b_i(-i\cos \frac{2\pi kj}{n}+\sin \frac{2\pi kj}{n})$

$\mathrm{conj}(P(\omega_n^{rev(k)}))=\mathrm{conj}(A(\omega_n^{-k})+iB(\omega_n^{-k}))$

$\mathrm{conj}(P(\omega_n^{rev(k)}))=\mathrm{conj}(\sum_{j=0}^{n-1}a_j(\cos(-\frac{2\pi kj}{n})+i\sin(-\frac{2\pi kj}{n}))+\sum_{j=0}^{n-1}b_j(i\cos(-\frac{2\pi kj}{n})-\sin(-\frac{2\pi kj}{n})))$

$\mathrm{conj}(P(\omega_n^{rev(k)}))=\mathrm{conj}(\sum_{j=0}^{n-1}a_j(\cos \frac{2\pi kj}{n}-i\sin \frac{2\pi kj}{n})+\sum_{j=0}^{n-1}b_j(i\cos\frac{2\pi kj}{n}+\sin \frac{2\pi kj}{n}))$

$\mathrm{conj}(P(\omega_n^{rev(k)}))=A(\omega_n^k)-iB(\omega_n^k)$

# MTT

$A(x),B(x)$

$A(x)=p'Q_A(x)+R_A(x)\\ B(x)=p'Q_B(x)+R_B(x)$

$A(x)B(x)=p'^2Q_A(x)Q_B(x)+p'(Q_A(x)R_B(x)+Q_B(x)R_A(x))+R_A(x)R_B(x)$

# 多项式求逆

$A(x)F(x)=1\mod{x^n}$

$A(x)F_0(x)=1\mod x^{\lceil n/2\rceil}$

$F(x)-F_0(x)=0\mod x^{\lceil n/2\rceil}$

$F^2(x)-2F(x)F_0(x)+F_0^2(x)=0\mod x^n$

$F(x)-2F_0(x)+A(x)F_0^2(x)=0\mod x^n$

$F(x)=2F_0(x)-A(x)F_0^2(x)\mod x^n$

# 多项式取对数

$F(x)=\ln A(x)\mod x^{n}$

$F'(x)=A^{-1}(x)A'(x)\mod x^n$

$F(x)=\int A^{-1}(x)A'(x)\mathrm dx$

# 牛顿迭代

$G(F(x))=0\mod x^n$
$G(x)$已知，现在要求$F(x)$

$G(F_0(x))=0\mod x^{\lceil n/2\rceil}$

$G(F(x))=G(F_0(x))+\frac{G'(F_0(x))}{1!}(F(x)-F_0(x))+\frac{G''(F_0(x))}{2!}(F(x)-F_0(x))^2+\cdots$

$(F(x)-F_0(x))^k=0\mod x^n$
$k\geq 2$时都成立。

$G(F(x))=G(F_0(x))+G'(F_0(x))(F(x)-F_0(x))\mod x^n$

$G(F_0(x))=0\mod x^n$

$F(x)=F_0(x)-\frac{G(F_0(x))}{G'(F_0(x))}\mod x^n$

# 多项式求指数

$F(x)=e^{A(x)}\mod x^n$

$\ln F(x)=A(x)\mod x^n$

$G(F(x))=\ln F(x)-A(x)=0\mod x^n$

$G'(F(x))=F^{-1}(x)\mod x^n$

$\ln F_0(x)-A(x)=0\mod x^{\lceil n/2\rceil}$

$F(x)=F_0(x)-F_0(x)(\ln F_0(x)-A(x))\mod x^n$

$F(x)=F_0(x)(1-\ln F_0(x)+A(x))\mod x^n$

# 多项式开方

$F^2(x)=A(x)\mod x^n$

$G(F(x))=F^2(x)-A(x)=0\mod x^n$

$G'(F(x))=2F(x)\mod x^n$

$F_0^2(x)-A(x)=0\mod x^{\lceil n/2\rceil}$

$F(x)=F_0(x)-2^{-1}F_0^{-1}(x)(F_0^2(x)-A(x))\mod x^n$

$F(x)=2^{-1}(F_0(x)+A(x)F_0^{-1}(x))\mod x^n$

# 拉格朗日反演

$G(F(x))=x$

$[x^n]F(x)=\frac{1}{n}[x^{n-1}]\frac{1}{G'^n(x)}$

$G'(x)=\frac{G(x)}{x}$

UPD：证明