B
    e‹d¥  ã               @   sH   d Z ddlmZ ddlm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.
é    )ÚMul)ÚS)Úsympify)ÚtimethisÚresiduec             C   sø   ddl m} ddlm} t| ƒ} |dkr8|  ||| ¡} x2dD ]*}| j||d}| |¡rf| ¡ dkr>P q>W || 	¡ |ƒ}|j
rˆ|j}n|g}tj}x^|D ]V}	|	 |¡\}
}t|Ž }|tj|fksÜ|jrÐ|jjsÜtd| ƒ‚|d| krš||
7 }qšW |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   )ÚOrder)Úcollect)r   é   é   é   é   é   é    )Únzterm of unexpected form: %sr	   )Zsympy.series.orderr   Zsympy.simplify.radsimpr   r   ÚsubsZnseriesÚhasZgetnZremoveOZis_AddÚargsr   ZZeroZas_coeff_mulr   ZOneZis_PowÚexpZ
is_IntegerÚNotImplementedError)ÚexprÚxZx0r   r   r   Úsr   ÚresÚargÚcÚm© r   úb/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/sympy/series/residues.pyr      s,    '

N)
Ú__doc__Zsympy.core.mulr   Zsympy.core.singletonr   Zsympy.core.sympifyr   Zsympy.utilities.timeutilsr   r   r   r   r   r   Ú<module>   s
   