版本比较
多项式初等函数详解
正文
增加 71 行删除 2 行
142 行未改动全部展开143144145146147147148149150151180 行未改动全部展开33233333433533633633733833934019 行未改动36036136236336436536636736836914 行未改动384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454142 行未改动全部展开若我们已经得到 $ F(g_0(x)) \equiv 0 (\mod x^{\frac{n}{2}}) $,考虑如何求出 $ g(x) $。
将 $ F(g(x)) $ 在 $ g_0(x) $ 处泰勒展开,得:$$F(g(x))=\overset{\infty}{\underset{i=0}{\sum}} \frac{F^{(i)}(g_0(x))}{i!} (g(x)-g_0(x))^iF(g(x))=\sum^\infty_{i=0} \frac{F^{(i)}(g_0(x))}{i!} (g(x)-g_0(x))^i$$根据定义,得 $ g(x)-g_0(x) \equiv 0 (\mod x^{\frac{n}{2}}) $,所以 $ (g(x)-g_0(x))^2 \equiv 0 (\mod x^n) $。
代入上式,得180 行未改动全部展开\end{aligned}$$根据上式直接计算即可。$ (\tan f(x) = \frac{\sin f(x)}{\cos f(x)})$
运用NTT时,若取 $ p=998344353 $,则一般取 $ \mathrm i=86583718 $。运用NTT时,若取 $ p=998244353 $,则一般取 $ \mathrm i=86583718 $。
时间复杂度:$ O(n \log n) $。
:::info[实现代码]19 行未改动}```$ type=0 $ 表示 $ \sin f(x) $,$ type=1 $ 表示 $ \cos f(x) $。```for(int i=0;i<n;i++) f[i]=(1ll*f[i]*img)%mod;if(type==0){ poly_exp(f,n,q); poly_times(f,-1,n,f);14 行未改动
:::
[例题](https://www.luogu.com.cn/problem/P5264)
# 多项式反三角函数
已知 $ f(x) $,求 $ \arcsin f(x),\arccos f(x),\arctan f(x) $。
仿照求多项式对数函数的方法,对反三角函数先求导再积分得:$$\begin{aligned}\frac{d}{dx} \arcsin f(x) &= \frac{f'(x)}{\sqrt{1-f^2(x)}}\\\arcsin f(x) &= \int \frac{f'(x)}{\sqrt{1-f^2(x)}} dx\\\frac{d}{dx} \arccos f(x) &= -\frac{f'(x)}{\sqrt{1-f^2(x)}}\\\arccos f(x) &= -\int \frac{f'(x)}{\sqrt{1-f^2(x)}} dx\\\frac{d}{dx} \arctan f(x) &= \frac{f'(x)}{1+f^2(x)}\\\arctan f(x) &= \int \frac{f'(x)}{1+f^2(x)} dx\end{aligned}$$根据上式求解即可,时间复杂度:$ O(n \log n) $。
:::info[实现代码]
```void poly_sqrt(int *f,int size,int *ans){ int now,inv2; now=1; inv2=qmi(2,mod-2); ans[0]=1; while(now<size) { now<<=1; inv(ans,now,v); poly_mul(v,f,now,v); poly_add(ans,v,now,ans); poly_times(ans,inv2,now,ans); }}```$ type=0 $ 表示 $ \arcsin f(x) $,$ type=1 $ 表示 $ \arctan f(x) $。```size=1;while(size<n) size<<=1;if(type==0){ poly_mul(f,f,size,q); poly_times(q,-1,size,q); q[0]=(q[0]+1)%mod; poly_sqrt(q,size,r); inv(r,size,w); diff(f,size,g); poly_mul(g,w,size,g); integ(g,size,g);}else{ poly_mul(f,f,size,q); q[0]=(q[0]+1)%mod; inv(q,size,r); diff(f,size,w); poly_mul(r,w,size,g); integ(g,size,g);}```
:::
[例题](https://www.luogu.com.cn/problem/P5265)