ó
Ê½÷Xc           @` s¤   d  d l  m Z m Z m Z d  d l Z y d  d l Z Wn e k
 rK n Xy7 e j ƒ  % e j	 d e
 ƒ d  d l m Z Wd QXWn e k
 r– n Xd „  Z d S(   i    (   t   divisiont   print_functiont   absolute_importNt   ignore(   t   xc         ` sù   t  ˆ  ƒ } t ‡  f d †  t t  ˆ  ƒ ƒ Dƒ ƒ } t | j t d | ƒ j ƒ  } | d g } x/ t | ƒ D]! } | j | d | j ƒ  ƒ qm Wt j	 d ƒ g } x< t d | ƒ D]+ } | j | | j
 t | d ƒ | ƒ q´ Wt d „  | ƒ } | S(   s”  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` s!   |  ] } ˆ  | t  | Vq d  S(   N(   R   (   t   .0t   i(   t   a(    s>   /tmp/pip-build-7oUkmx/scipy/scipy/special/_precompute/utils.pys	   <genexpr>%   s    i    iÿÿÿÿi   c         S` s   t  j |  ƒ S(   N(   t   mpt   mpf(   R   (    (    s>   /tmp/pip-build-7oUkmx/scipy/scipy/special/_precompute/utils.pyt   <lambda>-   s    (   t   lent   sumt   rangeR   t   seriest   removeOt   appendt   expandR   R	   t   coefft   map(   R   t   nt   ft   ht   hpowert   kt   b(    (   R   s>   /tmp/pip-build-7oUkmx/scipy/scipy/special/_precompute/utils.pyt   lagrange_inversion   s    ()(   t
   __future__R    R   R   t   warningst   mpmathR   t   ImportErrort   catch_warningst   simplefiltert   DeprecationWarningt	   sympy.abcR   R   (    (    (    s>   /tmp/pip-build-7oUkmx/scipy/scipy/special/_precompute/utils.pyt   <module>   s   