ó
+»Ã[c           @   s®   d  d l  Z  d  d l Td  d l m Z m Z m Z m Z m Z m Z m	 Z	 m
 Z
 m Z m Z m Z d „  Z d „  Z d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d S(   iÿÿÿÿN(   t   *(   t   Secantt   Mullert	   Bisectiont   Illinoist   Pegasust   Andersont   Riddert   ANewtont   Newtont   MNewtont   MDNewtonc          C   sO  d t  _ t d „  t d ƒ ƒ j d ƒ s0 t ‚ t t t d ƒ ƒ j t ƒ sT t ‚ t t t d ƒ t d ƒ f ƒ j t ƒ s„ t ‚ t d „  t d ƒ ƒ j d
 ƒ s« t ‚ d „  }  xP t	 t
 t t t g D]9 } t |  d d | ƒ} t |  | ƒ ƒ t k  sÊ t ‚ qÊ WxV t
 t t t t t t g D]9 } t |  d d | ƒ} t |  | ƒ ƒ t k  s#t ‚ q#Wd „  }  t t j |  d d d ƒt ƒ st ‚ t t j |  d d d ƒt ƒ s·t ‚ t j t ƒ 7 t d ƒ $ t d „  t d d d d ƒ ƒ Wd  QXWd  QXt j t ƒ  t d „  d ƒ Wd  QXt j t ƒ  t d „  d ƒ Wd  QXd  S(    Ni   c         S   s   d |  d S(   Ni   i   (    (   t   x(    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyt   <lambda>	   s    i   g      è?i   g…ëQ¸	@c         S   s   |  |  d S(   Ni   (    (   R   (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyR      s    i   y               @y              ð?c         S   s
   t  |  ƒ S(   N(   t   cos(   R   (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyR      s    g       @t   solverg      ð?c         S   s   |  d d S(   Ni   (    (   R   (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyR      s    i   t   tolg»½×Ùß|Û=y                c         S   s   |  d d |  d S(   Ni   iòþC IÊ£è6  (    (   R   (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyR   #   s    t   reals	   5.278e+13t   imags
   -5.278e+13c         S   s   d S(   Niÿÿÿÿ(    (   R   (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyR   (   s    i    c         S   s   d |  d d S(   Ni   i   (    (   t   p(    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyR   ,   s    gÍÌÌÌÌÌì?y       @       @(   g      ð?g       @y      ð?        (   t   mpt   dpst   findroott   mpft   aet   AssertionErrort   sint   pit   mpcR	   R   R
   R   R   t   abst   epsR   R   R   R   R   t
   isinstancet   fpt   floatt   complext   pytestt   raisest
   ValueErrort   workprec(   t   fR   R   (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyt   test_findroot   s0    	'$0'	""	''	"c           C   s(   t  d „  d d d ƒd k s$ t ‚ d  S(   Nc         S   s   |  d d S(   Ni   i   (    (   R   (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyR   0   s    i    i   R   t   bisecti   (   i    i   (   R   R   (    (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyt   test_bisection.   s    c          C   s@   d „  }  t  |  d d d ƒ} t |  | ƒ ƒ t k  s< t ‚ d  S(   Nc         S   s   t  d d d d g |  ƒ S(   Ni   i   (   t   polyval(   R   (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyR   3   s    gÍÌÌÌÌÌì¿R   t   mnewton(   R   R   R   R   (   R'   R   (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyt   test_mnewton2   s    	c          C   s@   d „  }  t  |  d d t ƒ} t |  | ƒ ƒ t k  s< t ‚ d  S(   Nc         S   s   |  d d S(   Ni   id   (    (   R   (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyR   8   s    g      ð?R   (   R   R   R   R   R   (   R'   R   (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyt   test_anewton7   s    	c          C   s@   d „  }  t  |  d d t ƒ} t |  | ƒ ƒ t k  s< t ‚ d  S(   Nc         S   s   d |  d d S(   Ni   i   (    (   R   (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyR   =   s    g      ð?R   (   R   R   R   R   R   (   R'   R   (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyt   test_muller<   s    	c              s`   x; t  d d ƒ D]* ‰  t ‡  f d †  d ƒ ˆ  k s t ‚ q Wt d „  d ƒ d k s\ t ‚ d  S(   Ni   i   c            s   |  d ˆ  S(   Ni   (    (   R   (   t   i(    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyR   C   s    c         S   s   |  d S(   Ni   (    (   R   (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyR   D   s    i    (   t   ranget   multiplicityR   (    (    (   R0   s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyt   test_multiplicityA   s    (c             s  d „  }  t  t |  d ƒ t d d g d d g g ƒ d ƒ d k  sI t ‚ x/ t t |  d d d d	 d
 „  ƒD] \ } } qk Wt |  | Œ  d ƒ d k  sœ t ‚ d „  ‰  d „  ‰ d „  ‰ ‡  ‡ ‡ f d †  }  t |  d ƒ } g  | D] } t t	 | ƒ ƒ ^ qâ d d g k st ‚ d  S(   Nc          W   sZ   d |  d d d |  d d d |  d d d |  d |  d d d |  d d g S(   Ni   i    i   i   i   (    (   R   (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyR'   G   s    i   iþÿÿÿi   i   i    gH¯¼šò×z>t   verboset   normc         S   s   t  |  t ƒ S(   N(   R5   t   inf(   R   (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyR   K   s    i   g›+¡†›„=c         S   s   |  d | S(   Ni   (    (   R   t   y(    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyR   P   s    c         S   s(   |  d |  | d d d | |  d S(   Ni   i   (    (   R   R7   (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyR   Q   s    c         S   s   t  |  d | d ƒ S(   Ni   (   t   sqrt(   R   R7   (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyR   R   s    c            s3   ˆ  |  | ƒ } ˆ |  | ƒ | ˆ |  | ƒ | f S(   N(    (   R   R7   t   f1x(   t   f1t   f2t   f3(    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyR'   S   s    i
   i   i   (   i   iþÿÿÿ(   i   iþÿÿÿ(   i
   i
   (
   t   mnormt   jacobiant   matrixR   R   R   R5   R   t   intt   round(   R'   R   t   errorR0   (    (   R:   R;   R<   s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyt   test_multidimensionalF   s    	@!			c           C   s@   t  d „  d ƒ d k s t ‚ t  d „  d ƒ d k s< t ‚ d  S(   Nc         S   s   d S(   Ni    (    (   R   (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyR   Z   s    i   c         S   s   |  S(   N(    (   R   (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyR   [   s    i    (   R   R   (    (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyt   test_trivialY   s    (   R#   t   mpmatht   mpmath.calculus.optimizationR   R   R   R   R   R   R   R   R	   R
   R   R(   R*   R-   R.   R/   R3   RC   RD   (    (    (    s<   lib/python2.7/site-packages/mpmath/tests/test_rootfinding.pyt   <module>   s   
L	(						