�
��g� � �b � d Z ddlmZ ddlmZ ddlmZ ddlmZ ed� � d� � � Z dS ) zZ
This module implements the Residue function and related tools for working
with residues.
� )�Mul)�S)�sympify)�timethis�residuec �Z � ddl m} ddlm} t | � � } |dk r| � |||z � � } dD ]H}| � ||�� � }|� |� � r|� � � dk r n�I ||� � � |� � }|j
r|j }n|g}t j
}|D ]f} | � |� � \ }
}t |� }|t j |fv s%|j r|j j st) d|z � � �|d|z k r||
z
}�g|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 � � � � � � )�nzterm of unexpected form: %sr )�sympy.series.orderr �sympy.simplify.radsimpr
r �subs�nseries�has�getn�removeO�is_Add�argsr �Zero�as_coeff_mulr �One�is_Pow�exp�
is_Integer�NotImplementedError)�expr�x�x0r r
r �sr �res�arg�c�ms �e/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/sympy/series/residues.pyr r s[ � �N )�(�(�(�(�(�.�.�.�.�.�.��4�=�=�D� �Q�w�w��y�y��A��F�#�#��
$� � ���L�L��a�L� � ���u�u�U�|�|� �q�v�v�x�x�1�}�}��E� -���� � ���Q���A��x� ��v����s��
�&�C�� � ������"�"���1���G���a�e�Q�Z���A�H����1A��%�&C�a�&G�H�H�H���!��8�8��1�H�C���J� N)
�__doc__�sympy.core.mulr �sympy.core.singletonr �sympy.core.sympifyr �sympy.utilities.timeutilsr r � r+ r* �<module>r2 s� ��� �
� � � � � � "� "� "� "� "� "� &� &� &� &� &� &� .� .� .� .� .� .�
��)���<� <� ��<� <� <r+