ó
¡¼™\c           @  sÿ  d  Z  d d l m Z m Z d d l m Z m Z m Z m Z m	 Z	 m
 Z
 d d l m Z d d l m Z m Z d d l m Z d d l m Z d d l m Z d d	 l m Z m Z d d
 l m Z m Z d d l m Z d d l m Z m  Z  d d l! m" Z" m# Z# m$ Z$ d d l% m& Z& m' Z' d e f d „  ƒ  YZ( d e f d „  ƒ  YZ) d e f d „  ƒ  YZ* d e f d „  ƒ  YZ+ d e f d „  ƒ  YZ, d e f d „  ƒ  YZ- d e f d „  ƒ  YZ. d e f d „  ƒ  YZ/ d e f d  „  ƒ  YZ0 d! „  Z1 d" e f d# „  ƒ  YZ2 d$ e f d% „  ƒ  YZ3 d& e f d' „  ƒ  YZ4 d( e4 f d) „  ƒ  YZ5 d* e4 f d+ „  ƒ  YZ6 d, e4 f d- „  ƒ  YZ7 d. e4 f d/ „  ƒ  YZ8 d0 e f d1 „  ƒ  YZ9 d2 e9 f d3 „  ƒ  YZ: d4 e9 f d5 „  ƒ  YZ; d6 e f d7 „  ƒ  YZ< d8 e f d9 „  ƒ  YZ= d: S(;   s    This module contains various functions that are special cases
    of incomplete gamma functions. It should probably be renamed. iÿÿÿÿ(   t   print_functiont   division(   t   Addt   St   sympifyt   cacheitt   pit   I(   t   range(   t   Functiont   ArgumentIndexError(   t   Symbol(   t	   factorial(   t   floor(   t   sqrtt   root(   t   expt   log(   t
   polar_lift(   t   cosht   sinh(   t   cost   sint   sinc(   t   hypert   meijergt   erfc           B  sÈ   e  Z d  Z e Z d d „ Z d d „ Z e d „  ƒ Z e	 e
 d „  ƒ ƒ Z d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d „ Z RS(   s   
    The Gauss error function. This function is defined as:

    .. math ::
        \mathrm{erf}(x) = \frac{2}{\sqrt{\pi}} \int_0^x e^{-t^2} \mathrm{d}t.

    Examples
    ========

    >>> from sympy import I, oo, erf
    >>> from sympy.abc import z

    Several special values are known:

    >>> erf(0)
    0
    >>> erf(oo)
    1
    >>> erf(-oo)
    -1
    >>> erf(I*oo)
    oo*I
    >>> erf(-I*oo)
    -oo*I

    In general one can pull out factors of -1 and I from the argument:

    >>> erf(-z)
    -erf(z)

    The error function obeys the mirror symmetry:

    >>> from sympy import conjugate
    >>> conjugate(erf(z))
    erf(conjugate(z))

    Differentiation with respect to z is supported:

    >>> from sympy import diff
    >>> diff(erf(z), z)
    2*exp(-z**2)/sqrt(pi)

    We can numerically evaluate the error function to arbitrary precision
    on the whole complex plane:

    >>> erf(4).evalf(30)
    0.999999984582742099719981147840

    >>> erf(-4*I).evalf(30)
    -1296959.73071763923152794095062*I

    See Also
    ========

    erfc: Complementary error function.
    erfi: Imaginary error function.
    erf2: Two-argument error function.
    erfinv: Inverse error function.
    erfcinv: Inverse Complementary error function.
    erf2inv: Inverse two-argument error function.

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Error_function
    .. [2] http://dlmf.nist.gov/7
    .. [3] http://mathworld.wolfram.com/Erf.html
    .. [4] http://functions.wolfram.com/GammaBetaErf/Erf
    i   c         C  sF   | d k r3 d t  |  j d d ƒ t t j ƒ St |  | ƒ ‚ d  S(   Ni   i   i    (   R   t   argsR   R   t   PiR
   (   t   selft   argindex(    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   fdiffd   s    'c         C  s   t  S(   s7   
        Returns the inverse of this function.
        (   t   erfinv(   R   R   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   inversek   s    c         C  s  | j  rd | t j k r t j S| t j k r5 t j S| t j k rK t j S| t j k rd t j Sn  t | t	 ƒ r~ | j
 d St | t ƒ rŸ t j | j
 d St | t ƒ rÏ | j
 d t j k rÏ | j
 d S| j t j ƒ } | t j k sÿ | t j k r| S| j ƒ  r|  | ƒ Sd  S(   Ni    i   (   t	   is_NumberR   t   NaNt   Infinityt   Onet   NegativeInfinityt   NegativeOnet   Zerot
   isinstanceR    R   t   erfcinvt   erf2invt   extract_multiplicativelyt   ImaginaryUnitt   could_extract_minus_sign(   t   clst   argt   t(    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   evalq   s(    	
%c         G  s¯   |  d k  s |  d d k r# t  j St | ƒ } t |  d t  d ƒ ƒ } t | ƒ d k r| | d | d |  d |  | Sd d | | |  |  t | ƒ t t  j ƒ Sd  S(   Ni    i   i   iþÿÿÿiÿÿÿÿ(   R   R(   R   R   t   lenR   R   R   (   t   nt   xt   previous_termst   k(    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   taylor_term   s    !c         C  s   |  j  |  j d j ƒ  ƒ S(   Ni    (   t   funcR   t	   conjugate(   R   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _eval_conjugateœ   s    c         C  s   |  j  d j S(   Ni    (   R   t   is_real(   R   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _eval_is_realŸ   s    c         K  sJ   d d l  m } t | d ƒ | t j | t j | d ƒ t t j ƒ S(   Niÿÿÿÿ(   t
   uppergammai   (   t   sympyR>   R   R   R%   t   HalfR   (   R   t   zt   kwargsR>   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _eval_rewrite_as_uppergamma¢   s    c         K  sD   t  j t  j | t t ƒ } t  j t  j t | ƒ t t | ƒ S(   N(   R   R%   R-   R   R   t   fresnelcR   t   fresnels(   R   RA   RB   R0   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _eval_rewrite_as_fresnels¦   s    c         K  sD   t  j t  j | t t ƒ } t  j t  j t | ƒ t t | ƒ S(   N(   R   R%   R-   R   R   RD   R   RE   (   R   RA   RB   R0   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _eval_rewrite_as_fresnelcª   s    c         K  s8   | t  t ƒ t t j g g  d g t j g | d ƒ S(   Ni    i   (   R   R   R   R   R@   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _eval_rewrite_as_meijerg®   s    c         K  s7   d | t  t ƒ t t j g d t j g | d ƒ S(   Ni   i   (   R   R   R   R   R@   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _eval_rewrite_as_hyper±   s    c         K  s7   t  | d ƒ | | t t j | d ƒ t  t j ƒ S(   Ni   (   R   t   expintR   R@   R   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _eval_rewrite_as_expint´   s    c         K  s    t  j t | ƒ t | d ƒ S(   Ni   (   R   R%   t   _erfsR   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _eval_rewrite_as_tractable·   s    c         K  s   t  j t | ƒ S(   N(   R   R%   t   erfc(   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _eval_rewrite_as_erfcº   s    c         K  s   t  t t  | ƒ S(   N(   R   t   erfi(   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _eval_rewrite_as_erfi½   s    c         C  sp   d d l  m } |  j d j | ƒ } | | j k r_ | d | ƒ j | ƒ r_ d | t t ƒ S|  j | ƒ Sd  S(   Niÿÿÿÿ(   t   Orderi    i   i   (	   R?   RR   R   t   as_leading_termt   free_symbolst   containsR   R   R9   (   R   R5   RR   R0   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _eval_as_leading_termÀ   s
    'c         K  s:  |  j  d j rI | r9 t | d <|  j | |  t j f S|  t j f Sn  | rw |  j  d j | |  j ƒ  \ } } n |  j  d j ƒ  \ } } | d | d } t j |  j | | t	 | ƒ ƒ |  j | | t	 | ƒ ƒ } | d | t	 | ƒ |  j | | t	 | ƒ ƒ |  j | | t	 | ƒ ƒ } | | f S(   Ni    t   complexi   (
   R   R<   t   Falset   expandR   R(   t   as_real_imagR@   R9   R   (   R   t   deept   hintsR5   t   yt   sqt   ret   im(    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRZ   É   s    
(?/(   t   __name__t
   __module__t   __doc__t   Truet
   unbranchedR   R!   t   classmethodR2   t   staticmethodR   R8   R;   R=   RC   RF   RG   RH   RI   RK   RM   RO   RQ   RV   RZ   (    (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR      s(   E													RN   c           B  sÑ   e  Z d  Z e Z d d „ Z d d „ Z e d „  ƒ Z e	 e
 d „  ƒ ƒ Z d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d „ Z RS(   sú  
    Complementary Error Function. The function is defined as:

    .. math ::
        \mathrm{erfc}(x) = \frac{2}{\sqrt{\pi}} \int_x^\infty e^{-t^2} \mathrm{d}t

    Examples
    ========

    >>> from sympy import I, oo, erfc
    >>> from sympy.abc import z

    Several special values are known:

    >>> erfc(0)
    1
    >>> erfc(oo)
    0
    >>> erfc(-oo)
    2
    >>> erfc(I*oo)
    -oo*I
    >>> erfc(-I*oo)
    oo*I

    The error function obeys the mirror symmetry:

    >>> from sympy import conjugate
    >>> conjugate(erfc(z))
    erfc(conjugate(z))

    Differentiation with respect to z is supported:

    >>> from sympy import diff
    >>> diff(erfc(z), z)
    -2*exp(-z**2)/sqrt(pi)

    It also follows

    >>> erfc(-z)
    2 - erfc(z)

    We can numerically evaluate the complementary error function to arbitrary precision
    on the whole complex plane:

    >>> erfc(4).evalf(30)
    0.0000000154172579002800188521596734869

    >>> erfc(4*I).evalf(30)
    1.0 - 1296959.73071763923152794095062*I

    See Also
    ========

    erf: Gaussian error function.
    erfi: Imaginary error function.
    erf2: Two-argument error function.
    erfinv: Inverse error function.
    erfcinv: Inverse Complementary error function.
    erf2inv: Inverse two-argument error function.

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Error_function
    .. [2] http://dlmf.nist.gov/7
    .. [3] http://mathworld.wolfram.com/Erfc.html
    .. [4] http://functions.wolfram.com/GammaBetaErf/Erfc
    i   c         C  sF   | d k r3 d t  |  j d d ƒ t t j ƒ St |  | ƒ ‚ d  S(   Ni   iþÿÿÿi    i   (   R   R   R   R   R   R
   (   R   R   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR   %  s    'c         C  s   t  S(   s7   
        Returns the inverse of this function.
        (   R*   (   R   R   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR!   +  s    c         C  sã   | j  rN | t j k r t j S| t j k r5 t j S| t j k rN t j Sn  t | t ƒ ro t j | j d St | t	 ƒ r‰ | j d S| j
 t j ƒ } | t j k s¹ | t j k r¾ | S| j ƒ  rß t d ƒ |  | ƒ Sd  S(   Ni    i   (   R"   R   R#   R$   R(   R%   R)   R    R   R*   R,   R-   R&   R.   (   R/   R0   R1   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR2   1  s     	
c         G  sÂ   |  d k r t  j S|  d k  s/ |  d d k r6 t  j St | ƒ } t |  d t  d ƒ ƒ } t | ƒ d k r | d | d |  d |  | Sd d | | |  |  t | ƒ t t  j ƒ Sd  S(   Ni    i   i   iþÿÿÿiÿÿÿÿ(	   R   R%   R(   R   R   R3   R   R   R   (   R4   R5   R6   R7   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR8   J  s    !c         C  s   |  j  |  j d j ƒ  ƒ S(   Ni    (   R9   R   R:   (   R   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR;   Y  s    c         C  s   |  j  d j S(   Ni    (   R   R<   (   R   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR=   \  s    c         K  s   |  j  t ƒ j  d d t ƒS(   Nt	   tractableR[   (   t   rewriteR   Rd   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRM   _  s    c         K  s   t  j t | ƒ S(   N(   R   R%   R   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _eval_rewrite_as_erfb  s    c         K  s   t  j t t t | ƒ S(   N(   R   R%   R   RP   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRQ   e  s    c         K  sK   t  j t  j | t t ƒ } t  j t  j t  j t | ƒ t t | ƒ S(   N(   R   R%   R-   R   R   RD   R   RE   (   R   RA   RB   R0   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRF   h  s    c         K  sK   t  j t  j | t t ƒ } t  j t  j t  j t | ƒ t t | ƒ S(   N(   R   R%   R-   R   R   RD   R   RE   (   R   RA   RB   R0   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRG   l  s    c      	   K  s?   t  j | t t ƒ t t  j g g  d g t  j g | d ƒ S(   Ni    i   (   R   R%   R   R   R   R@   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRH   p  s    c         K  s>   t  j d | t t ƒ t t  j g d t  j g | d ƒ S(   Ni   i   (   R   R%   R   R   R   R@   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRI   s  s    c         K  sQ   d d l  m } t j t | d ƒ | t j | t j | d ƒ t t j ƒ S(   Niÿÿÿÿ(   R>   i   (   R?   R>   R   R%   R   R@   R   (   R   RA   RB   R>   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRC   v  s    c         K  s>   t  j t | d ƒ | | t t  j | d ƒ t t  j ƒ S(   Ni   (   R   R%   R   RJ   R@   R   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRK   z  s    c         K  s   |  j  t ƒ S(   N(   Ri   R   (   R   R\   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _eval_expand_func}  s    c         C  se   d d l  m } |  j d j | ƒ } | | j k rT | d | ƒ j | ƒ rT t j S|  j | ƒ Sd  S(   Niÿÿÿÿ(   RR   i    i   (	   R?   RR   R   RS   RT   RU   R   R%   R9   (   R   R5   RR   R0   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRV   €  s
    'c         K  s:  |  j  d j rI | r9 t | d <|  j | |  t j f S|  t j f Sn  | rw |  j  d j | |  j ƒ  \ } } n |  j  d j ƒ  \ } } | d | d } t j |  j | | t	 | ƒ ƒ |  j | | t	 | ƒ ƒ } | d | t	 | ƒ |  j | | t	 | ƒ ƒ |  j | | t	 | ƒ ƒ } | | f S(   Ni    RW   i   (
   R   R<   RX   RY   R   R(   RZ   R@   R9   R   (   R   R[   R\   R5   R]   R^   R_   R`   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRZ   ‰  s    
(?/(   Ra   Rb   Rc   Rd   Re   R   R!   Rf   R2   Rg   R   R8   R;   R=   RM   Rj   RQ   RF   RG   RH   RI   RC   RK   Rk   RV   RZ   (    (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRN   Ü   s*   E														RP   c           B  s¼   e  Z d  Z e Z d d „ Z e d „  ƒ Z e e	 d „  ƒ ƒ Z
 d „  Z d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d „ Z RS(   sÀ  
    Imaginary error function. The function erfi is defined as:

    .. math ::
        \mathrm{erfi}(x) = \frac{2}{\sqrt{\pi}} \int_0^x e^{t^2} \mathrm{d}t

    Examples
    ========

    >>> from sympy import I, oo, erfi
    >>> from sympy.abc import z

    Several special values are known:

    >>> erfi(0)
    0
    >>> erfi(oo)
    oo
    >>> erfi(-oo)
    -oo
    >>> erfi(I*oo)
    I
    >>> erfi(-I*oo)
    -I

    In general one can pull out factors of -1 and I from the argument:

    >>> erfi(-z)
    -erfi(z)

    >>> from sympy import conjugate
    >>> conjugate(erfi(z))
    erfi(conjugate(z))

    Differentiation with respect to z is supported:

    >>> from sympy import diff
    >>> diff(erfi(z), z)
    2*exp(z**2)/sqrt(pi)

    We can numerically evaluate the imaginary error function to arbitrary precision
    on the whole complex plane:

    >>> erfi(2).evalf(30)
    18.5648024145755525987042919132

    >>> erfi(-2*I).evalf(30)
    -0.995322265018952734162069256367*I

    See Also
    ========

    erf: Gaussian error function.
    erfc: Complementary error function.
    erf2: Two-argument error function.
    erfinv: Inverse error function.
    erfcinv: Inverse Complementary error function.
    erf2inv: Inverse two-argument error function.

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Error_function
    .. [2] http://mathworld.wolfram.com/Erfi.html
    .. [3] http://functions.wolfram.com/GammaBetaErf/Erfi
    i   c         C  sE   | d k r2 d t  |  j d d ƒ t t j ƒ St |  | ƒ ‚ d  S(   Ni   i   i    (   R   R   R   R   R   R
   (   R   R   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR   á  s    &c         C  s  | j  rN | t j k r t j S| t j k r5 t j S| t j k rN t j Sn  | j ƒ  rf |  | ƒ S| j t ƒ } | d  k	 r| t j k r” t St	 | t
 ƒ r² t | j d St	 | t ƒ r× t t j | j d St	 | t ƒ r| j d t j k rt | j d Sn  d  S(   Ni    i   (   R"   R   R#   R(   R$   R.   R,   R   t   NoneR)   R    R   R*   R%   R+   (   R/   RA   t   nz(    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR2   ç  s&    	
%c         G  s¦   |  d k  s |  d d k r# t  j St | ƒ } t |  d t  d ƒ ƒ } t | ƒ d k r{ | d | d |  d |  | Sd | |  |  t | ƒ t t  j ƒ Sd  S(   Ni    i   i   iþÿÿÿ(   R   R(   R   R   R3   R   R   R   (   R4   R5   R6   R7   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR8     s     c         C  s   |  j  |  j d j ƒ  ƒ S(   Ni    (   R9   R   R:   (   R   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR;     s    c         C  s   |  j  d j S(   Ni    (   R   R<   (   R   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR=     s    c         K  s   |  j  t ƒ j  d d t ƒS(   NRh   R[   (   Ri   R   Rd   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRM     s    c         K  s   t  t t  | ƒ S(   N(   R   R   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRj     s    c         K  s   t  t t  | ƒ t  S(   N(   R   RN   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRO     s    c         K  sD   t  j t  j | t t ƒ } t  j t  j t | ƒ t t | ƒ S(   N(   R   R%   R-   R   R   RD   R   RE   (   R   RA   RB   R0   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRF     s    c         K  sD   t  j t  j | t t ƒ } t  j t  j t | ƒ t t | ƒ S(   N(   R   R%   R-   R   R   RD   R   RE   (   R   RA   RB   R0   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRG   !  s    c         K  s9   | t  t ƒ t t j g g  d g t j g | d ƒ S(   Ni    i   (   R   R   R   R   R@   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRH   %  s    c         K  s6   d | t  t ƒ t t j g d t j g | d ƒ S(   Ni   i   (   R   R   R   R   R@   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRI   (  s    c         K  sL   d d l  m } t | d ƒ | | t j | d ƒ t t j ƒ t j S(   Niÿÿÿÿ(   R>   i   (   R?   R>   R   R   R@   R   R%   (   R   RA   RB   R>   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRC   +  s    c         K  s9   t  | d ƒ | | t t j | d ƒ t  t j ƒ S(   Ni   (   R   RJ   R   R@   R   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRK   /  s    c         K  s   |  j  t ƒ S(   N(   Ri   R   (   R   R\   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRk   2  s    c         K  s:  |  j  d j rI | r9 t | d <|  j | |  t j f S|  t j f Sn  | rw |  j  d j | |  j ƒ  \ } } n |  j  d j ƒ  \ } } | d | d } t j |  j | | t	 | ƒ ƒ |  j | | t	 | ƒ ƒ } | d | t	 | ƒ |  j | | t	 | ƒ ƒ |  j | | t	 | ƒ ƒ } | | f S(   Ni    RW   i   (
   R   R<   RX   RY   R   R(   RZ   R@   R9   R   (   R   R[   R\   R5   R]   R^   R_   R`   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRZ   5  s    
(?/(   Ra   Rb   Rc   Rd   Re   R   Rf   R2   Rg   R   R8   R;   R=   RM   Rj   RO   RF   RG   RH   RI   RC   RK   Rk   RZ   (    (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRP   ›  s&   B												t   erf2c           B  s’   e  Z d  Z d „  Z e d „  ƒ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z RS(   s  
    Two-argument error function. This function is defined as:

    .. math ::
        \mathrm{erf2}(x, y) = \frac{2}{\sqrt{\pi}} \int_x^y e^{-t^2} \mathrm{d}t

    Examples
    ========

    >>> from sympy import I, oo, erf2
    >>> from sympy.abc import x, y

    Several special values are known:

    >>> erf2(0, 0)
    0
    >>> erf2(x, x)
    0
    >>> erf2(x, oo)
    1 - erf(x)
    >>> erf2(x, -oo)
    -erf(x) - 1
    >>> erf2(oo, y)
    erf(y) - 1
    >>> erf2(-oo, y)
    erf(y) + 1

    In general one can pull out factors of -1:

    >>> erf2(-x, -y)
    -erf2(x, y)

    The error function obeys the mirror symmetry:

    >>> from sympy import conjugate
    >>> conjugate(erf2(x, y))
    erf2(conjugate(x), conjugate(y))

    Differentiation with respect to x, y is supported:

    >>> from sympy import diff
    >>> diff(erf2(x, y), x)
    -2*exp(-x**2)/sqrt(pi)
    >>> diff(erf2(x, y), y)
    2*exp(-y**2)/sqrt(pi)

    See Also
    ========

    erf: Gaussian error function.
    erfc: Complementary error function.
    erfi: Imaginary error function.
    erfinv: Inverse error function.
    erfcinv: Inverse Complementary error function.
    erf2inv: Inverse two-argument error function.

    References
    ==========

    .. [1] http://functions.wolfram.com/GammaBetaErf/Erf2/
    c         C  sz   |  j  \ } } | d k r; d t | d ƒ t t j ƒ S| d k rg d t | d ƒ t t j ƒ St |  | ƒ ‚ d  S(   Ni   iþÿÿÿi   (   R   R   R   R   R   R
   (   R   R   R5   R]   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR   ‡  s      c         C  s4  t  j } t  j } t  j } | t  j k s9 | t  j k r@ t  j S| | k rS t  j S| | k s› | | k s› | | k s› | | k s› | | k s› | | k r¯ t | ƒ t | ƒ St | t ƒ rÜ | j d | k rÜ | j d S| j	 ƒ  } | j	 ƒ  } | r| r|  | | ƒ S| s| r0t | ƒ t | ƒ Sd  S(   Ni    i   (
   R   R$   R&   R(   R#   R   R)   R+   R   R.   (   R/   R5   R]   R   t   Nt   Ot   sign_xt   sign_y(    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR2     s"    			H"c         C  s*   |  j  |  j d j ƒ  |  j d j ƒ  ƒ S(   Ni    i   (   R9   R   R:   (   R   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR;   §  s    c         C  s   |  j  d j o |  j  d j S(   Ni    i   (   R   R<   (   R   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR=   ª  s    c         K  s   t  | ƒ t  | ƒ S(   N(   R   (   R   R5   R]   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRj   ­  s    c         K  s   t  | ƒ t  | ƒ S(   N(   RN   (   R   R5   R]   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRO   °  s    c         K  s    t  t t  | ƒ t t  | ƒ S(   N(   R   RP   (   R   R5   R]   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRQ   ³  s    c         K  s&   t  | ƒ j t ƒ t  | ƒ j t ƒ S(   N(   R   Ri   RE   (   R   R5   R]   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRF   ¶  s    c         K  s&   t  | ƒ j t ƒ t  | ƒ j t ƒ S(   N(   R   Ri   RD   (   R   R5   R]   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRG   ¹  s    c         K  s&   t  | ƒ j t ƒ t  | ƒ j t ƒ S(   N(   R   Ri   R   (   R   R5   R]   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRH   ¼  s    c         K  s&   t  | ƒ j t ƒ t  | ƒ j t ƒ S(   N(   R   Ri   R   (   R   R5   R]   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRI   ¿  s    c         K  s„   d d l  m } t | d ƒ | t j | t j | d ƒ t t j ƒ t | d ƒ | t j | t j | d ƒ t t j ƒ S(   Niÿÿÿÿ(   R>   i   (   R?   R>   R   R   R%   R@   R   (   R   R5   R]   RB   R>   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRC   Â  s    9c         K  s&   t  | ƒ j t ƒ t  | ƒ j t ƒ S(   N(   R   Ri   RJ   (   R   R5   R]   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRK   Ç  s    c         K  s   |  j  t ƒ S(   N(   Ri   R   (   R   R\   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRk   Ê  s    (   Ra   Rb   Rc   R   Rf   R2   R;   R=   Rj   RO   RQ   RF   RG   RH   RI   RC   RK   Rk   (    (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRn   G  s   =													R    c           B  s>   e  Z d  Z d d „ Z d d „ Z e d „  ƒ Z d „  Z RS(   sU  
    Inverse Error Function. The erfinv function is defined as:

    .. math ::
        \mathrm{erf}(x) = y \quad \Rightarrow \quad \mathrm{erfinv}(y) = x

    Examples
    ========

    >>> from sympy import I, oo, erfinv
    >>> from sympy.abc import x

    Several special values are known:

    >>> erfinv(0)
    0
    >>> erfinv(1)
    oo

    Differentiation with respect to x is supported:

    >>> from sympy import diff
    >>> diff(erfinv(x), x)
    sqrt(pi)*exp(erfinv(x)**2)/2

    We can numerically evaluate the inverse error function to arbitrary precision
    on [-1, 1]:

    >>> erfinv(0.2).evalf(30)
    0.179143454621291692285822705344

    See Also
    ========

    erf: Gaussian error function.
    erfc: Complementary error function.
    erfi: Imaginary error function.
    erf2: Two-argument error function.
    erfcinv: Inverse Complementary error function.
    erf2inv: Inverse two-argument error function.

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Error_function#Inverse_functions
    .. [2] http://functions.wolfram.com/GammaBetaErf/InverseErf/
    i   c         C  sQ   | d k r> t  t j ƒ t |  j |  j d ƒ d ƒ t j St |  | ƒ ‚ d  S(   Ni   i    i   (   R   R   R   R   R9   R   R@   R
   (   R   R   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR      s    2c         C  s   t  S(   s7   
        Returns the inverse of this function.
        (   R   (   R   R   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR!     s    c         C  sÌ   | t  j k r t  j S| t  j k r, t  j S| t  j k rB t  j S| t  j k rX t  j St | t ƒ r‚ | j	 d j
 r‚ | j	 d S| j d ƒ } | d  k	 rÈ t | t ƒ rÈ | j	 d j
 rÈ | j	 d Sd  S(   Ni    iÿÿÿÿ(   R   R#   R'   R&   R(   R%   R$   R)   R   R   R<   R,   Rl   (   R/   RA   Rm   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR2     s    +c         K  s   t  d | ƒ S(   Ni   (   R*   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _eval_rewrite_as_erfcinv  s    (   Ra   Rb   Rc   R   R!   Rf   R2   Rs   (    (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR    Î  s
   /R*   c           B  s>   e  Z d  Z d d „ Z d d „ Z e d „  ƒ Z d „  Z RS(   s·  
    Inverse Complementary Error Function. The erfcinv function is defined as:

    .. math ::
        \mathrm{erfc}(x) = y \quad \Rightarrow \quad \mathrm{erfcinv}(y) = x

    Examples
    ========

    >>> from sympy import I, oo, erfcinv
    >>> from sympy.abc import x

    Several special values are known:

    >>> erfcinv(1)
    0
    >>> erfcinv(0)
    oo

    Differentiation with respect to x is supported:

    >>> from sympy import diff
    >>> diff(erfcinv(x), x)
    -sqrt(pi)*exp(erfcinv(x)**2)/2

    See Also
    ========

    erf: Gaussian error function.
    erfc: Complementary error function.
    erfi: Imaginary error function.
    erf2: Two-argument error function.
    erfinv: Inverse error function.
    erf2inv: Inverse two-argument error function.

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Error_function#Inverse_functions
    .. [2] http://functions.wolfram.com/GammaBetaErf/InverseErfc/
    i   c         C  sR   | d k r? t  t j ƒ t |  j |  j d ƒ d ƒ t j St |  | ƒ ‚ d  S(   Ni   i    i   (   R   R   R   R   R9   R   R@   R
   (   R   R   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR   O  s    3c         C  s   t  S(   s7   
        Returns the inverse of this function.
        (   RN   (   R   R   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR!   U  s    c         C  sY   | t  j k r t  j S| t  j k r, t  j S| t  j k rB t  j S| d k rU t  j Sd  S(   Ni   (   R   R#   R(   R$   R%   R&   (   R/   RA   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR2   [  s    c         K  s   t  d | ƒ S(   Ni   (   R    (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _eval_rewrite_as_erfinvf  s    (   Ra   Rb   Rc   R   R!   Rf   R2   Rt   (    (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR*   #  s
   )R+   c           B  s&   e  Z d  Z d „  Z e d „  ƒ Z RS(   s@  
    Two-argument Inverse error function. The erf2inv function is defined as:

    .. math ::
        \mathrm{erf2}(x, w) = y \quad \Rightarrow \quad \mathrm{erf2inv}(x, y) = w

    Examples
    ========

    >>> from sympy import I, oo, erf2inv, erfinv, erfcinv
    >>> from sympy.abc import x, y

    Several special values are known:

    >>> erf2inv(0, 0)
    0
    >>> erf2inv(1, 0)
    1
    >>> erf2inv(0, 1)
    oo
    >>> erf2inv(0, y)
    erfinv(y)
    >>> erf2inv(oo, y)
    erfcinv(-y)

    Differentiation with respect to x and y is supported:

    >>> from sympy import diff
    >>> diff(erf2inv(x, y), x)
    exp(-x**2 + erf2inv(x, y)**2)
    >>> diff(erf2inv(x, y), y)
    sqrt(pi)*exp(erf2inv(x, y)**2)/2

    See Also
    ========

    erf: Gaussian error function.
    erfc: Complementary error function.
    erfi: Imaginary error function.
    erf2: Two-argument error function.
    erfinv: Inverse error function.
    erfcinv: Inverse complementary error function.

    References
    ==========

    .. [1] http://functions.wolfram.com/GammaBetaErf/InverseErf2/
    c         C  sŠ   |  j  \ } } | d k r= t |  j | | ƒ d | d ƒ S| d k rw t t j ƒ t j t |  j | | ƒ d ƒ St |  | ƒ ‚ d  S(   Ni   i   (   R   R   R9   R   R   R   R@   R
   (   R   R   R5   R]   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR     s    ".c         C  s÷   | t  j k s | t  j k r% t  j S| t  j k rJ | t  j k rJ t  j S| t  j k ro | t  j k ro t  j S| t  j k r” | t  j k r” t  j S| t  j k r­ t | ƒ S| t  j k rÇ t | ƒ S| t  j k rÚ | S| t  j k ró t | ƒ Sd  S(   N(   R   R#   R(   R%   R$   R    R*   (   R/   R5   R]   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR2   ¦  s     
(   Ra   Rb   Rc   R   Rf   R2   (    (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR+   j  s   0		t   Eic           B  sz   e  Z d  Z e d „  ƒ Z d d „ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 e
 Z e
 Z e
 Z d	 „  Z d
 „  Z RS(   sí  
    The classical exponential integral.

    For use in SymPy, this function is defined as

    .. math:: \operatorname{Ei}(x) = \sum_{n=1}^\infty \frac{x^n}{n\, n!}
                                     + \log(x) + \gamma,

    where `\gamma` is the Euler-Mascheroni constant.

    If `x` is a polar number, this defines an analytic function on the
    Riemann surface of the logarithm. Otherwise this defines an analytic
    function in the cut plane `\mathbb{C} \setminus (-\infty, 0]`.

    **Background**

    The name *exponential integral* comes from the following statement:

    .. math:: \operatorname{Ei}(x) = \int_{-\infty}^x \frac{e^t}{t} \mathrm{d}t

    If the integral is interpreted as a Cauchy principal value, this statement
    holds for `x > 0` and `\operatorname{Ei}(x)` as defined above.

    Examples
    ========

    >>> from sympy import Ei, polar_lift, exp_polar, I, pi
    >>> from sympy.abc import x

    >>> Ei(-1)
    Ei(-1)

    This yields a real value:

    >>> Ei(-1).n(chop=True)
    -0.219383934395520

    On the other hand the analytic continuation is not real:

    >>> Ei(polar_lift(-1)).n(chop=True)
    -0.21938393439552 + 3.14159265358979*I

    The exponential integral has a logarithmic branch point at the origin:

    >>> Ei(x*exp_polar(2*I*pi))
    Ei(x) + 2*I*pi

    Differentiation is supported:

    >>> Ei(x).diff(x)
    exp(x)/x

    The exponential integral is related to many other special functions.
    For example:

    >>> from sympy import uppergamma, expint, Shi
    >>> Ei(x).rewrite(expint)
    -expint(1, x*exp_polar(I*pi)) - I*pi
    >>> Ei(x).rewrite(Shi)
    Chi(x) + Shi(x)

    See Also
    ========

    expint: Generalised exponential integral.
    E1: Special case of the generalised exponential integral.
    li: Logarithmic integral.
    Li: Offset logarithmic integral.
    Si: Sine integral.
    Ci: Cosine integral.
    Shi: Hyperbolic sine integral.
    Chi: Hyperbolic cosine integral.
    sympy.functions.special.gamma_functions.uppergamma: Upper incomplete gamma function.

    References
    ==========

    .. [1] http://dlmf.nist.gov/6.6
    .. [2] https://en.wikipedia.org/wiki/Exponential_integral
    .. [3] Abramowitz & Stegun, section 5: http://people.math.sfu.ca/~cbm/aands/page_228.htm

    c         C  sx   | t  j k r t  j S| t  j k r, t  j S| t  j k rB t  j S| j ƒ  \ } } | rt t | ƒ d t t | Sd  S(   Ni   (   R   R(   R&   R$   t   extract_branch_factorRu   R   R   (   R/   RA   Rm   R4   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR2     s    i   c         C  sP   d d l  m } | |  j d ƒ } | d k r= t | ƒ | St |  | ƒ ‚ d  S(   Niÿÿÿÿ(   t
   unpolarifyi    i   (   R?   Rw   R   R   R
   (   R   R   Rw   R0   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR      s
    c         C  sK   |  j  d t d ƒ j r; t j |  | ƒ t t j | ƒ St j |  | ƒ S(   Ni    iÿÿÿÿ(   R   R   t   is_positiveR	   t   _eval_evalfR   R   (   R   t   prec(    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRy   (  s    !c         K  s0   d d l  m } | d t d ƒ | ƒ t t S(   Niÿÿÿÿ(   R>   i    (   R?   R>   R   R   R   (   R   RA   RB   R>   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRC   -  s    c         K  s    t  d t d ƒ | ƒ t t S(   Ni   iÿÿÿÿ(   RJ   R   R   R   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRK   3  s    c         K  s0   t  | t ƒ r  t | j d ƒ St t | ƒ ƒ S(   Ni    (   R)   R   t   liR   R   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _eval_rewrite_as_li6  s    c         K  s   t  | ƒ t | ƒ S(   N(   t   Shit   Chi(   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _eval_rewrite_as_Si?  s    c         K  s   t  | ƒ t | ƒ S(   N(   R   t   _eis(   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRM   E  s    c         C  si   |  j  d j | d ƒ } | t j k rM |  j |  j  Œ  } | j | | | ƒ St t |  ƒ j | | | ƒ S(   Ni    (   R   t   limitR   R(   R   t   _eval_nseriest   superRu   (   R   R5   R4   t   logxt   x0t   f(    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR‚   H  s
    (   Ra   Rb   Rc   Rf   R2   R   Ry   RC   RK   R|   R   t   _eval_rewrite_as_Cit   _eval_rewrite_as_Chit   _eval_rewrite_as_ShiRM   R‚   (    (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRu   ¾  s   R							RJ   c           B  sn   e  Z d  Z e d „  ƒ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 e	 Z
 e	 Z e	 Z d „  Z d „  Z RS(	   s²  
    Generalized exponential integral.

    This function is defined as

    .. math:: \operatorname{E}_\nu(z) = z^{\nu - 1} \Gamma(1 - \nu, z),

    where `\Gamma(1 - \nu, z)` is the upper incomplete gamma function
    (``uppergamma``).

    Hence for :math:`z` with positive real part we have

    .. math:: \operatorname{E}_\nu(z)
              =   \int_1^\infty \frac{e^{-zt}}{z^\nu} \mathrm{d}t,

    which explains the name.

    The representation as an incomplete gamma function provides an analytic
    continuation for :math:`\operatorname{E}_\nu(z)`. If :math:`\nu` is a
    non-positive integer the exponential integral is thus an unbranched
    function of :math:`z`, otherwise there is a branch point at the origin.
    Refer to the incomplete gamma function documentation for details of the
    branching behavior.

    Examples
    ========

    >>> from sympy import expint, S
    >>> from sympy.abc import nu, z

    Differentiation is supported. Differentiation with respect to z explains
    further the name: for integral orders, the exponential integral is an
    iterated integral of the exponential function.

    >>> expint(nu, z).diff(z)
    -expint(nu - 1, z)

    Differentiation with respect to nu has no classical expression:

    >>> expint(nu, z).diff(nu)
    -z**(nu - 1)*meijerg(((), (1, 1)), ((0, 0, 1 - nu), ()), z)

    At non-postive integer orders, the exponential integral reduces to the
    exponential function:

    >>> expint(0, z)
    exp(-z)/z
    >>> expint(-1, z)
    exp(-z)/z + exp(-z)/z**2

    At half-integers it reduces to error functions:

    >>> expint(S(1)/2, z)
    sqrt(pi)*erfc(sqrt(z))/sqrt(z)

    At positive integer orders it can be rewritten in terms of exponentials
    and expint(1, z). Use expand_func() to do this:

    >>> from sympy import expand_func
    >>> expand_func(expint(5, z))
    z**4*expint(1, z)/24 + (-z**3 + z**2 - 2*z + 6)*exp(-z)/24

    The generalised exponential integral is essentially equivalent to the
    incomplete gamma function:

    >>> from sympy import uppergamma
    >>> expint(nu, z).rewrite(uppergamma)
    z**(nu - 1)*uppergamma(1 - nu, z)

    As such it is branched at the origin:

    >>> from sympy import exp_polar, pi, I
    >>> expint(4, z*exp_polar(2*pi*I))
    I*pi*z**3/3 + expint(4, z)
    >>> expint(nu, z*exp_polar(2*pi*I))
    z**(nu - 1)*(exp(2*I*pi*nu) - 1)*gamma(1 - nu) + expint(nu, z)

    See Also
    ========

    Ei: Another related function called exponential integral.
    E1: The classical case, returns expint(1, z).
    li: Logarithmic integral.
    Li: Offset logarithmic integral.
    Si: Sine integral.
    Ci: Cosine integral.
    Shi: Hyperbolic sine integral.
    Chi: Hyperbolic cosine integral.
    sympy.functions.special.gamma_functions.uppergamma

    References
    ==========

    .. [1] http://dlmf.nist.gov/8.19
    .. [2] http://functions.wolfram.com/GammaBetaErf/ExpIntegralE/
    .. [3] https://en.wikipedia.org/wiki/Exponential_integral

    c         C  su  d d l  m } m } m } m } m } m } | | ƒ }	 | |	 k rS t |	 | ƒ S| j rh | d k s | j r¨ d | j r¨ | | | | d | d | | ƒ ƒ ƒ S| j	 ƒ  \ } }
 |
 d k rÊ d  S| j
 r,| d k sã d  St | | ƒ d t t |
 d | d | | d ƒ | | ƒ | d S| d t t | |
 ƒ d | | d | d | ƒ t | | ƒ Sd  S(   Niÿÿÿÿ(   Rw   t
   expand_mulR>   R   t   gammaR   i    i   i   (   R?   Rw   RŠ   R>   R   R‹   R   RJ   t
   is_IntegerRv   t
   is_integerR   R   (   R/   t   nuRA   Rw   RŠ   R>   R   R‹   R   t   nu2R4   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR2   µ  s    .,)	=c         C  s’   d d l  m } |  j \ } } | d k ra | | d | g  d d g d d d | g g  | ƒ S| d k r t | d | ƒ St |  | ƒ ‚ d  S(   Niÿÿÿÿ(   R   i   i    i   (   R?   R   R   RJ   R
   (   R   R   R   RŽ   RA   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR   Ì  s    6c         K  s-   d d l  m } | | d | d | | ƒ S(   Niÿÿÿÿ(   R>   i   (   R?   R>   (   R   RŽ   RA   RB   R>   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRC   Ö  s    c   
      K  sü   d d l  m } m } m } m } | d k rP t | | t t ƒ ƒ t t S| j rô | d k rô | | ƒ } | | d | | d ƒ t	 | ƒ j
 t ƒ | | ƒ | | d ƒ t g  t | d ƒ D]" }	 | | |	 d ƒ | |	 ^ qÉ Œ  S|  Sd  S(   Niÿÿÿÿ(   t	   exp_polarRw   R   R   i   i   (   R?   R   Rw   R   R   Ru   R   R   RŒ   t   E1Ri   R   R   (
   R   RŽ   RA   RB   R   Rw   R   R   R5   R7   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _eval_rewrite_as_EiÚ  s    "",?c         K  s   |  j  t ƒ j  t |  S(   N(   Ri   Ru   RJ   (   R   R\   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRk   ç  s    c         K  s$   | d k r |  St  | ƒ t | ƒ S(   Ni   (   R}   R~   (   R   RŽ   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR   ê  s    c         C  s­   |  j  d j | ƒ s‘ |  j  d } | d k rT |  j |  j  Œ  } | j | | | ƒ S| j r‘ | d k r‘ |  j |  j  Œ  } | j | | | ƒ Sn  t t |  ƒ j | | | ƒ S(   Ni    i   (   R   t   hasR   R‚   RŒ   R’   Rƒ   RJ   (   R   R5   R4   R„   RŽ   R†   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR‚   ò  s    c         C  s9   d d  l  j } | j |  j d j ƒ  |  j d j ƒ  ƒ S(   Niÿÿÿÿi    i   (   t   sage.allt   allt   exp_integral_eR   t   _sage_(   R   t   sage(    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR—   ý  s    (   Ra   Rb   Rc   Rf   R2   R   RC   R’   Rk   R   R‡   Rˆ   R‰   R‚   R—   (    (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRJ   P  s   b	
					c         C  s   t  d |  ƒ S(   s‘  
    Classical case of the generalized exponential integral.

    This is equivalent to ``expint(1, z)``.

    See Also
    ========

    Ei: Exponential integral.
    expint: Generalised exponential integral.
    li: Logarithmic integral.
    Li: Offset logarithmic integral.
    Si: Sine integral.
    Ci: Cosine integral.
    Shi: Hyperbolic sine integral.
    Chi: Hyperbolic cosine integral.
    i   (   RJ   (   RA   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR‘     s    R{   c           B  s†   e  Z d  Z e d „  ƒ Z d d „ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 e
 Z d	 „  Z e Z d
 „  Z d „  Z d „  Z RS(   s	  
    The classical logarithmic integral.

    For the use in SymPy, this function is defined as

    .. math:: \operatorname{li}(x) = \int_0^x \frac{1}{\log(t)} \mathrm{d}t \,.

    Examples
    ========

    >>> from sympy import I, oo, li
    >>> from sympy.abc import z

    Several special values are known:

    >>> li(0)
    0
    >>> li(1)
    -oo
    >>> li(oo)
    oo

    Differentiation with respect to z is supported:

    >>> from sympy import diff
    >>> diff(li(z), z)
    1/log(z)

    Defining the `li` function via an integral:


    The logarithmic integral can also be defined in terms of Ei:

    >>> from sympy import Ei
    >>> li(z).rewrite(Ei)
    Ei(log(z))
    >>> diff(li(z).rewrite(Ei), z)
    1/log(z)

    We can numerically evaluate the logarithmic integral to arbitrary precision
    on the whole complex plane (except the singular points):

    >>> li(2).evalf(30)
    1.04516378011749278484458888919

    >>> li(2*I).evalf(30)
    1.0652795784357498247001125598 + 3.08346052231061726610939702133*I

    We can even compute Soldner's constant by the help of mpmath:

    >>> from mpmath import findroot
    >>> findroot(li, 2)
    1.45136923488338

    Further transformations include rewriting `li` in terms of
    the trigonometric integrals `Si`, `Ci`, `Shi` and `Chi`:

    >>> from sympy import Si, Ci, Shi, Chi
    >>> li(z).rewrite(Si)
    -log(I*log(z)) - log(1/log(z))/2 + log(log(z))/2 + Ci(I*log(z)) + Shi(log(z))
    >>> li(z).rewrite(Ci)
    -log(I*log(z)) - log(1/log(z))/2 + log(log(z))/2 + Ci(I*log(z)) + Shi(log(z))
    >>> li(z).rewrite(Shi)
    -log(1/log(z))/2 + log(log(z))/2 + Chi(log(z)) - Shi(log(z))
    >>> li(z).rewrite(Chi)
    -log(1/log(z))/2 + log(log(z))/2 + Chi(log(z)) - Shi(log(z))

    See Also
    ========

    Li: Offset logarithmic integral.
    Ei: Exponential integral.
    expint: Generalised exponential integral.
    E1: Special case of the generalised exponential integral.
    Si: Sine integral.
    Ci: Cosine integral.
    Shi: Hyperbolic sine integral.
    Chi: Hyperbolic cosine integral.

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Logarithmic_integral
    .. [2] http://mathworld.wolfram.com/LogarithmicIntegral.html
    .. [3] http://dlmf.nist.gov/6
    .. [4] http://mathworld.wolfram.com/SoldnersConstant.html
    c         C  sF   | t  j k r t  j S| t  j k r, t  j S| t  j k rB t  j Sd  S(   N(   R   R(   R%   R&   R$   (   R/   RA   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR2   q  s    i   c         C  s=   |  j  d } | d k r* t j t | ƒ St |  | ƒ ‚ d  S(   Ni    i   (   R   R   R%   R   R
   (   R   R   R0   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR   z  s    c         C  s6   |  j  d } | j o | j s2 |  j | j ƒ  ƒ Sd  S(   Ni    (   R   R<   t   is_negativeR9   R:   (   R   RA   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR;     s    c         K  s   t  | ƒ t d ƒ S(   Ni   (   t   LiR{   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _eval_rewrite_as_Li‡  s    c         K  s   t  t | ƒ ƒ S(   N(   Ru   R   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR’   Š  s    c         K  sd   d d l  m } | d t | ƒ ƒ t j t t | ƒ ƒ t t j t | ƒ ƒ t t | ƒ ƒ S(   Niÿÿÿÿ(   R>   i    (   R?   R>   R   R   R@   R%   (   R   RA   RB   R>   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRC     s    c         K  sn   t  t t | ƒ ƒ t t t t | ƒ ƒ t j t t j t | ƒ ƒ t t | ƒ ƒ t t t | ƒ ƒ S(   N(   t   CiR   R   t   SiR   R@   R%   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR   ’  s    c         K  sN   t  t | ƒ ƒ t t | ƒ ƒ t j t t j t | ƒ ƒ t t | ƒ ƒ S(   N(   R~   R   R}   R   R@   R%   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR‰   ˜  s    c         K  sU   t  | ƒ t d d t  | ƒ ƒ t j t  t  | ƒ ƒ t  t j t  | ƒ ƒ t j S(   Ni   i   (   i   i   (   i   i   (   R   R   R   R@   R%   t
   EulerGamma(   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRI     s    c         K  sc   t  t  | ƒ ƒ t j t  t j t  | ƒ ƒ t  t  | ƒ ƒ t d d f d d f t  | ƒ ƒ S(   Ni   i    (    (   i   (   i    i    (    (   R   R   R@   R%   R   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRH   ¡  s    c         K  s   | t  t | ƒ ƒ S(   N(   R€   R   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRM   ¥  s    (   Ra   Rb   Rc   Rf   R2   R   R;   R›   R’   RC   R   R‡   R‰   Rˆ   RI   RH   RM   (    (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR{     s   W									Rš   c           B  sD   e  Z d  Z e d „  ƒ Z d d „ Z d „  Z d „  Z d „  Z RS(   sG  
    The offset logarithmic integral.

    For the use in SymPy, this function is defined as

    .. math:: \operatorname{Li}(x) = \operatorname{li}(x) - \operatorname{li}(2)

    Examples
    ========

    >>> from sympy import I, oo, Li
    >>> from sympy.abc import z

    The following special value is known:

    >>> Li(2)
    0

    Differentiation with respect to z is supported:

    >>> from sympy import diff
    >>> diff(Li(z), z)
    1/log(z)

    The shifted logarithmic integral can be written in terms of `li(z)`:

    >>> from sympy import li
    >>> Li(z).rewrite(li)
    li(z) - li(2)

    We can numerically evaluate the logarithmic integral to arbitrary precision
    on the whole complex plane (except the singular points):

    >>> Li(2).evalf(30)
    0

    >>> Li(4).evalf(30)
    1.92242131492155809316615998938

    See Also
    ========

    li: Logarithmic integral.
    Ei: Exponential integral.
    expint: Generalised exponential integral.
    E1: Special case of the generalised exponential integral.
    Si: Sine integral.
    Ci: Cosine integral.
    Shi: Hyperbolic sine integral.
    Chi: Hyperbolic cosine integral.

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Logarithmic_integral
    .. [2] http://mathworld.wolfram.com/LogarithmicIntegral.html
    .. [3] http://dlmf.nist.gov/6
    c         C  s4   | t  j k r t  j S| d t  j k r0 t  j Sd  S(   Ni   (   R   R$   R%   R(   (   R/   RA   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR2   æ  s    i   c         C  s=   |  j  d } | d k r* t j t | ƒ St |  | ƒ ‚ d  S(   Ni    i   (   R   R   R%   R   R
   (   R   R   R0   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR   í  s    c         C  s   |  j  t ƒ j | ƒ S(   N(   Ri   R{   t   evalf(   R   Rz   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRy   ô  s    c         K  s   t  | ƒ t  d ƒ S(   Ni   (   R{   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR|   ÷  s    c         K  s   |  j  t ƒ j  d d t ƒS(   NRh   R[   (   Ri   R{   Rd   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRM   ú  s    (	   Ra   Rb   Rc   Rf   R2   R   Ry   R|   RM   (    (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRš   ©  s   :		t   TrigonometricIntegralc           B  sD   e  Z d  Z e d „  ƒ Z d d „ Z d „  Z d „  Z d „  Z RS(   s)    Base class for trigonometric integrals. c         C  s‘  | d k r |  j  S| t j k r, |  j ƒ  S| t j k rE |  j ƒ  S| j t t ƒ ƒ } | d  k r |  j
 d ƒ d k r | j t ƒ } n  | d  k	 r© |  j | d ƒ S| j t t ƒ ƒ } | d  k	 rÛ |  j | d ƒ S| j t d ƒ ƒ } | d  k r#|  j
 d ƒ d k r#| j d ƒ } n  | d  k	 r<|  j | ƒ S| j ƒ  \ } } | d k rj| | k rjd  Sd t t | |  j
 d ƒ |  | ƒ S(   Ni    i   iÿÿÿÿi   (   t   _atzeroR   R$   t   _atinfR&   t	   _atneginfR,   R   R   Rl   t	   _trigfunct   _Ifactort   _minusfactorRv   R   (   R/   RA   Rm   R4   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR2     s.    

!!i   c         C  sD   d d l  m } | |  j d ƒ } | d k r@ |  j | ƒ | Sd  S(   Niÿÿÿÿ(   Rw   i    i   (   R?   Rw   R   R¤   (   R   R   Rw   R0   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR   "  s    c         K  s   |  j  | ƒ j t ƒ S(   N(   RK   Ri   Ru   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR’   (  s    c         K  s&   d d l  m } |  j | ƒ j | ƒ S(   Niÿÿÿÿ(   R>   (   R?   R>   RK   Ri   (   R   RA   RB   R>   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRC   +  s    c         C  s  d d l  m } m } m } | d 7} |  j d j | d ƒ d k ra t t |  ƒ j | | | ƒ S|  j	 | ƒ j | | | ƒ } |  j	 d ƒ d k r¡ | d 8} n  | j
 | d „  d t ƒ} |  j	 d ƒ d k rè | | | | ƒ 7} n  | j | |  j d ƒ j | | | ƒ S(   Niÿÿÿÿ(   R   Rž   t   Powi   i    c         S  s   |  | | S(   N(    (   R1   R4   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   <lambda>8  t    t   simultaneous(   R?   R   Rž   R§   R   t   subsRƒ   R    R‚   R¤   t   replaceRX   (   R   R5   R4   R„   R   Rž   R§   t
   baseseries(    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR‚   /  s    
(	   Ra   Rb   Rc   Rf   R2   R   R’   RC   R‚   (    (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR      s   		R   c           B  sw   e  Z d  Z e Z e d ƒ Z e d „  ƒ Z e d „  ƒ Z	 e d „  ƒ Z
 e d „  ƒ Z d „  Z d „  Z d „  Z RS(	   sÒ  
    Sine integral.

    This function is defined by

    .. math:: \operatorname{Si}(z) = \int_0^z \frac{\sin{t}}{t} \mathrm{d}t.

    It is an entire function.

    Examples
    ========

    >>> from sympy import Si
    >>> from sympy.abc import z

    The sine integral is an antiderivative of sin(z)/z:

    >>> Si(z).diff(z)
    sin(z)/z

    It is unbranched:

    >>> from sympy import exp_polar, I, pi
    >>> Si(z*exp_polar(2*I*pi))
    Si(z)

    Sine integral behaves much like ordinary sine under multiplication by ``I``:

    >>> Si(I*z)
    I*Shi(z)
    >>> Si(-z)
    -Si(z)

    It can also be expressed in terms of exponential integrals, but beware
    that the latter is branched:

    >>> from sympy import expint
    >>> Si(z).rewrite(expint)
    -I*(-expint(1, z*exp_polar(-I*pi/2))/2 +
         expint(1, z*exp_polar(I*pi/2))/2) + pi/2

    It can be rewritten in the form of sinc function (By definition)

    >>> from sympy import sinc
    >>> Si(z).rewrite(sinc)
    Integral(sinc(t), (t, 0, z))

    See Also
    ========

    Ci: Cosine integral.
    Shi: Hyperbolic sine integral.
    Chi: Hyperbolic cosine integral.
    Ei: Exponential integral.
    expint: Generalised exponential integral.
    sinc: unnormalized sinc function
    E1: Special case of the generalised exponential integral.
    li: Logarithmic integral.
    Li: Offset logarithmic integral.

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Trigonometric_integral

    i    c         C  s   t  t j S(   N(   R   R   R@   (   R/   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR¢   …  s    c         C  s   t  t j S(   N(   R   R   R@   (   R/   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR£   ‰  s    c         C  s   t  | ƒ S(   N(   R   (   R/   RA   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR¦     s    c         C  s   t  t | ƒ | S(   N(   R   R}   (   R/   RA   t   sign(    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR¥   ‘  s    c         K  s9   t  d t t t ƒ | ƒ t t t ƒ | ƒ d t S(   Ni   (   R   R‘   R   R   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRK   •  s    c         K  s>   d d l  m } t d d t ƒ} | t | ƒ | d | f ƒ S(   Niÿÿÿÿ(   t   IntegralR1   t   Dummyi    (   R?   R¯   R   Rd   R   (   R   RA   RB   R¯   R1   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _eval_rewrite_as_sinc™  s    c         C  s)   d d  l  j } | j |  j d j ƒ  ƒ S(   Niÿÿÿÿi    (   R”   R•   t   sin_integralR   R—   (   R   R˜   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR—   ž  s    (   Ra   Rb   Rc   R   R¤   R   R¡   Rf   R¢   R£   R¦   R¥   RK   R±   R—   (    (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR   >  s   B		Rœ   c           B  sk   e  Z d  Z e Z e j Z e d „  ƒ Z	 e d „  ƒ Z
 e d „  ƒ Z e d „  ƒ Z d „  Z d „  Z RS(   s¼  
    Cosine integral.

    This function is defined for positive `x` by

    .. math:: \operatorname{Ci}(x) = \gamma + \log{x}
                         + \int_0^x \frac{\cos{t} - 1}{t} \mathrm{d}t
           = -\int_x^\infty \frac{\cos{t}}{t} \mathrm{d}t,

    where `\gamma` is the Euler-Mascheroni constant.

    We have

    .. math:: \operatorname{Ci}(z) =
        -\frac{\operatorname{E}_1\left(e^{i\pi/2} z\right)
               + \operatorname{E}_1\left(e^{-i \pi/2} z\right)}{2}

    which holds for all polar `z` and thus provides an analytic
    continuation to the Riemann surface of the logarithm.

    The formula also holds as stated
    for `z \in \mathbb{C}` with `\Re(z) > 0`.
    By lifting to the principal branch we obtain an analytic function on the
    cut complex plane.

    Examples
    ========

    >>> from sympy import Ci
    >>> from sympy.abc import z

    The cosine integral is a primitive of `\cos(z)/z`:

    >>> Ci(z).diff(z)
    cos(z)/z

    It has a logarithmic branch point at the origin:

    >>> from sympy import exp_polar, I, pi
    >>> Ci(z*exp_polar(2*I*pi))
    Ci(z) + 2*I*pi

    The cosine integral behaves somewhat like ordinary `\cos` under multiplication by `i`:

    >>> from sympy import polar_lift
    >>> Ci(polar_lift(I)*z)
    Chi(z) + I*pi/2
    >>> Ci(polar_lift(-1)*z)
    Ci(z) + I*pi

    It can also be expressed in terms of exponential integrals:

    >>> from sympy import expint
    >>> Ci(z).rewrite(expint)
    -expint(1, z*exp_polar(-I*pi/2))/2 - expint(1, z*exp_polar(I*pi/2))/2

    See Also
    ========

    Si: Sine integral.
    Shi: Hyperbolic sine integral.
    Chi: Hyperbolic cosine integral.
    Ei: Exponential integral.
    expint: Generalised exponential integral.
    E1: Special case of the generalised exponential integral.
    li: Logarithmic integral.
    Li: Offset logarithmic integral.

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Trigonometric_integral

    c         C  s   t  j S(   N(   R   R(   (   R/   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR¢   ñ  s    c         C  s   t  t S(   N(   R   R   (   R/   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR£   õ  s    c         C  s   t  | ƒ t t S(   N(   Rœ   R   R   (   R/   RA   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR¦   ù  s    c         C  s   t  | ƒ t t d | S(   Ni   (   R~   R   R   (   R/   RA   R®   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR¥   ý  s    c         K  s.   t  t t ƒ | ƒ t  t t ƒ | ƒ d S(   Ni   (   R‘   R   R   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRK     s    c         C  s)   d d  l  j } | j |  j d j ƒ  ƒ S(   Niÿÿÿÿi    (   R”   R•   t   cos_integralR   R—   (   R   R˜   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR—     s    (   Ra   Rb   Rc   R   R¤   R   t   ComplexInfinityR¡   Rf   R¢   R£   R¦   R¥   RK   R—   (    (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRœ   ¢  s   J		R}   c           B  sn   e  Z d  Z e Z e d ƒ Z e d „  ƒ Z e d „  ƒ Z	 e d „  ƒ Z
 e d „  ƒ Z d „  Z d „  Z RS(   sì  
    Sinh integral.

    This function is defined by

    .. math:: \operatorname{Shi}(z) = \int_0^z \frac{\sinh{t}}{t} \mathrm{d}t.

    It is an entire function.

    Examples
    ========

    >>> from sympy import Shi
    >>> from sympy.abc import z

    The Sinh integral is a primitive of `\sinh(z)/z`:

    >>> Shi(z).diff(z)
    sinh(z)/z

    It is unbranched:

    >>> from sympy import exp_polar, I, pi
    >>> Shi(z*exp_polar(2*I*pi))
    Shi(z)

    The `\sinh` integral behaves much like ordinary `\sinh` under multiplication by `i`:

    >>> Shi(I*z)
    I*Si(z)
    >>> Shi(-z)
    -Shi(z)

    It can also be expressed in terms of exponential integrals, but beware
    that the latter is branched:

    >>> from sympy import expint
    >>> Shi(z).rewrite(expint)
    expint(1, z)/2 - expint(1, z*exp_polar(I*pi))/2 - I*pi/2

    See Also
    ========

    Si: Sine integral.
    Ci: Cosine integral.
    Chi: Hyperbolic cosine integral.
    Ei: Exponential integral.
    expint: Generalised exponential integral.
    E1: Special case of the generalised exponential integral.
    li: Logarithmic integral.
    Li: Offset logarithmic integral.

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Trigonometric_integral

    i    c         C  s   t  j S(   N(   R   R$   (   R/   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR¢   H  s    c         C  s   t  j S(   N(   R   R&   (   R/   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR£   L  s    c         C  s   t  | ƒ S(   N(   R}   (   R/   RA   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR¦   P  s    c         C  s   t  t | ƒ | S(   N(   R   R   (   R/   RA   R®   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR¥   T  s    c         K  sB   d d l  m } t | ƒ t | t t ƒ | ƒ d t t d S(   Niÿÿÿÿ(   R   i   (   R?   R   R‘   R   R   (   R   RA   RB   R   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRK   X  s    c         C  s)   d d  l  j } | j |  j d j ƒ  ƒ S(   Niÿÿÿÿi    (   R”   R•   t   sinh_integralR   R—   (   R   R˜   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR—   ]  s    (   Ra   Rb   Rc   R   R¤   R   R¡   Rf   R¢   R£   R¦   R¥   RK   R—   (    (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR}   	  s   :	R~   c           B  sk   e  Z d  Z e Z e j Z e d „  ƒ Z	 e d „  ƒ Z
 e d „  ƒ Z e d „  ƒ Z d „  Z d „  Z RS(   s  
    Cosh integral.

    This function is defined for positive :math:`x` by

    .. math:: \operatorname{Chi}(x) = \gamma + \log{x}
                         + \int_0^x \frac{\cosh{t} - 1}{t} \mathrm{d}t,

    where :math:`\gamma` is the Euler-Mascheroni constant.

    We have

    .. math:: \operatorname{Chi}(z) = \operatorname{Ci}\left(e^{i \pi/2}z\right)
                         - i\frac{\pi}{2},

    which holds for all polar :math:`z` and thus provides an analytic
    continuation to the Riemann surface of the logarithm.
    By lifting to the principal branch we obtain an analytic function on the
    cut complex plane.

    Examples
    ========

    >>> from sympy import Chi
    >>> from sympy.abc import z

    The `\cosh` integral is a primitive of `\cosh(z)/z`:

    >>> Chi(z).diff(z)
    cosh(z)/z

    It has a logarithmic branch point at the origin:

    >>> from sympy import exp_polar, I, pi
    >>> Chi(z*exp_polar(2*I*pi))
    Chi(z) + 2*I*pi

    The `\cosh` integral behaves somewhat like ordinary `\cosh` under multiplication by `i`:

    >>> from sympy import polar_lift
    >>> Chi(polar_lift(I)*z)
    Ci(z) + I*pi/2
    >>> Chi(polar_lift(-1)*z)
    Chi(z) + I*pi

    It can also be expressed in terms of exponential integrals:

    >>> from sympy import expint
    >>> Chi(z).rewrite(expint)
    -expint(1, z)/2 - expint(1, z*exp_polar(I*pi))/2 - I*pi/2

    See Also
    ========

    Si: Sine integral.
    Ci: Cosine integral.
    Shi: Hyperbolic sine integral.
    Ei: Exponential integral.
    expint: Generalised exponential integral.
    E1: Special case of the generalised exponential integral.
    li: Logarithmic integral.
    Li: Offset logarithmic integral.

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Trigonometric_integral

    c         C  s   t  j S(   N(   R   R$   (   R/   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR¢   ¬  s    c         C  s   t  j S(   N(   R   R$   (   R/   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR£   °  s    c         C  s   t  | ƒ t t S(   N(   R~   R   R   (   R/   RA   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR¦   ´  s    c         C  s   t  | ƒ t t d | S(   Ni   (   Rœ   R   R   (   R/   RA   R®   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR¥   ¸  s    c         K  sC   d d l  m } t t d t | ƒ t | t t ƒ | ƒ d S(   Niÿÿÿÿ(   R   i   (   R?   R   R   R   R‘   (   R   RA   RB   R   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRK   ¼  s    c         C  s)   d d  l  j } | j |  j d j ƒ  ƒ S(   Niÿÿÿÿi    (   R”   R•   t   cosh_integralR   R—   (   R   R˜   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR—   À  s    (   Ra   Rb   Rc   R   R¤   R   R´   R¡   Rf   R¢   R£   R¦   R¥   RK   R—   (    (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR~   b  s   E		t   FresnelIntegralc           B  sY   e  Z d  Z e Z e d „  ƒ Z d d „ Z d „  Z d „  Z	 e d „ Z
 e d „ Z RS(   s&    Base class for the Fresnel integrals.c         C  sí   | t  j k r t  d ƒ St  j } | } t } | j d ƒ } | d  k	 r_ | } | } t } n  | j t ƒ } | d  k	 rš |  j t | } | } t } n  | r® | |  | ƒ S| t  j	 k rÄ t  j
 S| t t  j	 k ré |  j t t  j
 Sd  S(   Ni    iÿÿÿÿ(   R   R(   R%   RX   R,   Rl   Rd   R   t   _signR$   R@   (   R/   RA   t   prefactt   newargt   changedRm   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR2   Î  s*    
			i   c         C  sB   | d k r/ |  j  t j t |  j d d ƒ St |  | ƒ ‚ d  S(   Ni   i    i   (   R¤   R   R@   R   R   R
   (   R   R   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR   ï  s    #c         C  s   |  j  d j S(   Ni    (   R   R<   (   R   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR=   õ  s    c         C  s   |  j  |  j d j ƒ  ƒ S(   Ni    (   R9   R   R:   (   R   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR;   ø  s    c         K  sš   |  j  d j rI | r9 t | d <|  j | |  t j f S|  t j f Sn  | rw |  j  d j | |  j ƒ  \ } } n |  j  d j ƒ  \ } } | | f S(   Ni    RW   (   R   R<   RX   RY   R   R(   RZ   (   R   R[   R\   R_   R`   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _as_real_imagû  s    
(c         K  sÅ   |  j  d | |  \ } } | d | d } t j |  j | | t | ƒ ƒ |  j | | t | ƒ ƒ } | d | t | ƒ |  j | | t | ƒ ƒ |  j | | t | ƒ ƒ } | | f S(   NR[   i   (   R¼   R   R@   R9   R   (   R   R[   R\   R5   R]   R^   R_   R`   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRZ     s    ?/(   Ra   Rb   Rc   Rd   Re   Rf   R2   R   R=   R;   R¼   RZ   (    (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR·   É  s   !		RE   c           B  sW   e  Z d  Z e Z e j Z e e	 d „  ƒ ƒ Z
 d „  Z d „  Z d „  Z d „  Z RS(   s[  
    Fresnel integral S.

    This function is defined by

    .. math:: \operatorname{S}(z) = \int_0^z \sin{\frac{\pi}{2} t^2} \mathrm{d}t.

    It is an entire function.

    Examples
    ========

    >>> from sympy import I, oo, fresnels
    >>> from sympy.abc import z

    Several special values are known:

    >>> fresnels(0)
    0
    >>> fresnels(oo)
    1/2
    >>> fresnels(-oo)
    -1/2
    >>> fresnels(I*oo)
    -I/2
    >>> fresnels(-I*oo)
    I/2

    In general one can pull out factors of -1 and `i` from the argument:

    >>> fresnels(-z)
    -fresnels(z)
    >>> fresnels(I*z)
    -I*fresnels(z)

    The Fresnel S integral obeys the mirror symmetry
    `\overline{S(z)} = S(\bar{z})`:

    >>> from sympy import conjugate
    >>> conjugate(fresnels(z))
    fresnels(conjugate(z))

    Differentiation with respect to `z` is supported:

    >>> from sympy import diff
    >>> diff(fresnels(z), z)
    sin(pi*z**2/2)

    Defining the Fresnel functions via an integral

    >>> from sympy import integrate, pi, sin, gamma, expand_func
    >>> integrate(sin(pi*z**2/2), z)
    3*fresnels(z)*gamma(3/4)/(4*gamma(7/4))
    >>> expand_func(integrate(sin(pi*z**2/2), z))
    fresnels(z)

    We can numerically evaluate the Fresnel integral to arbitrary precision
    on the whole complex plane:

    >>> fresnels(2).evalf(30)
    0.343415678363698242195300815958

    >>> fresnels(-2*I).evalf(30)
    0.343415678363698242195300815958*I

    See Also
    ========

    fresnelc: Fresnel cosine integral.

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Fresnel_integral
    .. [2] http://dlmf.nist.gov/7
    .. [3] http://mathworld.wolfram.com/FresnelIntegrals.html
    .. [4] http://functions.wolfram.com/GammaBetaErf/FresnelS
    .. [5] The converging factors for the fresnel integrals
            by John W. Wrench Jr. and Vicki Alley

    c         G  sÙ   |  d k  r t  j St | ƒ } t | ƒ d k r| | d } t d | d d |  d d |  d |  d d |  d | S| d | d |  t  d ƒ d |  d t d |  d d |  d t d |  d ƒ Sd  S(	   Ni    i   iÿÿÿÿi   i   i   i   iþÿÿÿ(   R   R(   R   R3   R   R   (   R4   R5   R6   t   p(    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR8   l  s    
Ac         K  sY   t  j t d t t  j t d t t ƒ | ƒ t t t  j t d t t ƒ | ƒ S(   Ni   i   (   R   R%   R   R   R   R   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRj   y  s    c         K  sX   t  | d d t t d ƒ d g t d ƒ d t d ƒ d g t  d | d d ƒ S(   Ni   i   i   i   i   i   (   R   R   R   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRI   |  s    c      	   K  s   t  | t d ƒ d t d ƒ | d t d ƒ d | t d ƒ d t g  d g t d ƒ d g t d ƒ d d g t  d | d d ƒ S(   Ni	   i   i   i   i   i    i   (   R   R   R   R   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRH     s    c         C  sW  d d l  m } | d } | t j t j g k r8|  j d } g  t d | ƒ D]p } d | d | k  rP d | t d | d ƒ d d | d | d | d d d | t d | ƒ ^ qP }	 d d | g g  t d | ƒ D]x } d | d | k  rä d | t d | d ƒ d d | d | d | d d d | d t d | d ƒ ^ qä }
 g  |	 D] } t d t ƒ | ^ qj}	 g  |
 D] } t d t ƒ | ^ q’}
 | t j k rÈd n d } | t j	 t
 | d ƒ t |	 Œ  t | d ƒ t |
 Œ  j | t d t ƒ | ƒ | d | | | ƒ St t |  ƒ j | | | | ƒ S(   Niÿÿÿÿ(   RR   i    i   i   i   i   (   R?   RR   R   R$   R   R   R   R   R   R@   R   R   R   R«   Rƒ   RE   t   _eval_aseries(   R   R4   t   args0R5   R„   RR   t   pointRA   R7   R½   t   qR1   t   s(    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR¾   ƒ  s    
ƒŒ((j(   Ra   Rb   Rc   R   R¤   R   R%   R¸   Rg   R   R8   Rj   RI   RH   R¾   (    (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRE     s   Q
			RD   c           B  sV   e  Z d  Z e Z e j Z e e	 d „  ƒ ƒ Z
 d „  Z d „  Z d „  Z d „  Z RS(   sV  
    Fresnel integral C.

    This function is defined by

    .. math:: \operatorname{C}(z) = \int_0^z \cos{\frac{\pi}{2} t^2} \mathrm{d}t.

    It is an entire function.

    Examples
    ========

    >>> from sympy import I, oo, fresnelc
    >>> from sympy.abc import z

    Several special values are known:

    >>> fresnelc(0)
    0
    >>> fresnelc(oo)
    1/2
    >>> fresnelc(-oo)
    -1/2
    >>> fresnelc(I*oo)
    I/2
    >>> fresnelc(-I*oo)
    -I/2

    In general one can pull out factors of -1 and `i` from the argument:

    >>> fresnelc(-z)
    -fresnelc(z)
    >>> fresnelc(I*z)
    I*fresnelc(z)

    The Fresnel C integral obeys the mirror symmetry
    `\overline{C(z)} = C(\bar{z})`:

    >>> from sympy import conjugate
    >>> conjugate(fresnelc(z))
    fresnelc(conjugate(z))

    Differentiation with respect to `z` is supported:

    >>> from sympy import diff
    >>> diff(fresnelc(z), z)
    cos(pi*z**2/2)

    Defining the Fresnel functions via an integral

    >>> from sympy import integrate, pi, cos, gamma, expand_func
    >>> integrate(cos(pi*z**2/2), z)
    fresnelc(z)*gamma(1/4)/(4*gamma(5/4))
    >>> expand_func(integrate(cos(pi*z**2/2), z))
    fresnelc(z)

    We can numerically evaluate the Fresnel integral to arbitrary precision
    on the whole complex plane:

    >>> fresnelc(2).evalf(30)
    0.488253406075340754500223503357

    >>> fresnelc(-2*I).evalf(30)
    -0.488253406075340754500223503357*I

    See Also
    ========

    fresnels: Fresnel sine integral.

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Fresnel_integral
    .. [2] http://dlmf.nist.gov/7
    .. [3] http://mathworld.wolfram.com/FresnelIntegrals.html
    .. [4] http://functions.wolfram.com/GammaBetaErf/FresnelC
    .. [5] The converging factors for the fresnel integrals
            by John W. Wrench Jr. and Vicki Alley
    c         G  sÉ   |  d k  r t  j St | ƒ } t | ƒ d k r| | d } t d | d d |  d d |  d |  d d |  d | S| | d |  t  d ƒ d |  t d |  d |  d t d |  ƒ Sd  S(	   Ni    i   iÿÿÿÿi   i   i   i   iþÿÿÿ(   R   R(   R   R3   R   R   (   R4   R5   R6   R½   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR8   õ  s    
Ac         K  sY   t  j t d t t  j t d t t ƒ | ƒ t t t  j t d t t ƒ | ƒ S(   Ni   i   (   R   R%   R   R   R   R   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRj   	  s    c         K  sF   | t  t j d g t j d t d ƒ d g t d | d d ƒ S(   Ni   i   i   i   (   R   R   R%   R   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRI   	  s    c      	   K  s†   t  | t d ƒ d t d ƒ t | d d ƒ t | d ƒ t g  d g t d ƒ d g t d ƒ d d g t  d | d d ƒ S(   Ni   i   i   i   i    i   (   R   R   R   R   R   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRH   	  s    c         C  sV  d d l  m } | d } | t j t j g k r7|  j d } g  t d | ƒ D]p } d | d | k  rP d | t d | d ƒ d d | d | d | d d d | t d | ƒ ^ qP }	 d d | g g  t d | ƒ D]x } d | d | k  rä d | t d | d ƒ d d | d | d | d d d | d t d | d ƒ ^ qä }
 g  |	 D] } t d t ƒ | ^ qj}	 g  |
 D] } t d t ƒ | ^ q’}
 | t j k rÇd n d } | t j	 t
 | d ƒ t |	 Œ  t | d ƒ t |
 Œ  j | t d t ƒ | ƒ | d | | | ƒ St t |  ƒ j | | | | ƒ S(   Niÿÿÿÿ(   RR   i    i   i   i   i   (   R?   RR   R   R$   R   R   R   R   R   R@   R   R   R   R«   Rƒ   RD   R¾   (   R   R4   R¿   R5   R„   RR   RÀ   RA   R7   R½   RÁ   R1   RÂ   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR¾   	  s    
ƒŒ('j(   Ra   Rb   Rc   R   R¤   R   R%   R¸   Rg   R   R8   Rj   RI   RH   R¾   (    (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRD   ¡  s   P				RL   c           B  s,   e  Z d  Z d „  Z d d „ Z d „  Z RS(   sh   
    Helper function to make the `\mathrm{erf}(z)` function
    tractable for the Gruntz algorithm.
    c         C  sÑ  d d l  m } | d } | t j k rÝ |  j d } g  t d | ƒ D]U } d t t j ƒ t d | ƒ t d ƒ | t | ƒ d | d | d ^ qF }	 | d | d | d | ƒ }
 t	 |	 Œ  j
 | | | ƒ |
 S| j t j ƒ } | t j k r²|  j d } g  t d | ƒ D]U } d t t j ƒ t d | ƒ t d ƒ | t | ƒ d | d | d ^ q}	 | d | d | d | ƒ }
 t	 |	 Œ  j
 | | | ƒ |
 St t |  ƒ j | | | | ƒ S(   Niÿÿÿÿ(   RR   i    i   i   i   (   R?   RR   R   R$   R   R   R   R   R   R   R‚   R,   R-   Rƒ   RL   R¾   (   R   R4   R¿   R5   R„   RR   RÀ   RA   R7   t   lt   oR1   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR¾   6	  s     
hhi   c         C  sO   | d k r< |  j  d } d t t j ƒ d | t | ƒ St |  | ƒ ‚ d  S(   Ni   i    iþÿÿÿi   (   R   R   R   R   RL   R
   (   R   R   RA   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR   Q	  s    #c         K  s   t  j t | ƒ t | d ƒ S(   Ni   (   R   R%   R   R   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   _eval_rewrite_as_intractableX	  s    (   Ra   Rb   Rc   R¾   R   RÅ   (    (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRL   /	  s   	R€   c           B  s5   e  Z d  Z d „  Z d d „ Z d „  Z d „  Z RS(   s}   
    Helper function to make the `\mathrm{Ei}(z)` and `\mathrm{li}(z)` functions
    tractable for the Gruntz algorithm.
    c   
      C  s¿   d d l  m } | d t j k rB t t |  ƒ j | | | | ƒ S|  j d } g  t d | ƒ D]" } t	 | ƒ d | | d ^ q_ } | d | | d | ƒ }	 t
 | Œ  j | | | ƒ |	 S(   Niÿÿÿÿ(   RR   i    i   (   R?   RR   R   R$   Rƒ   RL   R¾   R   R   R   R   R‚   (
   R   R4   R¿   R5   R„   RR   RA   R7   RÃ   RÄ   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR¾   c	  s    8i   c         C  sA   | d k r. |  j  d } t j | t | ƒ St |  | ƒ ‚ d  S(   Ni   i    (   R   R   R%   R€   R
   (   R   R   RA   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR   o	  s    c         K  s   t  | ƒ t | ƒ S(   N(   R   Ru   (   R   RA   RB   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyRÅ   v	  s    c         C  si   |  j  d j | d ƒ } | t j k rM |  j |  j  Œ  } | j | | | ƒ St t |  ƒ j | | | ƒ S(   Ni    (   R   R   R   R(   RÅ   R‚   Rƒ   R€   (   R   R5   R4   R„   R…   R†   (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR‚   y	  s
    (   Ra   Rb   Rc   R¾   R   RÅ   R‚   (    (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyR€   \	  s
   		N(>   Rc   t
   __future__R    R   t
   sympy.coreR   R   R   R   R   R   t   sympy.core.compatibilityR   t   sympy.core.functionR	   R
   t   sympy.core.symbolR   t(   sympy.functions.combinatorial.factorialsR   t#   sympy.functions.elementary.integersR   t(   sympy.functions.elementary.miscellaneousR   R   t&   sympy.functions.elementary.exponentialR   R   t$   sympy.functions.elementary.complexesR   t%   sympy.functions.elementary.hyperbolicR   R   t(   sympy.functions.elementary.trigonometricR   R   R   t   sympy.functions.special.hyperR   R   R   RN   RP   Rn   R    R*   R+   Ru   RJ   R‘   R{   Rš   R    R   Rœ   R}   R~   R·   RE   RD   RL   R€   (    (    (    sF   lib/python2.7/site-packages/sympy/functions/special/error_functions.pyt   <module>   sF   .
Á¿¬‡UGT’²	’X=dgYgNŠŽ-