
    tKgw                     T    	 d dl Z	 d dlmZ d Zy# e$ r Y w xY w# e$ r Y d Zyw xY w)    Nxc                     t               }t         fdt        |      D              }t        |z  j	                  t        d|      j                         }|dz  g}t        |      D ]'  }|j                  |d   |z  j                                ) t        j                  d      g}t        d|      D ]0  }|j                  ||   j                  t        |dz
        |z         2 |D cg c]  }t        j                  |       }}|S c c}w )a  Given 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.

    c              3   <   K   | ]  }|   t         |z  z    y w)Nr   ).0ias     c/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/scipy/special/_precompute/utils.py	<genexpr>z%lagrange_inversion.<locals>.<genexpr>   s     (x!AaDAIxs   r      )lensumranger   seriesremoveOappendexpandmpmpfcoeff)r	   nfhhpowerkbr   s   `       r
   lagrange_inversionr      s      	AA(uQx((A	
1Q1%%'AdVF1Xvbz!|++-. 	A1a[	AE*1,- AqAAH 	s   *D
)mpmathr   ImportError	sympy.abcr   r        r
   <module>r$      sF   		
  		
  			s     ''