o
    à8Va,  ã                   @   s0   d Z ddlmZ ddlmZ edƒdd„ ƒZdS )zZ
This module implements the Residue function and related tools for working
with residues.
é    )Úsympify)ÚtimethisÚresiduec                 C   sô   ddl m}m}m}m} t| ƒ} |dkr|  ||| ¡} dD ]}| j||d}| |¡r2| 	¡ dkr4 nq|| 
¡ |ƒ}|jrC|j}	n|g}	|j}
|	D ],}| |¡\}}||Ž }|dksm||ksm|jrg|jjsmtd| ƒ‚|d| krw|
|7 }
qK|
S )a  
    Finds the residue of ``expr`` at the point x=x0.

    The residue is defined as the coefficient of ``1/(x-x0)`` in the power series
    expansion about ``x=x0``.

    Examples
    ========

    >>> from sympy import Symbol, residue, sin
    >>> x = Symbol("x")
    >>> residue(1/x, x, 0)
    1
    >>> residue(1/x**2, x, 0)
    0
    >>> residue(2/sin(x), x, 0)
    2

    This function is essential for the Residue Theorem [1].

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Residue_theorem
    r   )ÚcollectÚMulÚOrderÚS)r   é   é   é   é   é   é    )Únr	   zterm of unexpected form: %s)Úsympyr   r   r   r   r   ZsubsZnseriesZhasZgetnZremoveOZis_AddÚargsZZeroZas_coeff_mulZis_PowZexpZ
is_IntegerÚNotImplementedError)ÚexprÚxZx0r   r   r   r   r   Úsr   ÚresÚargÚcÚm© r   ú7/usr/lib/python3/dist-packages/sympy/series/residues.pyr   
   s.   'ÿ€N)Ú__doc__r   r   Zsympy.utilities.timeutilsr   r   r   r   r   r   Ú<module>   s
    