L iwT ddlZ ddlmZdZy#e$rYwxYw#e$rYdZywxYw)Nxct}tfdt|D}t|z j td|j }|dzg}t|D]'}|j |d|zj)tjdg}td|D]0}|j ||jt|dz |z 2|Dcgc]}tj|}}|Scc}w)aGiven a series f(x) = a[1]*x + a[2]*x**2 + ... + a[n-1]*x**(n - 1), use the Lagrange inversion formula to compute a series g(x) = b[1]*x + b[2]*x**2 + ... + b[n-1]*x**(n - 1) so that f(g(x)) = g(f(x)) = x mod x**n. We must have a[0] = 0, so necessarily b[0] = 0 too. The algorithm is naive and could be improved, but speed isn't an issue here and it's easy to read. c3<K|]}|t|zzyw)Nr).0ias e/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/scipy/special/_precompute/utils.py z%lagrange_inversion..s (!AaDAI (sr) lensumrangerseriesremoveOappendexpandmpmpfcoeff)r nfhhpowerkbrs` r lagrange_inversionr s AA (uQx ((A 1 Q1%%'AdVF 1X/ vbz!|++-./  A 1a[. AE*1,-.qA H s*D )mpmathr ImportError sympy.abcrrr r$sF         s''