ó
î&]\c           @` s   d  Z  d d l m Z m Z m Z d d l Z y d d l Z d d l j	 Z
 Wn e k
 r` n Xd   Z d   Z e d k r e   n  d S(   s   Compute a Pade approximation for the principle branch of the
Lambert W function around 0 and compare it to various other
approximations.

i    (   t   divisiont   print_functiont   absolute_importNc          C` sd   g  }  x6 t  d  D]( } |  j t j t j d d |  q Wt j |  d d  \ } } | | f S(   Ni   i    t   ni   i   (   t   ranget   appendt   mpmatht   difft   lambertwt   pade(   t   derivsR   t   pt   q(    (    sA   lib/python2.7/site-packages/scipy/special/_precompute/lambertw.pyt   lambertw_pade   s
    &c       	   C` sC  t  t  t j d  a t   \ }  } |  d  d  d  | d  d  d  }  } t  d j |    t  d j |   Wd  QXt j d d d  t j d d d  } } t j | |  \ } } | d | } g  } x0 | j	   D]" } | j
 t t j |    qŕ Wt j |  j | j  } t j d	 d
 d d  \ } } t j g  |  D] }	 t |	  ^ qL }  t j g  | D] }
 t |
  ^ qt } t j |  |  t j | |  } t | |  } | d j | | |  t j |  t j t j |   } t | |  } | d j | | |  t j d t j d  | d  }  d |  |  d d
 } t | |  } | d j | | |  } | j | d | j   j   t j   t j d	 d d d  \ } } | | k  } | j | | |  } t j d d  } | j d t |  d | d  | j | d | t j   d  S(   Ni2   i˙˙˙˙s   p = {}s   q = {}g      řżg      ř?iK   y              đ?t   nrowsi   t   ncolsi   i    i   t   axg333333Óżg333333Ó?g      ŔgÉ?t   r(   t   printt   __doc__R   t   workdpsR   t   formatt   npt   linspacet   meshgridt   flattenR   t   complexR   t   arrayt   reshapet   shapet   pltt   subplotst   floatt   polyvalt   abst
   pcolormesht   logt   sqrtt   expt   colorbart   ravelt   tolistt   showt   plot(   R   R   t   xt   yt   zt   lambertw_stdt   z0t   figt   axest   p0t   q0t   pade_approxt   pade_errt
   asy_approxt   asy_errt   series_approxt
   series_errt   imR   t   pade_bettert   t(    (    sA   lib/python2.7/site-packages/scipy/special/_precompute/lambertw.pyt   main   sF    
'+ (("%$
!t   __main__(   R   t
   __future__R    R   R   t   numpyR   R   t   matplotlib.pyplott   pyplotR   t   ImportErrorR   R>   t   __name__(    (    (    sA   lib/python2.7/site-packages/scipy/special/_precompute/lambertw.pyt   <module>   s   		.