�
��g� � �( � d dl mZmZ d dlmZ d� ZdS )� )�SingularityFunction�
DiracDelta)� integratec � � | � t � � sdS t | t � � rK| j \ }}}|j s|j rt |||dz � � |dz z S |dv rt |||dz � � S | j s| j rD| � t � � }t ||� � }|� t � � S dS )aI
This function handles the indefinite integrations of Singularity functions.
The ``integrate`` function calls this function internally whenever an
instance of SingularityFunction is passed as argument.
Explanation
===========
The idea for integration is the following:
- If we are dealing with a SingularityFunction expression,
i.e. ``SingularityFunction(x, a, n)``, we just return
``SingularityFunction(x, a, n + 1)/(n + 1)`` if ``n >= 0`` and
``SingularityFunction(x, a, n + 1)`` if ``n < 0``.
- If the node is a multiplication or power node having a
SingularityFunction term we rewrite the whole expression in terms of
Heaviside and DiracDelta and then integrate the output. Lastly, we
rewrite the output of integration back in terms of SingularityFunction.
- If none of the above case arises, we return None.
Examples
========
>>> from sympy.integrals.singularityfunctions import singularityintegrate
>>> from sympy import SingularityFunction, symbols, Function
>>> x, a, n, y = symbols('x a n y')
>>> f = Function('f')
>>> singularityintegrate(SingularityFunction(x, a, 3), x)
SingularityFunction(x, a, 4)/4
>>> singularityintegrate(5*SingularityFunction(x, 5, -2), x)
5*SingularityFunction(x, 5, -1)
>>> singularityintegrate(6*SingularityFunction(x, 5, -1), x)
6*SingularityFunction(x, 5, 0)
>>> singularityintegrate(x*SingularityFunction(x, 0, -1), x)
0
>>> singularityintegrate(SingularityFunction(x, 1, -1) * f(x), x)
f(1)*SingularityFunction(x, 1, 0)
N� )��������������������)�hasr �
isinstance�args�is_positive�is_zero�is_Mul�is_Pow�rewriter r )�f�x�a�n�exprs �t/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/sympy/integrals/singularityfunctions.py�singularityintegrater s� � �V
�5�5�$�%�%� ��t��!�(�)�)� 4��&���1�a��=� 4�A�I� 4�&�q�!�Q��U�3�3�Q��U�;�;�
�"�
"�
"�&�q�!�Q��U�3�3�3��x� 1�1�8� 1��y�y��$�$����q�!�!���|�|�/�0�0�0��4� N)�sympy.functionsr r �sympy.integralsr r � r r �<module>r sH �� ;� ;� ;� ;� ;� ;� ;� ;� %� %� %� %� %� %�:� :� :� :� :r