U
    ZÊ¹jº3 ã                   @   s†  d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	m
Z
 ddlmZ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 ddlmZmZmZ ddlmZm Z m!Z! ddl"m#Z#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dl/m0Z0m1Z1m2Z2 ddl3m4Z4m5Z5 dDdd„Z6G dd„ deƒZ7G dd„ deƒZ8G dd„ deƒZ9G dd„ deƒZ:G dd „ d eƒZ;G d!d"„ d"eƒZ<G d#d$„ d$eƒZ=G d%d&„ d&eƒZ>G d'd(„ d(eƒZ?d)d*„ Z@G d+d,„ d,eƒZAG d-d.„ d.eƒZBG d/d0„ d0eƒZCG d1d2„ d2eCƒZDG d3d4„ d4eCƒZEG d5d6„ d6eCƒZFG d7d8„ d8eCƒZGG d9d:„ d:eƒZHG d;d<„ d<eHƒZIG d=d>„ d>eHƒZJG d?d@„ d@eƒZKG dAdB„ dBeƒZLdCS )Ez� This module contains various functions that are special cases
    of incomplete gamma functions. It should probably be renamed. é    )Ú
EulerGamma)ÚAdd)Úcacheit)ÚFunctionÚArgumentIndexErrorÚ
expand_mul)ÚIÚpiÚRational)Úis_eq)ÚPow)ÚS)ÚDummyÚuniquely_named_symbol)Úsympify)Ú	factorialÚ
factorial2ÚRisingFactorial)Ú
polar_liftÚreÚ
unpolarify)ÚceilingÚfloor)ÚsqrtÚroot)ÚexpÚlogÚ	exp_polar)ÚcoshÚsinh)ÚcosÚsinÚsinc)ÚhyperÚmeijergTc                 K   sÆ   | j d jr6|r,d|d< | j|f|ŽtjfS | tjfS |rX| j d j|f|Ž ¡ \}}n| j d  ¡ \}}|  |t|  ¡|  |t|  ¡ d }|  |t|  ¡|  |t|  ¡ dt  }||fS )Nr   FÚcomplexé   )ÚargsÚis_extended_realÚexpandr   ÚZeroÚas_real_imagÚfuncr   )ÚselfÚdeepÚhintsÚxÚyr   Zim© r2   úf/var/www/html/bwave/python/venv/lib/python3.8/site-packages/sympy/functions/special/error_functions.pyÚreal_to_real_as_real_imag   s    
(,r4   c                       sÌ   e Zd ZdZdZd,dd„Zd-dd„Zedd	„ ƒZe	e
d
d„ ƒƒZdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd.d!d"„Zd#d$„ Zd%d&„ Zd/d(d)„Z‡ fd*d+„ZeZ‡  ZS )0Úerfa.  
    The Gauss error function.

    Explanation
    ===========

    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] https://dlmf.nist.gov/7
    .. [3] https://mathworld.wolfram.com/Erf.html
    .. [4] https://functions.wolfram.com/GammaBetaErf/Erf

    Té   c                 C   s6   |dkr(dt | jd d  ƒ ttƒ S t| |ƒ‚d S ©Nr6   r&   r   ©r   r'   r   r	   r   ©r-   Úargindexr2   r2   r3   Úfdiff   s     z	erf.fdiffc                 C   s   t S ©z8
        Returns the inverse of this function.

        ©Úerfinvr9   r2   r2   r3   Úinverse†   s    zerf.inversec                 C   sÒ   |j rB|tjkrtjS |tjkr&tjS |tjkr6tjS |jrBtjS t	|t
ƒrV|jd S t	|tƒrptj|jd  S |jr|tjS t	|tƒrœ|jd jrœ|jd S | t¡}|tjtjfkrº|S | ¡ rÎ| | ƒ S d S ©Nr   r6   )Ú	is_Numberr   ÚNaNÚInfinityÚOneÚNegativeInfinityÚNegativeOneÚis_zeror*   Ú
isinstancer>   r'   ÚerfcinvÚerf2invÚextract_multiplicativelyr   Úcould_extract_minus_sign©ÚclsÚargÚtr2   r2   r3   Úeval�   s,    







zerf.evalc                 G   s’   | dk s| d dkrt jS t|ƒ}t| d t dƒ ƒ}t|ƒdkrd|d  |d  | d  | |  S dt j|  ||   | t|ƒ ttƒ  S d S ©Nr   r&   r6   éþÿÿÿ)	r   r*   r   r   ÚlenrF   r   r   r	   ©Únr0   Úprevious_termsÚkr2   r2   r3   Útaylor_term¯   s    "zerf.taylor_termc                 C   s   |   | jd  ¡ ¡S ©Nr   ©r,   r'   Ú	conjugate©r-   r2   r2   r3   Ú_eval_conjugate¼   s    zerf._eval_conjugatec                 C   s   | j d jS rZ   ©r'   r(   r]   r2   r2   r3   Ú_eval_is_real¿   s    zerf._eval_is_realc                 C   s    | j d jrdS | j d jS d S ©Nr   T)r'   Ú	is_finiter(   r]   r2   r2   r3   Ú_eval_is_finiteÂ   s    zerf._eval_is_finitec                 C   s   | j d jS rZ   ©r'   rG   r]   r2   r2   r3   Ú_eval_is_zeroÈ   s    zerf._eval_is_zeroc                 K   s:   ddl m} t|d ƒ| tj|tj|d ƒttƒ   S ©Nr   ©Ú
uppergammar&   ©Ú'sympy.functions.special.gamma_functionsrh   r   r   rD   ÚHalfr	   ©r-   ÚzÚkwargsrh   r2   r2   r3   Ú_eval_rewrite_as_uppergammaË   s    zerf._eval_rewrite_as_uppergammac                 K   s4   t jt | ttƒ }t jt t|ƒtt|ƒ   S ©N©r   rD   r   r   r	   ÚfresnelcÚfresnels©r-   rm   rn   rO   r2   r2   r3   Ú_eval_rewrite_as_fresnelsÏ   s    zerf._eval_rewrite_as_fresnelsc                 K   s4   t jt | ttƒ }t jt t|ƒtt|ƒ   S rp   rq   rt   r2   r2   r3   Ú_eval_rewrite_as_fresnelcÓ   s    zerf._eval_rewrite_as_fresnelcc                 K   s.   |t tƒ ttjgg dgtddƒg|d ƒ S ©Nr   éÿÿÿÿr&   ©r   r	   r$   r   rk   r
   ©r-   rm   rn   r2   r2   r3   Ú_eval_rewrite_as_meijerg×   s    zerf._eval_rewrite_as_meijergc                 K   s.   d| t tƒ ttjgdtj g|d  ƒ S ©Nr&   é   ©r   r	   r#   r   rk   rz   r2   r2   r3   Ú_eval_rewrite_as_hyperÚ   s    zerf._eval_rewrite_as_hyperc                 K   s,   t |d ƒ| |ttj|d ƒ t tƒ  S ©Nr&   ©r   Úexpintr   rk   r	   rz   r2   r2   r3   Ú_eval_rewrite_as_expintÝ   s    zerf._eval_rewrite_as_expintNc                 K   sb   ddl m} |rF|||tjƒ}|tjkrFtjt| ƒt|d  ƒ  S tjt|ƒt|d  ƒ  S )Nr   )Úlimitr&   )	Zsympy.series.limitsr„   r   rC   rE   rF   Ú_erfsr   rD   )r-   rm   Úlimitvarrn   r„   Zlimr2   r2   r3   Ú_eval_rewrite_as_tractableà   s    
zerf._eval_rewrite_as_tractablec                 K   s   t jt|ƒ S rp   )r   rD   Úerfcrz   r2   r2   r3   Ú_eval_rewrite_as_erfcè   s    zerf._eval_rewrite_as_erfcc                 K   s   t  tt | ƒ S rp   ©r   Úerfirz   r2   r2   r3   Ú_eval_rewrite_as_erfië   s    zerf._eval_rewrite_as_erfir   c                 C   sv   | j d j|||d�}| |d¡}|tjkrH|j|d|dkr@dndd�}||jkrh|jrhd| tt	ƒ S |  
|¡S d S )Nr   ©ÚlogxÚcdirrx   ú-ú+©Údirr&   )r'   Úas_leading_termÚsubsr   ÚComplexInfinityr„   Úfree_symbolsrG   r   r	   r,   ©r-   r0   rŽ   r�   rO   Úarg0r2   r2   r3   Ú_eval_as_leading_termî   s    
zerf._eval_as_leading_termc              	      sÚ   ddl m} |d }|tjtjfkrÄ| jd ‰ zˆ  |¡\}}W n ttfk
r\   |  Y S X | }|j	rÄt
|| ƒ}	‡ fdd„t|	ƒD ƒ|dˆ |	  |ƒg }
tjtˆ d  ƒttƒ t|
Ž   S tt| ƒ ||||¡S )Nr   ©ÚOrderc                    s>   g | ]6}t j| td | d ƒ ˆ d | d  d |   ‘qS ©r&   r6   )r   rF   r   ©Ú.0rX   ©rm   r2   r3   Ú
<listcomp>  s   ÿz%erf._eval_aseries.<locals>.<listcomp>r6   r&   )Úsympy.series.orderrœ   r   rC   rE   r'   ZleadtermÚ
ValueErrorÚNotImplementedErrorÚis_positiver   ÚrangerD   r   r   r	   r   Úsuperr5   Ú_eval_aseries)r-   rV   Úargs0r0   rŽ   rœ   ÚpointÚ_ÚexZnewnÚs©Ú	__class__r    r3   r¨   ù   s$    


ÿÿ$zerf._eval_aseries)r6   )r6   )N)Nr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
unbranchedr;   r?   ÚclassmethodrQ   Ústaticmethodr   rY   r^   r`   rc   re   ro   ru   rv   r{   r   rƒ   r‡   r‰   rŒ   rš   r¨   r4   r+   Ú__classcell__r2   r2   r®   r3   r5   0   s2   L


!

r5   c                   @   s¼   e Zd ZdZdZd*dd„Zd+dd„Zedd	„ ƒZe	e
d
d„ ƒƒZdd„ Zdd„ Zd,dd„Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd-d&d'„ZeZd(d)„ ZdS ).rˆ   a&  
    Complementary Error Function.

    Explanation
    ===========

    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] https://dlmf.nist.gov/7
    .. [3] https://mathworld.wolfram.com/Erfc.html
    .. [4] https://functions.wolfram.com/GammaBetaErf/Erfc

    Tr6   c                 C   s6   |dkr(dt | jd d  ƒ ttƒ S t| |ƒ‚d S )Nr6   rS   r   r&   r8   r9   r2   r2   r3   r;   `  s     z
erfc.fdiffc                 C   s   t S r<   ©rI   r9   r2   r2   r3   r?   f  s    zerfc.inversec                 C   s¦   |j r2|tjkrtjS |tjkr&tjS |jr2tjS t|tƒrLtj|j	d  S t|t
ƒr`|j	d S |jrltjS | t¡}|tjtjfkrŒ| S | ¡ r¢d| | ƒ S d S )Nr   r&   )rA   r   rB   rC   r*   rG   rD   rH   r>   r'   rI   rK   r   rE   rL   rM   r2   r2   r3   rQ   m  s$    





z	erfc.evalc                 G   s    | dkrt jS | dk s"| d dkr(t jS t|ƒ}t| d t dƒ ƒ}t|ƒdkrr|d  |d  | d  | |  S dt j|  ||   | t|ƒ tt	ƒ  S d S rR   )
r   rD   r*   r   r   rT   rF   r   r   r	   rU   r2   r2   r3   rY   ‰  s    "zerfc.taylor_termc                 C   s   |   | jd  ¡ ¡S rZ   r[   r]   r2   r2   r3   r^   ˜  s    zerfc._eval_conjugatec                 C   s   | j d jS rZ   r_   r]   r2   r2   r3   r`   ›  s    zerfc._eval_is_realNc                 K   s   |   t¡j dd|d�S ©NÚ	tractableT)r.   r†   ©Úrewriter5   ©r-   rm   r†   rn   r2   r2   r3   r‡   ž  s    zerfc._eval_rewrite_as_tractablec                 K   s   t jt|ƒ S rp   )r   rD   r5   rz   r2   r2   r3   Ú_eval_rewrite_as_erf¡  s    zerfc._eval_rewrite_as_erfc                 K   s   t jttt| ƒ  S rp   )r   rD   r   r‹   rz   r2   r2   r3   rŒ   ¤  s    zerfc._eval_rewrite_as_erfic                 K   s:   t jt | ttƒ }t jt jt t|ƒtt|ƒ    S rp   rq   rt   r2   r2   r3   ru   §  s    zerfc._eval_rewrite_as_fresnelsc                 K   s:   t jt | ttƒ }t jt jt t|ƒtt|ƒ    S rp   rq   rt   r2   r2   r3   rv   «  s    zerfc._eval_rewrite_as_fresnelcc              	   K   s4   t j|ttƒ tt jgg dgtddƒg|d ƒ  S rw   )r   rD   r   r	   r$   rk   r
   rz   r2   r2   r3   r{   ¯  s    zerfc._eval_rewrite_as_meijergc                 K   s4   t jd| ttƒ tt jgdt j g|d  ƒ  S r|   )r   rD   r   r	   r#   rk   rz   r2   r2   r3   r   ²  s    zerfc._eval_rewrite_as_hyperc                 K   s@   ddl m} tjt|d ƒ| tj|tj|d ƒttƒ    S rf   )rj   rh   r   rD   r   rk   r	   rl   r2   r2   r3   ro   µ  s    z erfc._eval_rewrite_as_uppergammac                 K   s2   t jt|d ƒ|  |tt j|d ƒ ttƒ  S r€   )r   rD   r   r‚   rk   r	   rz   r2   r2   r3   rƒ   ¹  s    zerfc._eval_rewrite_as_expintc                 K   s
   |   t¡S rp   r»   ©r-   r/   r2   r2   r3   Ú_eval_expand_func¼  s    zerfc._eval_expand_funcr   c                 C   sb   | j d j|||d�}| |d¡}|tjkrH|j|d|dkr@dndd�}|jrTtjS |  |¡S d S )Nr   r�   rx   r�   r‘   r’   )	r'   r”   r•   r   r–   r„   rG   rD   r,   r˜   r2   r2   r3   rš   ¿  s    
zerfc._eval_as_leading_termc                 C   s   t jt| jŽ  ||||¡ S rp   )r   rD   r5   r'   r¨   )r-   rV   r©   r0   rŽ   r2   r2   r3   r¨   Ì  s    zerfc._eval_aseries)r6   )r6   )N)Nr   )r°   r±   r²   r³   r´   r;   r?   rµ   rQ   r¶   r   rY   r^   r`   r‡   r¾   rŒ   ru   rv   r{   r   ro   rƒ   rÀ   rš   r4   r+   r¨   r2   r2   r2   r3   rˆ     s0   L




rˆ   c                       sÂ   e Zd ZdZdZd*dd„Zedd„ ƒZee	dd	„ ƒƒZ
d
d„ Zdd„ Zdd„ Zd+dd„Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ ZeZd,d&d'„Z‡ fd(d)„Z‡  ZS )-r‹   aí  
    Imaginary error function.

    Explanation
    ===========

    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] https://mathworld.wolfram.com/Erfi.html
    .. [3] https://functions.wolfram.com/GammaBetaErf/Erfi

    Tr6   c                 C   s4   |dkr&dt | jd d ƒ ttƒ S t| |ƒ‚d S r7   r8   r9   r2   r2   r3   r;     s    z
erfi.fdiffc                 C   sÐ   |j r2|tjkrtjS |jr"tjS |tjkr2tjS |jr>tjS | ¡ rR| | ƒ S | t¡}|d k	rÌ|tjkrrtS t	|t
ƒrŠt|jd  S t	|tƒr¨ttj|jd   S t	|tƒrÌ|jd jrÌt|jd  S d S r@   )rA   r   rB   rG   r*   rC   rL   rK   r   rH   r>   r'   rI   rD   rJ   ©rN   rm   Únzr2   r2   r3   rQ   "  s*    





z	erfi.evalc                 G   s†   | dk s| d dkrt jS t|ƒ}t| d t dƒ ƒ}t|ƒdkrb|d |d  | d  | |  S d||   | t|ƒ ttƒ  S d S rR   )r   r*   r   r   rT   r   r   r	   rU   r2   r2   r3   rY   @  s     zerfi.taylor_termc                 C   s   |   | jd  ¡ ¡S rZ   r[   r]   r2   r2   r3   r^   M  s    zerfi._eval_conjugatec                 C   s   | j d jS rZ   r_   r]   r2   r2   r3   Ú_eval_is_extended_realP  s    zerfi._eval_is_extended_realc                 C   s   | j d jS rZ   rd   r]   r2   r2   r3   re   S  s    zerfi._eval_is_zeroNc                 K   s   |   t¡j dd|d�S r¹   r»   r½   r2   r2   r3   r‡   V  s    zerfi._eval_rewrite_as_tractablec                 K   s   t  tt | ƒ S rp   )r   r5   rz   r2   r2   r3   r¾   Y  s    zerfi._eval_rewrite_as_erfc                 K   s   t tt | ƒ t  S rp   )r   rˆ   rz   r2   r2   r3   r‰   \  s    zerfi._eval_rewrite_as_erfcc                 K   s4   t jt | ttƒ }t jt t|ƒtt|ƒ   S rp   rq   rt   r2   r2   r3   ru   _  s    zerfi._eval_rewrite_as_fresnelsc                 K   s4   t jt | ttƒ }t jt t|ƒtt|ƒ   S rp   rq   rt   r2   r2   r3   rv   c  s    zerfi._eval_rewrite_as_fresnelcc                 K   s0   |t tƒ ttjgg dgtddƒg|d  ƒ S rw   ry   rz   r2   r2   r3   r{   g  s    zerfi._eval_rewrite_as_meijergc                 K   s,   d| t tƒ ttjgdtj g|d ƒ S r|   r~   rz   r2   r2   r3   r   j  s    zerfi._eval_rewrite_as_hyperc                 K   s>   ddl m} t|d  ƒ| |tj|d  ƒttƒ tj  S rf   )rj   rh   r   r   rk   r	   rD   rl   r2   r2   r3   ro   m  s    z erfi._eval_rewrite_as_uppergammac                 K   s0   t |d  ƒ| |ttj|d  ƒ t tƒ  S r€   r�   rz   r2   r2   r3   rƒ   q  s    zerfi._eval_rewrite_as_expintc                 K   s
   |   t¡S rp   r»   r¿   r2   r2   r3   rÀ   t  s    zerfi._eval_expand_funcr   c                 C   s\   | j d j|||d�}| |d¡}||jkrB|jrBd| ttƒ S |jrR|  |¡S |  |¡S )Nr   r�   r&   )	r'   r”   r•   r—   rG   r   r	   rb   r,   r˜   r2   r2   r3   rš   y  s    
zerfi._eval_as_leading_termc                    sŠ   ddl m} |d }|tjkrt| jd ‰ ‡ fdd„t|ƒD ƒ|dˆ |  |ƒg }t tˆ d ƒtt	ƒ t
|Ž   S tt| ƒ ||||¡S )Nr   r›   c                    s4   g | ],}t d | d ƒd | ˆ d | d    ‘qS r�   )r   rž   r    r2   r3   r¡   ‰  s   ÿz&erfi._eval_aseries.<locals>.<listcomp>r6   r&   )r¢   rœ   r   rC   r'   r¦   r   r   r   r	   r   r§   r‹   r¨   ©r-   rV   r©   r0   rŽ   rœ   rª   r­   r®   r    r3   r¨   ƒ  s    


ÿÿ"zerfi._eval_aseries)r6   )N)Nr   )r°   r±   r²   r³   r´   r;   rµ   rQ   r¶   r   rY   r^   rÃ   re   r‡   r¾   r‰   ru   rv   r{   r   ro   rƒ   rÀ   r4   r+   rš   r¨   r·   r2   r2   r®   r3   r‹   Ð  s0   I




r‹   c                   @   sŒ   e Zd ZdZdd„ Zedd„ ƒZdd„ Zdd	„ Zd
d„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd S )!Úerf2a?  
    Two-argument error function.

    Explanation
    ===========

    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 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] https://functions.wolfram.com/GammaBetaErf/Erf2/

    c                 C   s\   | j \}}|dkr,dt|d  ƒ ttƒ S |dkrNdt|d  ƒ ttƒ S t| |ƒ‚d S )Nr6   rS   r&   )r'   r   r   r	   r   ©r-   r:   r0   r1   r2   r2   r3   r;   Ö  s    
z
erf2.fdiffc                 C   sò   t jt jt jf}|t jks$|t jkr*t jS ||kr8t jS ||ksH||krXt|ƒt|ƒ S t|tƒrz|jd |krz|jd S |j	sž|j	sž|j
r’|jsž|j
r®|jr®t|ƒt|ƒ S | ¡ }| ¡ }|rÖ|rÖ| | | ƒ S |sÞ|rît|ƒt|ƒ S d S r@   )r   rC   rE   r*   rB   r5   rH   rJ   r'   rG   r(   Úis_infiniterL   )rN   r0   r1   ZchkZsign_xZsign_yr2   r2   r3   rQ   ß  s*    
ÿÿz	erf2.evalc                 C   s    |   | jd  ¡ | jd  ¡ ¡S r@   r[   r]   r2   r2   r3   r^   ø  s    zerf2._eval_conjugatec                 C   s   | j d jo| j d jS r@   r_   r]   r2   r2   r3   rÃ   û  s    zerf2._eval_is_extended_realc                 K   s   t |ƒt |ƒ S rp   ©r5   ©r-   r0   r1   rn   r2   r2   r3   r¾   þ  s    zerf2._eval_rewrite_as_erfc                 K   s   t |ƒt |ƒ S rp   ©rˆ   rÉ   r2   r2   r3   r‰     s    zerf2._eval_rewrite_as_erfcc                 K   s   t tt | ƒtt | ƒ  S rp   rŠ   rÉ   r2   r2   r3   rŒ     s    zerf2._eval_rewrite_as_erfic                 K   s   t |ƒ t¡t |ƒ t¡ S rp   )r5   r¼   rs   rÉ   r2   r2   r3   ru     s    zerf2._eval_rewrite_as_fresnelsc                 K   s   t |ƒ t¡t |ƒ t¡ S rp   )r5   r¼   rr   rÉ   r2   r2   r3   rv   
  s    zerf2._eval_rewrite_as_fresnelcc                 K   s   t |ƒ t¡t |ƒ t¡ S rp   )r5   r¼   r$   rÉ   r2   r2   r3   r{     s    zerf2._eval_rewrite_as_meijergc                 K   s   t |ƒ t¡t |ƒ t¡ S rp   )r5   r¼   r#   rÉ   r2   r2   r3   r     s    zerf2._eval_rewrite_as_hyperc                 K   sh   ddl m} t|d ƒ| tj|tj|d ƒttƒ   t|d ƒ| tj|tj|d ƒttƒ    S rf   ri   )r-   r0   r1   rn   rh   r2   r2   r3   ro     s    ,,ÿz erf2._eval_rewrite_as_uppergammac                 K   s   t |ƒ t¡t |ƒ t¡ S rp   )r5   r¼   r‚   rÉ   r2   r2   r3   rƒ     s    zerf2._eval_rewrite_as_expintc                 K   s
   |   t¡S rp   r»   r¿   r2   r2   r3   rÀ     s    zerf2._eval_expand_funcc                 C   s
   t | jŽ S rp   )r   r'   r]   r2   r2   r3   re     s    zerf2._eval_is_zeroN)r°   r±   r²   r³   r;   rµ   rQ   r^   rÃ   r¾   r‰   rŒ   ru   rv   r{   r   ro   rƒ   rÀ   re   r2   r2   r2   r3   rÅ   �  s"   E	
rÅ   c                   @   s@   e Zd ZdZddd„Zddd„Zedd„ ƒZd	d
„ Zdd„ Z	dS )r>   aR  
    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 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] https://functions.wolfram.com/GammaBetaErf/InverseErf/

    r6   c                 C   s<   |dkr.t tƒt|  | jd ¡d ƒ tj S t| |ƒ‚d S ©Nr6   r   r&   ©r   r	   r   r,   r'   r   rk   r   r9   r2   r2   r3   r;   T  s    &zerfinv.fdiffc                 C   s   t S r<   rÈ   r9   r2   r2   r3   r?   Z  s    zerfinv.inversec                 C   s    |t jkrt jS |t jkr t jS |jr,t jS |t jkr<t jS t|t	ƒr\|j
d jr\|j
d S |jrht jS | d¡}|d k	rœt|t	ƒrœ|j
d jrœ|j
d  S d S ©Nr   rx   )r   rB   rF   rE   rG   r*   rD   rC   rH   r5   r'   r(   rK   rÁ   r2   r2   r3   rQ   a  s    




zerfinv.evalc                 K   s   t d| ƒS ©Nr6   r¸   rz   r2   r2   r3   Ú_eval_rewrite_as_erfcinvw  s    zerfinv._eval_rewrite_as_erfcinvc                 C   s   | j d jS rZ   rd   r]   r2   r2   r3   re   z  s    zerfinv._eval_is_zeroN)r6   )r6   )
r°   r±   r²   r³   r;   r?   rµ   rQ   rÏ   re   r2   r2   r2   r3   r>   !  s   2


r>   c                   @   sH   e Zd ZdZddd„Zddd„Zedd„ ƒZd	d
„ Zdd„ Z	dd„ Z
dS )rI   a´  
    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 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] https://functions.wolfram.com/GammaBetaErf/InverseErfc/

    r6   c                 C   s>   |dkr0t tƒ t|  | jd ¡d ƒ tj S t| |ƒ‚d S rË   rÌ   r9   r2   r2   r3   r;   «  s    (zerfcinv.fdiffc                 C   s   t S r<   rÊ   r9   r2   r2   r3   r?   ±  s    zerfcinv.inversec                 C   sJ   |t jkrt jS |jrt jS |t jkr,t jS |dkr:t jS |jrFt jS d S r€   )r   rB   rG   rC   rD   r*   rE   ©rN   rm   r2   r2   r3   rQ   ¸  s    

zerfcinv.evalc                 K   s   t d| ƒS rÎ   r=   rz   r2   r2   r3   Ú_eval_rewrite_as_erfinvÆ  s    zerfcinv._eval_rewrite_as_erfinvc                 C   s   | j d d jS r@   rd   r]   r2   r2   r3   re   É  s    zerfcinv._eval_is_zeroc                 C   s   | j d jS rZ   rd   r]   r2   r2   r3   Ú_eval_is_infiniteÌ  s    zerfcinv._eval_is_infiniteN)r6   )r6   )r°   r±   r²   r³   r;   r?   rµ   rQ   rÑ   re   rÒ   r2   r2   r2   r3   rI   ~  s   ,


rI   c                   @   s,   e Zd ZdZdd„ Zedd„ ƒZdd„ ZdS )	rJ   a2  
    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 erf2inv, oo
    >>> 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] https://functions.wolfram.com/GammaBetaErf/InverseErf2/

    c                 C   sf   | j \}}|dkr.t|  ||¡d |d  ƒS |dkrXttƒtj t|  ||¡d ƒ S t| |ƒ‚d S )Nr6   r&   )r'   r   r,   r   r	   r   rk   r   rÆ   r2   r2   r3   r;     s    
"zerf2inv.fdiffc                 C   s¾   |t jks|t jkrt jS |jr,|jr,t jS |jrB|t jkrBt jS |t jkrX|jrXt jS |jrft|ƒS |t jkrzt| ƒS |jr„|S |t jkr–t|ƒS |jr°|jr¨t jS t|ƒS |jrº|S d S rp   )r   rB   rG   r*   rD   rC   r>   rI   )rN   r0   r1   r2   r2   r3   rQ     s,    


zerf2inv.evalc                 C   s   | j \}}|jr|jrdS d S )NTrd   )r-   r0   r1   r2   r2   r3   re   (  s    
zerf2inv._eval_is_zeroN)r°   r±   r²   r³   r;   rµ   rQ   re   r2   r2   r2   r3   rJ   Ð  s
   3	
rJ   c                       s˜   e Zd ZdZedd„ ƒZddd„Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
dd„ ZeZeZeZddd„Zdd„ Zd‡ fdd„	Zd ‡ fdd„	Z‡ fdd„Z‡  ZS )!ÚEia	  
    The classical exponential integral.

    Explanation
    ===========

    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 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.
    uppergamma: Upper incomplete gamma function.

    References
    ==========

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

    c                 C   sd   |j rtjS |tjkrtjS |tjkr,tjS |j r8tjS | ¡ \}}|r`t|ƒdt t |  S d S r€   )	rG   r   rE   rC   r*   Úextract_branch_factorrÓ   r   r	   ©rN   rm   rÂ   rV   r2   r2   r3   rQ   ‰  s    

zEi.evalr6   c                 C   s0   t | jd ƒ}|dkr"t|ƒ| S t| |ƒ‚d S r@   )r   r'   r   r   ©r-   r:   rO   r2   r2   r3   r;   ™  s    zEi.fdiffc                 C   s:   | j d tdƒ jr.t | |¡tt  |¡ S t | |¡S rÍ   )r'   r   r¥   r   Ú_eval_evalfr   r	   ©r-   Úprecr2   r2   r3   r×      s    zEi._eval_evalfc                 K   s(   ddl m} |dtdƒ| ƒ tt  S )Nr   rg   rx   )rj   rh   r   r   r	   rl   r2   r2   r3   ro   ¥  s    zEi._eval_rewrite_as_uppergammac                 K   s   t dtdƒ| ƒ tt  S )Nr6   rx   )r‚   r   r   r	   rz   r2   r2   r3   rƒ   «  s    zEi._eval_rewrite_as_expintc                 K   s$   t |tƒrt|jd ƒS tt|ƒƒS rZ   )rH   r   Úlir'   r   rz   r2   r2   r3   Ú_eval_rewrite_as_li®  s    
zEi._eval_rewrite_as_lic                 K   s2   |j rt|ƒt|ƒ tt  S t|ƒt|ƒ S d S rp   )Úis_negativeÚShiÚChir   r	   rz   r2   r2   r3   Ú_eval_rewrite_as_Si·  s    zEi._eval_rewrite_as_SiNc                 K   s   t |ƒt|ƒ S rp   )r   Ú_eisr½   r2   r2   r3   r‡   À  s    zEi._eval_rewrite_as_tractablec                 K   s:   ddl m} ttd|gƒjƒ}|tj| | |tj|fƒS ©Nr   ©ÚIntegralrP   )Úsympy.integrals.integralsrã   r   r   Únamer   ZExp1rE   ©r-   rm   rn   rã   rP   r2   r2   r3   Ú_eval_rewrite_as_IntegralÃ  s    zEi._eval_rewrite_as_Integralr   c           	         s¤   ddl m} | jd  |d¡}| jd j||d�}| ||¡}|jr’| |¡\}}|d krbt|ƒn|}t|ƒ||  t	 ||ƒj
rŠtt ntj S tƒ j|||d�S )Nr   )r   )r�   r�   )Zsympyr   r'   r„   r”   r“   rG   Úas_coeff_exponentr   r   rÜ   r   r	   r   r*   r§   rš   )	r-   r0   rŽ   r�   r   Úx0rO   ÚcÚer®   r2   r3   rš   È  s    ÿzEi._eval_as_leading_termc                    sB   | j d  |d¡}|jr2| j| j Ž }| |||¡S tƒ  |||¡S rZ   )r'   r„   rG   rß   Ú_eval_nseriesr§   ©r-   r0   rV   rŽ   r�   ré   Úfr®   r2   r3   rì   Ô  s
    zEi._eval_nseriesc                    s|   ddl m} |d }|tjkrf| jd ‰ ‡ fdd„t|ƒD ƒ|dˆ |  |ƒg }tˆ ƒˆ  t|Ž  S tt	| ƒ 
||||¡S )Nr   r›   c                    s   g | ]}t |ƒˆ |  ‘qS r2   ©r   rž   r    r2   r3   r¡   á  s     z$Ei._eval_aseries.<locals>.<listcomp>r6   )r¢   rœ   r   rC   r'   r¦   r   r   r§   rÓ   r¨   rÄ   r®   r    r3   r¨   Û  s    

ÿzEi._eval_aseries)r6   )N)Nr   )r   )r°   r±   r²   r³   rµ   rQ   r;   r×   ro   rƒ   rÛ   rß   Ú_eval_rewrite_as_CiÚ_eval_rewrite_as_ChiÚ_eval_rewrite_as_Shir‡   rç   rš   rì   r¨   r·   r2   r2   r®   r3   rÓ   1  s"   W

	
rÓ   c                       sv   e Zd ZdZedd„ ƒZdd„ Zdd„ Zdd	„ Zd
d„ Z	dd„ Z
e
Ze
Ze
Zd‡ fdd„	Z‡ fdd„Zdd„ Z‡  ZS )r‚   a£  
    Generalized exponential integral.

    Explanation
    ===========

    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 $z$ with positive real part we have

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

    which explains the name.

    The representation as an incomplete gamma function provides an analytic
    continuation for $\operatorname{E}_\nu(z)$. If $\nu$ is a
    non-positive integer, the exponential integral is thus an unbranched
    function of $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$ further
    explains 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.
    uppergamma

    References
    ==========

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

    c                 C   s  ddl m}m} t|ƒ}||kr*t||ƒS |jr8|dksH|jsjd| jrjtt||d  |d| |ƒ ƒƒS | ¡ \}}|tj	kr„d S |j
rÚ|dks–d S t||ƒdt t | tj|d   t|d ƒ t|ƒ|d    S tdt t | | ƒd ||d   |d| ƒ t||ƒ S d S )Nr   )Úgammarh   r&   r6   )rj   ró   rh   r   r‚   Ú
is_Integerr   rÔ   r   r*   Ú
is_integerr	   r   rF   r   r   )rN   Únurm   ró   rh   Znu2rV   r2   r2   r3   rQ   P  s     
"
8ÿzexpint.evalc                 C   sd   | j \}}|dkr>||d   tg ddgddd| gg |ƒ S |dkrVt|d |ƒ S t| |ƒ‚d S rË   )r'   r$   r‚   r   )r-   r:   rö   rm   r2   r2   r3   r;   f  s    
,zexpint.fdiffc                 K   s&   ddl m} ||d  |d| |ƒ S )Nr   rg   r6   )rj   rh   )r-   rö   rm   rn   rh   r2   r2   r3   ro   o  s    z"expint._eval_rewrite_as_uppergammac                    s¢   ˆ dkr(t |tt t ƒ ƒ tt  S ˆ jršˆ dkršt|ƒ ‰ˆˆ d  tˆ d ƒ t|ƒ t ¡ t	ˆƒtˆ d ƒ t
‡ ‡fdd„tˆ d ƒD ƒŽ   S | S d S )Nr6   c                    s$   g | ]}t ˆ | d  ƒˆ|  ‘qS ©r&   rï   rž   ©rö   r0   r2   r3   r¡   {  s     z.expint._eval_rewrite_as_Ei.<locals>.<listcomp>)rÓ   r   r   r	   rô   r   r   ÚE1r¼   r   r   r¦   ©r-   rö   rm   rn   r2   rø   r3   Ú_eval_rewrite_as_Eis  s     
$ÿÿzexpint._eval_rewrite_as_Eic                 K   s   |   t¡j tf|ŽS rp   )r¼   rÓ   r‚   r¿   r2   r2   r3   rÀ     s    zexpint._eval_expand_funcc                 K   s   |dkr| S t |ƒt|ƒ S rÎ   )rÝ   rÞ   rú   r2   r2   r3   rß   ‚  s    zexpint._eval_rewrite_as_Sir   c                    st   | j d  |¡sd| j d }|dkr<| j| j Ž }| |||¡S |jrd|dkrd| j| j Ž }| |||¡S tƒ  |||¡S r@   )r'   Úhasrß   rì   rô   rû   r§   )r-   r0   rV   rŽ   r�   rö   rî   r®   r2   r3   rì   Š  s    
zexpint._eval_nseriesc                    sŠ   ddl m} |d }| jd ‰ |tjkrt| jd ‰‡ ‡fdd„t|ƒD ƒ|dˆ|  |ƒg }tˆ ƒˆ t|Ž  S tt	| ƒ 
||||¡S )Nr   r›   r6   c                    s(   g | ] }t j| tˆ |ƒ ˆ|  ‘qS r2   )r   rF   r   rž   ©rö   rm   r2   r3   r¡   œ  s     z(expint._eval_aseries.<locals>.<listcomp>)r¢   rœ   r'   r   rC   r¦   r   r   r§   r‚   r¨   rÄ   r®   rý   r3   r¨   •  s    


,zexpint._eval_aseriesc                 O   sL   ddl m} | j\}}ttd|ƒjƒ}|||  t| | ƒ |dtjfƒS ©Nr   râ   rP   r6   )	rä   rã   r'   r   r   rå   r   r   rC   )r-   r'   rn   rã   rV   r0   rP   r2   r2   r3   rç   ¡  s    
z expint._eval_rewrite_as_Integral)r   )r°   r±   r²   r³   rµ   rQ   r;   ro   rû   rÀ   rß   rð   rñ   rò   rì   r¨   rç   r·   r2   r2   r®   r3   r‚   è  s   g
	r‚   c                 C   s
   t d| ƒS )a+  
    Classical case of the generalized exponential integral.

    Explanation
    ===========

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

    Examples
    ========

    >>> from sympy import E1
    >>> E1(0)
    expint(1, 0)

    >>> E1(5)
    expint(1, 5)

    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.

    r6   )r‚   r    r2   r2   r3   rù   ¨  s     rù   c                   @   sŠ   e Zd ZdZedd„ ƒZddd„Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
dd„ ZeZdd„ ZeZdd„ Zdd„ Zd dd„Zd!dd„Zdd„ ZdS )"rÚ   aà	  
    The classical logarithmic integral.

    Explanation
    ===========

    For 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:
    >>> from sympy import integrate
    >>> integrate(li(z))
    z*li(z) - Ei(2*log(z))

    >>> integrate(li(z),z)
    z*li(z) - Ei(2*log(z))


    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] https://mathworld.wolfram.com/LogarithmicIntegral.html
    .. [3] https://dlmf.nist.gov/6
    .. [4] https://mathworld.wolfram.com/SoldnersConstant.html

    c                 C   s<   |j rtjS |tjkrtjS |tjkr,tjS |j r8tjS d S rp   )rG   r   r*   rD   rE   rC   rÐ   r2   r2   r3   rQ   /  s    

zli.evalr6   c                 C   s.   | j d }|dkr tjt|ƒ S t| |ƒ‚d S r@   ©r'   r   rD   r   r   rÖ   r2   r2   r3   r;   :  s    
zli.fdiffc                 C   s"   | j d }|js|  | ¡ ¡S d S rZ   )r'   Zis_extended_negativer,   r\   ©r-   rm   r2   r2   r3   r^   A  s    
zli._eval_conjugatec                 K   s   t |ƒtdƒ S r€   )ÚLirÚ   rz   r2   r2   r3   Ú_eval_rewrite_as_LiG  s    zli._eval_rewrite_as_Lic                 K   s   t t|ƒƒS rp   )rÓ   r   rz   r2   r2   r3   rû   J  s    zli._eval_rewrite_as_Eic                 K   sP   ddl m} |dt|ƒ ƒ tjtt|ƒƒttjt|ƒ ƒ   tt|ƒ ƒ S ©Nr   rg   )rj   rh   r   r   rk   rD   rl   r2   r2   r3   ro   M  s    "ÿÿzli._eval_rewrite_as_uppergammac                 K   sX   t tt|ƒ ƒtttt|ƒ ƒ  tjttjt|ƒ ƒtt|ƒƒ   ttt|ƒ ƒ S rp   )ÚCir   r   ÚSir   rk   rD   rz   r2   r2   r3   rß   R  s
    ""ÿÿzli._eval_rewrite_as_Sic                 K   s<   t t|ƒƒtt|ƒƒ tjttjt|ƒ ƒtt|ƒƒ   S rp   )rÞ   r   rÝ   r   rk   rD   rz   r2   r2   r3   rò   X  s    zli._eval_rewrite_as_Shic                 K   s@   t |ƒtddt |ƒƒ tjt t |ƒƒt tjt |ƒ ƒ   t S )N)r6   r6   )r&   r&   )r   r#   r   rk   rD   r   rz   r2   r2   r3   r   ]  s
    "ÿÿzli._eval_rewrite_as_hyperc                 K   sF   t t |ƒ ƒ tjt tjt |ƒ ƒt t |ƒƒ   tddt |ƒ ƒ S )N)r2   ©r6   ))r   r   r2   )r   r   rk   rD   r$   rz   r2   r2   r3   r{   a  s    2ÿzli._eval_rewrite_as_meijergNc                 K   s   |t t|ƒƒ S rp   )rà   r   r½   r2   r2   r3   r‡   e  s    zli._eval_rewrite_as_tractabler   c                    s:   | j d ‰ ‡ fdd„td|ƒD ƒ}tttˆ ƒƒ t|Ž  S )Nr   c                    s$   g | ]}t ˆ ƒ| t|ƒ|  ‘qS r2   )r   r   rž   r    r2   r3   r¡   j  s     z$li._eval_nseries.<locals>.<listcomp>r6   )r'   r¦   r   r   r   )r-   r0   rV   rŽ   r�   r­   r2   r    r3   rì   h  s    
zli._eval_nseriesc                 C   s   | j d }|jrdS d S ra   rd   r   r2   r2   r3   re   m  s    
zli._eval_is_zero)r6   )N)r   )r°   r±   r²   r³   rµ   rQ   r;   r^   r  rû   ro   rß   rð   rò   rñ   r   r{   r‡   rì   re   r2   r2   r2   r3   rÚ   Ë  s"   c




rÚ   c                   @   sJ   e Zd ZdZedd„ ƒZddd„Zdd„ Zd	d
„ Zddd„Z	ddd„Z
dS )r  ab  
    The offset logarithmic integral.

    Explanation
    ===========

    For use in SymPy, this function is defined as

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

    Examples
    ========

    >>> from sympy import 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] https://mathworld.wolfram.com/LogarithmicIntegral.html
    .. [3] https://dlmf.nist.gov/6

    c                 C   s&   |t jkrt jS |t dƒkr"t jS d S r€   )r   rC   r*   rÐ   r2   r2   r3   rQ   ³  s    
zLi.evalr6   c                 C   s.   | j d }|dkr tjt|ƒ S t| |ƒ‚d S r@   rÿ   rÖ   r2   r2   r3   r;   º  s    
zLi.fdiffc                 C   s   |   t¡ |¡S rp   )r¼   rÚ   ZevalfrØ   r2   r2   r3   r×   Á  s    zLi._eval_evalfc                 K   s   t |ƒt dƒ S r€   )rÚ   rz   r2   r2   r3   rÛ   Ä  s    zLi._eval_rewrite_as_liNc                 K   s   |   t¡j ddd�S )Nrº   T)r.   )r¼   rÚ   r½   r2   r2   r3   r‡   Ç  s    zLi._eval_rewrite_as_tractabler   c                 C   s   | j | jŽ }| |||¡S rp   )rÛ   r'   rì   )r-   r0   rV   rŽ   r�   rî   r2   r2   r3   rì   Ê  s    zLi._eval_nseries)r6   )N)r   )r°   r±   r²   r³   rµ   rQ   r;   r×   rÛ   r‡   rì   r2   r2   r2   r3   r  r  s   @


r  c                       sH   e Zd ZdZedd„ ƒZddd„Zdd„ Zd	d
„ Zd‡ fdd„	Z	‡  Z
S )ÚTrigonometricIntegralz) Base class for trigonometric integrals. c                 C   s,  |t jkr| jS |t jkr"|  ¡ S |t jkr4|  ¡ S |jr@| jS | t	t
ƒ¡}|d krn|  d¡dkrn| t
¡}|d k	r‚|  |d¡S | t	t
 ƒ¡}|d k	r¦|  |d¡S | t	dƒ¡}|d krÔ|  d¡dkrÔ| d¡}|d k	ræ|  |¡S | ¡ \}}|dk�r
||k�r
d S dt t
 | |  d¡ | |ƒ S )Nr   r6   rx   r&   )r   r*   Ú_atzerorC   Ú_atinfrE   Ú	_atneginfrG   rK   r   r   Ú	_trigfuncÚ_IfactorÚ_minusfactorrÔ   r	   rÕ   r2   r2   r3   rQ   Ö  s2    





zTrigonometricIntegral.evalr6   c                 C   s2   t | jd ƒ}|dkr$|  |¡| S t| |ƒ‚d S r@   )r   r'   r  r   rÖ   r2   r2   r3   r;   ö  s    zTrigonometricIntegral.fdiffc                 K   s   |   |¡ t¡S rp   )rƒ   r¼   rÓ   rz   r2   r2   r3   rû   ý  s    z)TrigonometricIntegral._eval_rewrite_as_Eic                 K   s   ddl m} |  |¡ |¡S r  )rj   rh   rƒ   r¼   rl   r2   r2   r3   ro      s    z1TrigonometricIntegral._eval_rewrite_as_uppergammar   c                    sž   | j d  |d¡dkr&tƒ  |||¡S |  |¡ |||¡}|  d¡dkrP|d8 }|jtdd„ dd�}|  d¡dkr‚|tt|ƒ 7 }| || j d ¡ |||¡S )Nr   r6   c                 S   s   | | | S rp   r2   )rP   rV   r2   r2   r3   Ú<lambda>  ó    z5TrigonometricIntegral._eval_nseries.<locals>.<lambda>F)Zsimultaneous)	r'   r•   r§   rì   r  Úreplacer   r   r   )r-   r0   rV   rŽ   r�   Z
baseseriesr®   r2   r3   rì     s    z#TrigonometricIntegral._eval_nseries)r6   )r   )r°   r±   r²   r³   rµ   rQ   r;   rû   ro   rì   r·   r2   r2   r®   r3   r  Ò  s   

r  c                       s€   e Zd ZdZeZejZe	dd„ ƒZ
e	dd„ ƒZe	dd„ ƒZe	dd	„ ƒZd
d„ Zdd„ ZeZddd„Z‡ fdd„Zdd„ Z‡  ZS )r  aø  
    Sine integral.

    Explanation
    ===========

    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

    c                 C   s
   t tj S rp   ©r	   r   rk   ©rN   r2   r2   r3   r	  [  s    z	Si._atinfc                 C   s   t  tj S rp   r  r  r2   r2   r3   r
  _  s    zSi._atneginfc                 C   s
   t |ƒ S rp   )r  rÐ   r2   r2   r3   r  c  s    zSi._minusfactorc                 C   s   t t|ƒ | S rp   )r   rÝ   ©rN   rm   Úsignr2   r2   r3   r  g  s    zSi._Ifactorc                 K   s2   t d tttƒ| ƒttt ƒ| ƒ d t  S r€   )r	   rù   r   r   rz   r2   r2   r3   rƒ   k  s    zSi._eval_rewrite_as_expintc                 K   s2   ddl m} ttd|gƒjƒ}|t|ƒ|d|fƒS rá   )rä   rã   r   r   rå   r"   ræ   r2   r2   r3   rç   o  s    zSi._eval_rewrite_as_IntegralNr   c                 C   sl   | j d j|||d�}| |d¡}|tjkrJ|j|dt|ƒjrBdndd�}|jrT|S |j	sd|  
|¡S | S d S ©Nr   r�   r�   r‘   r’   ©r'   r”   r•   r   rB   r„   r   rÜ   rG   rÇ   r,   r˜   r2   r2   r3   rš   v  s    

zSi._eval_as_leading_termc           	         sÆ   ddl m} |d }|tjkr°| jd ‰ ‡ fdd„t|d d ƒD ƒ|dˆ |  |ƒg }‡ fdd„t|d ƒD ƒ|dˆ |  |ƒg }td tˆ ƒt|Ž   t	ˆ ƒt|Ž   S t
t| ƒ ||||¡S )Nr   r›   c                    s2   g | ]*}t j| td | ƒ ˆ d | d   ‘qS r�   ©r   rF   r   rž   r    r2   r3   r¡   Š  s   ÿz$Si._eval_aseries.<locals>.<listcomp>r&   r6   c                    s6   g | ].}t j| td | d ƒ ˆ d |d    ‘qS r�   r  rž   r    r2   r3   r¡   Œ  s   ÿ)r¢   rœ   r   rC   r'   r¦   r	   r    r   r!   r§   r  r¨   )	r-   rV   r©   r0   rŽ   rœ   rª   ÚpÚqr®   r    r3   r¨   ƒ  s     


ÿÿ

ÿÿ(zSi._eval_aseriesc                 C   s   | j d }|jrdS d S ra   rd   r   r2   r2   r3   re   “  s    
zSi._eval_is_zero)Nr   )r°   r±   r²   r³   r!   r  r   r*   r  rµ   r	  r
  r  r  rƒ   rç   Z_eval_rewrite_as_sincrš   r¨   re   r·   r2   r2   r®   r3   r    s"   F




r  c                       st   e Zd ZdZeZejZe	dd„ ƒZ
e	dd„ ƒZe	dd„ ƒZe	dd	„ ƒZd
d„ Zdd„ Zddd„Z‡ fdd„Z‡  ZS )r  aâ  
    Cosine integral.

    Explanation
    ===========

    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 rp   )r   r*   r  r2   r2   r3   r	  ì  s    z	Ci._atinfc                 C   s   t t S rp   )r   r	   r  r2   r2   r3   r
  ð  s    zCi._atneginfc                 C   s   t |ƒtt  S rp   ©r  r   r	   rÐ   r2   r2   r3   r  ô  s    zCi._minusfactorc                 C   s   t |ƒtt d |  S r€   ©rÞ   r   r	   r  r2   r2   r3   r  ø  s    zCi._Ifactorc                 K   s(   t ttƒ| ƒt tt ƒ| ƒ  d S r€   )rù   r   r   rz   r2   r2   r3   rƒ   ü  s    zCi._eval_rewrite_as_expintc                 K   sH   ddl m} ttd|gƒjƒ}tjt|ƒ |dt|ƒ | |d|fƒ S rþ   )	rä   rã   r   r   rå   r   r   r   r    ræ   r2   r2   r3   rç   ÿ  s    zCi._eval_rewrite_as_IntegralNr   c                 C   sž   | j d j|||d�}| |d¡}|tjkrJ|j|dt|ƒjrBdndd�}|jr†| 	|¡\}}|d krnt
|ƒn|}t
|ƒ||  t S |jr–|  |¡S | S d S r  ©r'   r”   r•   r   rB   r„   r   rÜ   rG   rè   r   r   rb   r,   ©r-   r0   rŽ   r�   rO   r™   rê   rë   r2   r2   r3   rš     s    

zCi._eval_as_leading_termc           
         sÞ   ddl m} |d }|tjtjfkrÈ| jd ‰ ‡ fdd„t|d d ƒD ƒ|dˆ |  |ƒg }‡ fdd„t|d ƒD ƒ|dˆ |  |ƒg }tˆ ƒt|Ž  t	ˆ ƒt|Ž   }	|tjkrÄ|	t
t 7 }	|	S tt| ƒ ||||¡S )Nr   r›   c                    s2   g | ]*}t j| td | ƒ ˆ d | d   ‘qS r�   r  rž   r    r2   r3   r¡     s   ÿz$Ci._eval_aseries.<locals>.<listcomp>r&   r6   c                    s6   g | ].}t j| td | d ƒ ˆ d |d    ‘qS r�   r  rž   r    r2   r3   r¡     s   ÿ)r¢   rœ   r   rC   rE   r'   r¦   r!   r   r    r   r	   r§   r  r¨   )
r-   rV   r©   r0   rŽ   rœ   rª   r  r  Úresultr®   r    r3   r¨     s&    

ÿÿ

ÿÿ 
zCi._eval_aseries)Nr   )r°   r±   r²   r³   r    r  r   r–   r  rµ   r	  r
  r  r  rƒ   rç   rš   r¨   r·   r2   r2   r®   r3   r  ™  s   O




r  c                   @   sd   e Zd ZdZeZejZe	dd„ ƒZ
e	dd„ ƒZe	dd„ ƒZe	dd	„ ƒZd
d„ Zdd„ Zddd„ZdS )rÝ   a  
    Sinh integral.

    Explanation
    ===========

    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

    c                 C   s   t jS rp   ©r   rC   r  r2   r2   r3   r	  h  s    z
Shi._atinfc                 C   s   t jS rp   )r   rE   r  r2   r2   r3   r
  l  s    zShi._atneginfc                 C   s
   t |ƒ S rp   )rÝ   rÐ   r2   r2   r3   r  p  s    zShi._minusfactorc                 C   s   t t|ƒ | S rp   )r   r  r  r2   r2   r3   r  t  s    zShi._Ifactorc                 K   s,   t |ƒt ttt ƒ| ƒ d tt d  S r€   )rù   r   r   r	   rz   r2   r2   r3   rƒ   x  s    zShi._eval_rewrite_as_expintc                 C   s   | j d }|jrdS d S ra   rd   r   r2   r2   r3   re   |  s    
zShi._eval_is_zeroNr   c                 C   sf   | j d  |¡}| |d¡}|tjkrD|j|dt|ƒjr<dndd�}|jrN|S |j	s^|  
|¡S | S d S )Nr   r�   r‘   r’   r  r˜   r2   r2   r3   rš   �  s    

zShi._eval_as_leading_term)Nr   )r°   r±   r²   r³   r   r  r   r*   r  rµ   r	  r
  r  r  rƒ   re   rš   r2   r2   r2   r3   rÝ   %  s   ?



rÝ   c                   @   s\   e Zd ZdZeZejZe	dd„ ƒZ
e	dd„ ƒZe	dd„ ƒZe	dd	„ ƒZd
d„ Zddd„ZdS )rÞ   a   
    Cosh integral.

    Explanation
    ===========

    This function is defined for positive $x$ by

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

    where $\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 $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 rp   r  r  r2   r2   r3   r	  Ý  s    z
Chi._atinfc                 C   s   t jS rp   r  r  r2   r2   r3   r
  á  s    zChi._atneginfc                 C   s   t |ƒtt  S rp   r  rÐ   r2   r2   r3   r  å  s    zChi._minusfactorc                 C   s   t |ƒtt d |  S r€   r  r  r2   r2   r3   r  é  s    zChi._Ifactorc                 K   s.   t  t d t|ƒttt t ƒ| ƒ d  S r€   )r   r	   rù   r   rz   r2   r2   r3   rƒ   í  s    zChi._eval_rewrite_as_expintNr   c                 C   sž   | j d j|||d�}| |d¡}|tjkrJ|j|dt|ƒjrBdndd�}|jr†| 	|¡\}}|d krnt
|ƒn|}t
|ƒ||  t S |jr–|  |¡S | S d S r  r  r  r2   r2   r3   rš   ð  s    

zChi._eval_as_leading_term)Nr   )r°   r±   r²   r³   r   r  r   r–   r  rµ   r	  r
  r  r  rƒ   rš   r2   r2   r2   r3   rÞ   �  s   J



rÞ   c                   @   sJ   e Zd ZdZdZedd„ ƒZddd„Zdd	„ ZeZ	d
d„ Z
dd„ ZeZdS )ÚFresnelIntegralz& Base class for the Fresnel integrals.Tc                 C   s†   |t jkrt jS |jrt jS t j}|}d}| d¡}|d k	rJ| }|}d}| t¡}|d k	rr| jt | }|}d}|r‚|| |ƒ S d S )NFrx   T)	r   rC   rk   rG   r*   rD   rK   r   Ú_sign)rN   rm   ZprefactZnewargÚchangedrÂ   r2   r2   r3   rQ   		  s&    


zFresnelIntegral.evalr6   c                 C   s4   |dkr&|   tjt | jd d  ¡S t| |ƒ‚d S rË   )r  r   rk   r	   r'   r   r9   r2   r2   r3   r;   (	  s    zFresnelIntegral.fdiffc                 C   s   | j d jS rZ   r_   r]   r2   r2   r3   rÃ   .	  s    z&FresnelIntegral._eval_is_extended_realc                 C   s   | j d jS rZ   rd   r]   r2   r2   r3   re   3	  s    zFresnelIntegral._eval_is_zeroc                 C   s   |   | jd  ¡ ¡S rZ   r[   r]   r2   r2   r3   r^   6	  s    zFresnelIntegral._eval_conjugateN)r6   )r°   r±   r²   r³   r´   rµ   rQ   r;   rÃ   rc   re   r^   r4   r+   r2   r2   r2   r3   r   	  s   

r   c                       sf   e Zd ZdZeZej Ze	e
dd„ ƒƒZdd„ Zdd„ Zdd	„ Zd
d„ Zddd„Z‡ fdd„Z‡  ZS )rs   ay  
    Fresnel integral S.

    Explanation
    ===========

    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, 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] https://dlmf.nist.gov/7
    .. [3] https://mathworld.wolfram.com/FresnelIntegrals.html
    .. [4] https://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S t|ƒ}t|ƒdkrl|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 ƒ  S d S )	Nr   r6   rx   r&   é   é   r}   rS   ©r   r*   r   rT   r	   r   ©rV   r0   rW   r  r2   r2   r3   rY   ”	  s    Bzfresnels.taylor_termc                 K   sN   t jt d tt jt d ttƒ | ƒttt jt d ttƒ | ƒ   S ©Nr#  r&   ©r   rD   r   r5   r   r	   rz   r2   r2   r3   r¾   ¡	  s    zfresnels._eval_rewrite_as_erfc                 K   sF   t |d  d ttddƒgtddƒtddƒgt d  |d  d ƒ S )Nr}   é   r#  r&   é   é   )r	   r#   r
   rz   r2   r2   r3   r   ¤	  s    zfresnels._eval_rewrite_as_hyperc              	   K   sr   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 )Né	   r#  r&   r}   r6   r   r+  )r	   r
   r   r$   rz   r2   r2   r3   r{   §	  s    :4ÿz!fresnels._eval_rewrite_as_meijergc                 K   s>   ddl m} ttd|gƒjƒ}|tt|d  d ƒ|d|fƒS ©Nr   râ   rP   r&   )rä   rã   r   r   rå   r!   r	   ræ   r2   r2   r3   rç   «	  s    z"fresnels._eval_rewrite_as_IntegralNr   c                 C   s°   ddl m} | jd j|||d�}| |d¡}|tjkrV|j|dt|ƒj	rNdndd�}|j
rlt|d  d S |tjtjfkr¢|tjkrŠd	nd
}|tj |||ƒ S |  |¡S d S )Nr   r›   r�   r�   r‘   r’   r}   r)  r6   rx   )r¢   rœ   r'   r”   r•   r   r–   r„   r   rÜ   rG   r	   rC   rE   rk   r,   ©r-   r0   rŽ   r�   rœ   rO   r™   r­   r2   r2   r3   rš   °	  s    
zfresnels._eval_as_leading_termc           
         s
  ddl m} |d }|tjtj fkrø| jd ‰‡ ‡fdd„tdˆ ƒD ƒ}ddˆ  g‡ ‡fdd„tdˆ ƒD ƒ }dd„ |D ƒ}d	d„ |D ƒ}|tjkrœdnd
}	|	tj tˆd ƒt|Ž  t	ˆd ƒt|Ž    
|tdt ƒ| ¡ |dˆˆ   |ƒ S tƒ  ˆ |||¡S )Nr   r›   c                    sn   g | ]f}d | d ˆ k rt j| td | d ƒ dd| d  ˆd | d   dd|   td| ƒ  ‘qS ©r#  r}   r6   r&   r  rž   ©rV   rm   r2   r3   r¡   É	  s
    þ6ÿz*fresnels._eval_aseries.<locals>.<listcomp>r6   r&   c                    sv   g | ]n}d | d ˆ k rt j| td | d ƒ dd| d  ˆd | d   dd| d   td| d ƒ  ‘qS ©r#  r6   r&   r  rž   r0  r2   r3   r¡   Ì	  s
    þ>ÿc                 S   s   g | ]}t d t ƒ | ‘qS r÷   ©r   r	   ©rŸ   rP   r2   r2   r3   r¡   Ð	  s     c                 S   s   g | ]}t d t ƒ | ‘qS r÷   r2  r3  r2   r2   r3   r¡   Ñ	  s     rx   )r¢   rœ   r   rC   r'   r¦   rk   r!   r   r    r•   r   r	   r§   r¨   ©
r-   rV   r©   r0   rŽ   rœ   rª   r  r  r­   r®   r0  r3   r¨   ¿	  s(    
þþ0 ÿÿzfresnels._eval_aseries)Nr   )r°   r±   r²   r³   r!   r  r   rD   r!  r¶   r   rY   r¾   r   r{   rç   rš   r¨   r·   r2   r2   r®   r3   rs   <	  s   T
rs   c                       sd   e Zd ZdZeZejZe	e
dd„ ƒƒZdd„ Zdd„ Zdd	„ Zd
d„ Zddd„Z‡ fdd„Z‡  ZS )rr   au  
    Fresnel integral C.

    Explanation
    ===========

    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, 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] https://dlmf.nist.gov/7
    .. [3] https://mathworld.wolfram.com/FresnelIntegrals.html
    .. [4] https://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S t|ƒ}t|ƒdkrl|d }td  |d  d|  d  d|  d|  d  d|  d   | S ||d  |   t dƒd|   td|     d|  d td|  ƒ  S d S )	Nr   r6   rx   r&   r#  r}   r$  rS   r%  r&  r2   r2   r3   rY   5
  s    Bzfresnelc.taylor_termc                 K   sN   t jt d tt jt d ttƒ | ƒttt jt d ttƒ | ƒ   S r'  r(  rz   r2   r2   r3   r¾   B
  s    zfresnelc._eval_rewrite_as_erfc                 K   s6   |t tddƒgtjtddƒgtd  |d  d ƒ S )Nr6   r#  é   r&   r+  )r#   r
   r   rk   r	   rz   r2   r2   r3   r   E
  s    zfresnelc._eval_rewrite_as_hyperc              	   K   sj   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 )Nr}   r#  r&   r6   r   r+  )r	   r
   r   r   r$   rz   r2   r2   r3   r{   H
  s    24ÿz!fresnelc._eval_rewrite_as_meijergc                 K   s>   ddl m} ttd|gƒjƒ}|tt|d  d ƒ|d|fƒS r-  )rä   rã   r   r   rå   r    r	   ræ   r2   r2   r3   rç   L
  s    z"fresnelc._eval_rewrite_as_IntegralNr   c                 C   s¤   ddl m} | jd j|||d�}| |d¡}|tjkrV|j|dt|ƒj	rNdndd�}|j
r`|S |tjtjfkr–|tjkr~dnd}|tj |||ƒ S |  |¡S d S )	Nr   r›   r�   r�   r‘   r’   r6   rx   )r¢   rœ   r'   r”   r•   r   r–   r„   r   rÜ   rG   rC   rE   rk   r,   r.  r2   r2   r3   rš   Q
  s    
zfresnelc._eval_as_leading_termc           
         s  ddl m} |d }|tjtj fkrö| jd ‰‡ ‡fdd„tˆ ƒD ƒ}ddˆ  g‡ ‡fdd„tdˆ ƒD ƒ }dd„ |D ƒ}d	d„ |D ƒ}|tjkršdnd
}	|	tj tˆd ƒt|Ž  t	ˆd ƒt|Ž    
|tdt ƒ| ¡ |dˆˆ   |ƒ S tƒ  ˆ |||¡S )Nr   r›   c                    sn   g | ]f}d | d ˆ k rt j| td | d ƒ dd| d  ˆd | d   dd|   td| ƒ  ‘qS r/  r  rž   r0  r2   r3   r¡   j
  s
    þ6ÿz*fresnelc._eval_aseries.<locals>.<listcomp>r6   r&   c                    sv   g | ]n}d | d ˆ k rt j| td | d ƒ dd| d  ˆd | d   dd| d   td| d ƒ  ‘qS r1  r  rž   r0  r2   r3   r¡   m
  s
    þ>ÿc                 S   s   g | ]}t d t ƒ | ‘qS r÷   r2  r3  r2   r2   r3   r¡   q
  s     c                 S   s   g | ]}t d t ƒ| ‘qS r÷   r2  r3  r2   r2   r3   r¡   r
  s     rx   )r¢   rœ   r   rC   r'   r¦   rk   r    r   r!   r•   r   r	   r§   r¨   r4  r®   r0  r3   r¨   `
  s(    
þþ0 ÿÿzfresnelc._eval_aseries)Nr   )r°   r±   r²   r³   r    r  r   rD   r!  r¶   r   rY   r¾   r   r{   rç   rš   r¨   r·   r2   r2   r®   r3   rr   Ý	  s   T
rr   c                       s>   e Zd ZdZedd„ ƒZ‡ fdd„Zddd„Zd	d
„ Z‡  Z	S )r…   zi
    Helper function to make the $\mathrm{erf}(z)$ function
    tractable for the Gruntz algorithm.

    c                 C   s   |j rtjS d S rp   )rG   r   rD   )rN   rO   r2   r2   r3   rQ   ‰
  s    z
_erfs.evalc           
         sä   ddl m} |d }|tjkrn| jd ‰ ‡ fdd„t|ƒD ƒ}|dˆ d| d   |ƒ}t|Ž  |||¡| S | t	¡}	|	tjkrÒ| jd ‰ ‡ fdd„t|ƒD ƒ}|dˆ d| d   |ƒ}t|Ž  |||¡| S t
ƒ  ||||¡S )Nr   r›   c                    sP   g | ]H}d t tƒ td| ƒ tdƒ |   t|ƒ d ˆ  d| d    ‘qS ©r6   r&   r#  ©r   r	   r   r   rž   r    r2   r3   r¡   •
  s   ÿÿÿÿÿz'_erfs._eval_aseries.<locals>.<listcomp>r6   r&   c                    sP   g | ]H}d t tƒ td| ƒ tdƒ |   t|ƒ d ˆ  d| d    ‘qS r6  r7  rž   r    r2   r3   r¡    
  s   ÿÿÿÿÿ)r¢   rœ   r   rC   r'   r¦   r   rì   rK   r   r§   r¨   )
r-   rV   r©   r0   rŽ   rœ   rª   ÚlÚorP   r®   r    r3   r¨   Ž
  s$    


ÿ



ÿz_erfs._eval_aseriesr6   c                 C   s<   |dkr.| j d }dttƒ d| t|ƒ  S t| |ƒ‚d S )Nr6   r   rS   r&   )r'   r   r	   r…   r   ©r-   r:   rm   r2   r2   r3   r;   ©
  s    
z_erfs.fdiffc                 K   s   t jt|ƒ t|d ƒ S r€   )r   rD   r5   r   rz   r2   r2   r3   Ú_eval_rewrite_as_intractable°
  s    z"_erfs._eval_rewrite_as_intractable)r6   )
r°   r±   r²   r³   rµ   rQ   r¨   r;   r;  r·   r2   r2   r®   r3   r…   ƒ
  s   

r…   c                       sN   e Zd ZdZ‡ fdd„Zddd„Zdd„ Zd‡ fdd„	Zd‡ fdd„	Z‡  Z	S )rà   z~
    Helper function to make the $\mathrm{Ei}(z)$ and $\mathrm{li}(z)$
    functions tractable for the Gruntz algorithm.

    c                    s|   ddl m} |d tjkr0tt| ƒ ||||¡S | jd ‰ ‡ fdd„t|ƒD ƒ}|dˆ |d   |ƒ}t	|Ž  
|||¡| S )Nr   r›   c                    s$   g | ]}t |ƒd ˆ  |d    ‘qS r  rï   rž   r    r2   r3   r¡   Â
  s     z&_eis._eval_aseries.<locals>.<listcomp>r6   )r¢   rœ   r   rC   r§   r…   r¨   r'   r¦   r   rì   )r-   rV   r©   r0   rŽ   rœ   r8  r9  r®   r    r3   r¨   ¼
  s    
z_eis._eval_aseriesr6   c                 C   s2   |dkr$| j d }tj| t|ƒ S t| |ƒ‚d S )Nr6   r   )r'   r   rD   rà   r   r:  r2   r2   r3   r;   È
  s    
z
_eis.fdiffc                 K   s   t | ƒt|ƒ S rp   )r   rÓ   rz   r2   r2   r3   r;  Ï
  s    z!_eis._eval_rewrite_as_intractableNr   c                    sF   | j d  |d¡}|jr4| j| j Ž }|j|||d�S tƒ j|||d�S )Nr   r�   )r'   r„   rG   r;  rš   r§   )r-   r0   rŽ   r�   ré   rî   r®   r2   r3   rš   Ò
  s
    z_eis._eval_as_leading_termc                    sB   | j d  |d¡}|jr2| j| j Ž }| |||¡S tƒ  |||¡S rZ   )r'   r„   rG   r;  rì   r§   rí   r®   r2   r3   rì   Ù
  s
    z_eis._eval_nseries)r6   )Nr   )r   )
r°   r±   r²   r³   r¨   r;   r;  rš   rì   r·   r2   r2   r®   r3   rà   ´
  s   
rà   N)T)Mr³   Z
sympy.corer   Zsympy.core.addr   Zsympy.core.cacher   Zsympy.core.functionr   r   r   Zsympy.core.numbersr   r	   r
   Zsympy.core.relationalr   Zsympy.core.powerr   Zsympy.core.singletonr   Zsympy.core.symbolr   r   Zsympy.core.sympifyr   Z(sympy.functions.combinatorial.factorialsr   r   r   Z$sympy.functions.elementary.complexesr   r   r   Z#sympy.functions.elementary.integersr   r   Z(sympy.functions.elementary.miscellaneousr   r   Z&sympy.functions.elementary.exponentialr   r   r   Z%sympy.functions.elementary.hyperbolicr   r   Z(sympy.functions.elementary.trigonometricr    r!   r"   Zsympy.functions.special.hyperr#   r$   r4   r5   rˆ   r‹   rÅ   r>   rI   rJ   rÓ   r‚   rù   rÚ   r  r  r  r  rÝ   rÞ   r   rs   rr   r…   rà   r2   r2   r2   r3   Ú<module>   sh   
 b @ A ]Ra 8 A# (`? 	 ju8 " '1