o
    oh$                     @   s  d Z ddlmZ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mZmZ ddlmZ ddl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 m!Z!m"Z" ddl#m$Z$m%Z% ddl&m'Z'm(Z(m)Z)m*Z* ddl+m,Z, ddl-m.Z.m/Z/m0Z0 ddl1m2Z2 ddl3m4Z4m5Z5m6Z6m7Z7 ddl8m9Z9 ddl:m;Z; ddl<m=Z= ddl>m?Z? ddl@mAZAmBZB ddlCmDZD ddlEmFZFmGZGmHZHmIZImJZJ ddlKmLZL ddlMmNZNmOZO ddlPmQZQ ddlRmSZS ddlTmUZU G d d! d!eVZWG d"d# d#eZXd$d% ZYd&d' ZZeZd(Z[d)d* Z\e[e\d+fd,d-Z]G d.d/ d/eXZ^d0d1 Z_d2d3 Z`G d4d5 d5eaZbd6d7 ZceZd+dkd8d9Zdd:aeG d;d< d<eXZfd=d> ZgeZd+dld?d@ZhG dAdB dBeXZiG dCdD dDeiZjdEdF ZkG dGdH dHeiZldIdJ ZmeZd+dldKdLZnG dMdN dNeXZoG dOdP dPeoZpdQdR ZqG dSdT dTeoZrdUdV ZsG dWdX dXeoZtdYdZ ZuG d[d\ d\eoZvd]d^ ZweZd+dld_d`ZxG dadb dbeXZyG dcdd ddeyZzdedf Z{G dgdh dheyZ|didj Z}dd:l~m  mZ ejZejZejZejZejZejZd:S )mz Integral Transforms     )reducewraps)repeat)Spi)Add)AppliedUndef	count_opsexpand
expand_mulFunction)Mul)igcdilcm)default_sort_key)Dummy)postorder_traversal)	factorialrf)reargAbs)exp	exp_polar)coshcothsinhtanh)ceiling)MaxMinsqrt)piecewise_fold)coscotsintan)besselj)	Heaviside)gamma)meijerg)	integrateIntegral)_dummy)to_cnf	conjuncts	disjunctsOrAnd)roots)factorPoly)CRootOf)iterable)debugc                       s    e Zd ZdZ fddZ  ZS )IntegralTransformErrora  
    Exception raised in relation to problems computing transforms.

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

    This class is mostly used internally; if integrals cannot be computed
    objects representing unevaluated transforms are usually returned.

    The hint ``needeval=True`` can be used to disable returning transform
    objects, and instead raise this exception if an integral cannot be
    computed.
    c                    s   t  d||f  || _d S )Nz'%s Transform could not be computed: %s.)super__init__function)self	transformr<   msg	__class__ n/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/sympy/integrals/transforms.pyr;   6   s   

zIntegralTransformError.__init__)__name__
__module____qualname____doc__r;   __classcell__rB   rB   r@   rC   r9   (   s    r9   c                   @   s|   e Zd Zd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 Zdd Zdd Zedd Zdd ZdS )IntegralTransforma}  
    Base class for integral transforms.

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

    This class represents unevaluated transforms.

    To implement a concrete transform, derive from this class and implement
    the ``_compute_transform(f, x, s, **hints)`` and ``_as_integral(f, x, s)``
    functions. If the transform cannot be computed, raise :obj:`IntegralTransformError`.

    Also set ``cls._name``. For instance,

    >>> from sympy import LaplaceTransform
    >>> LaplaceTransform._name
    'Laplace'

    Implement ``self._collapse_extra`` if your function returns more than just a
    number and possibly a convergence condition.
    c                 C   
   | j d S )z! The function to be transformed. r   argsr=   rB   rB   rC   r<   S      
zIntegralTransform.functionc                 C   rJ   )z; The dependent variable of the function to be transformed.    rK   rM   rB   rB   rC   function_variableX   rN   z#IntegralTransform.function_variablec                 C   rJ   )z% The independent transform variable.    rK   rM   rB   rB   rC   transform_variable]   rN   z$IntegralTransform.transform_variablec                 C   s   | j j| jh| jh S )zj
        This method returns the symbols that will exist when the transform
        is evaluated.
        )r<   free_symbolsunionrR   rP   rM   rB   rB   rC   rS   b   s   zIntegralTransform.free_symbolsc                 K      t NNotImplementedErrorr=   fxshintsrB   rB   rC   _compute_transformk      z$IntegralTransform._compute_transformc                 C   rU   rV   rW   r=   rZ   r[   r\   rB   rB   rC   _as_integraln   r_   zIntegralTransform._as_integralc                 C   s$   t | }|dkrt| jjd d|S )NF )r2   r9   rA   name)r=   extracondrB   rB   rC   _collapse_extraq   s   z!IntegralTransform._collapse_extrac                    s   d }t  fdd jtD  }|r4z j j j jfi |}W n ty3   td d }Y nw  j}|j	s>t
|}||fS )Nc                 3   s    | ]	}|  jV  qd S rV   )hasrP   ).0funcrM   rB   rC   	<genexpr>y   s    z2IntegralTransform._try_directly.<locals>.<genexpr>z6[IT _try ] Caught IntegralTransformError, returns None)anyr<   atomsr   r^   rP   rR   r9   r8   is_Addr   )r=   r]   Ttry_directlyfnrB   rM   rC   _try_directlyw   s&   


zIntegralTransform._try_directlyc                    s    dd}  dd}| d< jdi  \}}|dur |S |jr| d<  fdd|jD }g }g }|D ].}	t|	tsB|	g}	||	d  t|	d	krW||	d
  q8t|	d	krf||	d
d g7 }q8|dkrrt| 	 }nt| }|sz|S z
|}t|r|ft| W S ||fW S  ty   Y nw |rtjjjd|j\}
}|
jt| gtjd
d    S )a  
        Try to evaluate the transform in closed form.

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

        This general function handles linearity, but apart from that leaves
        pretty much everything to _compute_transform.

        Standard hints are the following:

        - ``simplify``: whether or not to simplify the result
        - ``noconds``: if True, do not return convergence conditions
        - ``needeval``: if True, raise IntegralTransformError instead of
                        returning IntegralTransform objects

        The default values of these hints depend on the concrete transform,
        usually the default is
        ``(simplify, noconds, needeval) = (True, False, False)``.
        needevalFsimplifyTNc                    s6   g | ]}j |gtjd d   jdi  qS )rO   NrB   )rA   listrL   doitrh   r[   r]   r=   rB   rC   
<listcomp>   s    .z*IntegralTransform.doit.<locals>.<listcomp>r   rQ   rO   rB   )poprq   rm   rL   
isinstancetupleappendlenr   rs   rf   r7   r9   rA   _namer<   as_coeff_mulrP   r   rt   )r=   r]   rr   rs   rp   rn   resrd   ressr[   coeffrestrB   rw   rC   ru      sR   


&zIntegralTransform.doitc                 C   s   |  | j| j| jS rV   )ra   r<   rP   rR   rM   rB   rB   rC   as_integral   s   zIntegralTransform.as_integralc                 O   s   | j S rV   )r   )r=   rL   kwargsrB   rB   rC   _eval_rewrite_as_Integral      z+IntegralTransform._eval_rewrite_as_IntegralN)rD   rE   rF   rG   propertyr<   rP   rR   rS   r^   ra   rf   rq   ru   r   r   rB   rB   rB   rC   rI   <   s$    



G
rI   c                 C   s4   |rddl m} ddlm} ||t| ddS | S )Nr   )rs   )	powdenestT)polar)sympy.simplifyrs   sympy.simplify.powsimpr   r"   )exprru   rs   r   rB   rB   rC   	_simplify   s
   r   c                    s    fdd}|S )aV  
    This is a decorator generator for dropping convergence conditions.

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

    Suppose you define a function ``transform(*args)`` which returns a tuple of
    the form ``(result, cond1, cond2, ...)``.

    Decorating it ``@_noconds_(default)`` will add a new keyword argument
    ``noconds`` to it. If ``noconds=True``, the return value will be altered to
    be only ``result``, whereas if ``noconds=False`` the return value will not
    be altered.

    The default value of the ``noconds`` keyword will be ``default`` (i.e. the
    argument of this function).
    c                    s   t  d fdd
}|S )Nnocondsc                    s    |i |}| r|d S |S Nr   rB   )r   rL   r   r   ri   rB   rC   wrapper   s   z0_noconds_.<locals>.make_wrapper.<locals>.wrapper)r   )ri   r   defaultr   rC   make_wrapper   s   z_noconds_.<locals>.make_wrapperrB   )r   r   rB   r   rC   	_noconds_   s   r   Fc                 C   s   t | |tjtjfS rV   )r+   r   ZeroInfinity)rZ   r[   rB   rB   rC   _default_integrator     r   Tc                    s   t dd| ||d  |  |}|ts't|||tjtjftjfS |j	s0t
d| d|jd \}}|trBt
d| dfdd	  fd
dt|D }dd |D }|jdd d |sjt
d| d|d \}}	}
t|||||	f|
fS )z0 Backend function to compute Mellin transforms. r\   zmellin-transformrO   Mellincould not compute integralr   integral in unexpected formc                    sH  ddl m} tj}tj}tj}tt| }tddd}|D ]}tj}tj}	g }
t	|D ]M}|
tdd t |}|jrM|jdv sM| sM||sS|
|g7 }
q+|||}|jr`|jdv rf|
|g7 }
q+|j|krrt|j|	}	q+t|j|}q+|tjur||krt||}q|	tjur|	|krt|	|}qt|t|
 }q|||fS )	zN
        Turn ``cond`` into a strip (a, b), and auxiliary conditions.
        r   )_solve_inequalitytT)realc                 S   s   |   d S r   )as_real_imagr[   rB   rB   rC   <lambda>)  s    z:_mellin_transform.<locals>.process_conds.<locals>.<lambda>)z==z!=)sympy.solvers.inequalitiesr   r   NegativeInfinityr   truer/   r.   r   r0   replacer   subsis_Relationalrel_oprg   ltsr   gtsr    r2   r1   )re   r   abauxcondsr   ca_b_aux_dd_soln)r\   rB   rC   process_conds  sL   






z(_mellin_transform.<locals>.process_condsc                    s   g | ]} |qS rB   rB   rh   r   )r   rB   rC   rx   @      z%_mellin_transform.<locals>.<listcomp>c                 S   s   g | ]
}|d  dkr|qS )rQ   FrB   rv   rB   rB   rC   rx   A      c                 S   s   | d | d  t | d fS )Nr   rO   rQ   )r	   r   rB   rB   rC   r   B  r   z#_mellin_transform.<locals>.<lambda>keyzno convergence found)r-   rg   r,   r   r   r   r   r   r   is_Piecewiser9   rL   r0   sort)rZ   r[   s_
integratorrs   Fre   r   r   r   r   rB   )r   r\   rC   _mellin_transform  s&   
"
'r   c                   @   s,   e Zd ZdZdZdd Zdd Zdd Zd	S )
MellinTransformz
    Class representing unevaluated Mellin transforms.

    For usage of this class, see the :class:`IntegralTransform` docstring.

    For how to compute Mellin transforms, see the :func:`mellin_transform`
    docstring.
    r   c                 K   s   t |||fi |S rV   )r   rY   rB   rB   rC   r^   W  r   z"MellinTransform._compute_transformc                 C   s    t |||d   |tjtjfS NrO   )r,   r   r   r   r`   rB   rB   rC   ra   Z  s    zMellinTransform._as_integralc           	      C   s   g }g }g }|D ]\\}}}||g7 }||g7 }||g7 }qt | t| ft| f}|d d |d d kdks>|d dkrDtdd d|S )Nr   rO   TFr   zno combined convergence.)r   r    r2   r9   )	r=   rd   r   r   re   sasbr   r   rB   rB   rC   rf   ]  s   

(zMellinTransform._collapse_extraN)rD   rE   rF   rG   r~   r^   ra   rf   rB   rB   rB   rC   r   K  s    	r   c                 K      t | ||jdi |S )a  
    Compute the Mellin transform `F(s)` of `f(x)`,

    .. math :: F(s) = \int_0^\infty x^{s-1} f(x) \mathrm{d}x.

    For all "sensible" functions, this converges absolutely in a strip
      `a < \operatorname{Re}(s) < b`.

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

    The Mellin transform is related via change of variables to the Fourier
    transform, and also to the (bilateral) Laplace transform.

    This function returns ``(F, (a, b), cond)``
    where ``F`` is the Mellin transform of ``f``, ``(a, b)`` is the fundamental strip
    (as above), and ``cond`` are auxiliary convergence conditions.

    If the integral cannot be computed in closed form, this function returns
    an unevaluated :class:`MellinTransform` object.

    For a description of possible hints, refer to the docstring of
    :func:`sympy.integrals.transforms.IntegralTransform.doit`. If ``noconds=False``,
    then only `F` will be returned (i.e. not ``cond``, and also not the strip
    ``(a, b)``).

    Examples
    ========

    >>> from sympy import mellin_transform, exp
    >>> from sympy.abc import x, s
    >>> mellin_transform(exp(-x), x, s)
    (gamma(s), (0, oo), True)

    See Also
    ========

    inverse_mellin_transform, laplace_transform, fourier_transform
    hankel_transform, inverse_hankel_transform
    NrB   )r   ru   )rZ   r[   r\   r]   rB   rB   rC   mellin_transforml  s   )r   c                 C   sp   | \}}t |t }t |t }t| | | d  }t|| | | td| | ||  d| t fS )a  
    Re-write the sine function ``sin(m*s + n)`` as gamma functions, compatible
    with the strip (a, b).

    Return ``(gamma1, gamma2, fac)`` so that ``f == fac/(gamma1 * gamma2)``.

    Examples
    ========

    >>> from sympy.integrals.transforms import _rewrite_sin
    >>> from sympy import pi, S
    >>> from sympy.abc import s
    >>> _rewrite_sin((pi, 0), s, 0, 1)
    (gamma(s), gamma(1 - s), pi)
    >>> _rewrite_sin((pi, 0), s, 1, 0)
    (gamma(s - 1), gamma(2 - s), -pi)
    >>> _rewrite_sin((pi, 0), s, -1, 0)
    (gamma(s + 1), gamma(-s), -pi)
    >>> _rewrite_sin((pi, pi/2), s, S(1)/2, S(3)/2)
    (gamma(s - 1/2), gamma(3/2 - s), -pi)
    >>> _rewrite_sin((pi, pi), s, 0, 1)
    (gamma(s), gamma(1 - s), -pi)
    >>> _rewrite_sin((2*pi, 0), s, 0, S(1)/2)
    (gamma(2*s), gamma(1 - 2*s), pi)
    >>> _rewrite_sin((2*pi, 0), s, S(1)/2, 1)
    (gamma(2*s - 1), gamma(2 - 2*s), -pi)
    r   rO   )r   r   r   r   r)   )m_nr\   r   r   mnrrB   rB   rC   _rewrite_sin  s
   %6r   c                   @   s   e Zd ZdZdS )MellinTransformStripErrorzF
    Exception raised by _rewrite_gamma. Mainly for internal use.
    N)rD   rE   rF   rG   rB   rB   rB   rC   r     s    r   c           -         s  t ||g\  fdd}g }tD ]#}|sq|jd }|jr-|d }|\}}	||g7 }qtt	t
tD ]%}|sJqB|jd }|jrY|d }|\}}	||t g7 }qBdd |D }t j|D ]	}
|
js}|
 nqtfdd|D }tdd	 |D rjstd
ddttdd |D t j }|krt|dkr}nttdd |D  }| t j| }t j| } durڈ |9  dur|9  \}}t|}t|}tt|tdtt|td }g }g }g }g }g }fdd|r| \r(||}}|}n||}}|}fdd}sD|g7 }njsNtt rjrYj!}j }nt"d}j }|j#r{}|dk rn| }|||fgt$| 7 }q|s||\}}sd| }||| g7 }||| g7 }ng%r#t&}|' dkr|( d }t)|}t||' krt*+|}||g7 }|fdd|D 7 }q|, \}}||g7 }||  }||r|t j| d fg7 }|t j| fg7 }n|dg7 }|t j-|d fg7 }|t j-|fg7 }nttra|jd \}}rY|dkrE|| | dksU|dk rY|| | dkrYt.d|||fg7 }nttrjd }rt|t td|t  t} }!}"nt/|| \} }!}"||  f|! fg7 }||"g7 }nett
rÈjd }|t|ddfttd | dd fg7 }nBtt	rވjd }|ttd | ddfg7 }n'ttrjd }|ttd | ddft|dd fg7 }n|s|t| t|  9 }g g g g f\}#}$}%}&||#|%df||&|$dffD ]\}'}(})|'r|' \}}|dkr|dkrt$t |}|| }*|| }+|j#sWt0dt1|D ]},|'|*|+|,|  fg7 }'q[r|dt d| d  ||t j2   9 }||| g7 }n|dt d| d  ||t j2    }|||  g7 }q.|dkr|(3d|  n|)3| |'s1q(t| }|#j4t5d |$j4t5d |%j4t5d |&j4t5d |#|$f|%|&f|||fS )a  
    Try to rewrite the product f(s) as a product of gamma functions,
    so that the inverse Mellin transform of f can be expressed as a meijer
    G function.

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

    Return (an, ap), (bm, bq), arg, exp, fac such that
    G((an, ap), (bm, bq), arg/z**exp)*fac is the inverse Mellin transform of f(s).

    Raises IntegralTransformError or MellinTransformStripError on failure.

    It is asserted that f has no poles in the fundamental strip designated by
    (a, b). One of a and b is allowed to be None. The fundamental strip is
    important, because it determines the inversion contour.

    This function can handle exponentials, linear factors, trigonometric
    functions.

    This is a helper function for inverse_mellin_transform that will not
    attempt any transformations on f.

    Examples
    ========

    >>> from sympy.integrals.transforms import _rewrite_gamma
    >>> from sympy.abc import s
    >>> from sympy import oo
    >>> _rewrite_gamma(s*(s+3)*(s-1), s, -oo, oo)
    (([], [-3, 0, 1]), ([-2, 1, 2], []), 1, 1, -1)
    >>> _rewrite_gamma((s-1)**2, s, -oo, oo)
    (([], [1, 1]), ([2, 2], []), 1, 1, 1)

    Importance of the fundamental strip:

    >>> _rewrite_gamma(1/s, s, 0, oo)
    (([1], []), ([], [0]), 1, 1, 1)
    >>> _rewrite_gamma(1/s, s, None, oo)
    (([1], []), ([], [0]), 1, 1, 1)
    >>> _rewrite_gamma(1/s, s, 0, None)
    (([1], []), ([], [0]), 1, 1, 1)
    >>> _rewrite_gamma(1/s, s, -oo, 0)
    (([], [1]), ([0], []), 1, 1, -1)
    >>> _rewrite_gamma(1/s, s, None, 0)
    (([], [1]), ([0], []), 1, 1, -1)
    >>> _rewrite_gamma(1/s, s, -oo, None)
    (([], [1]), ([0], []), 1, 1, -1)

    >>> _rewrite_gamma(2**(-s+3), s, -oo, oo)
    (([], []), ([], []), 1/2, 1, 8)
    c                    s   t t| }  du rtju rdS  du r| k S du r!|  kS | kdkr)dS |  kdkr1dS |r5dS  js>js>| jr@dS td)zU
        Decide whether pole at c lies to the left of the fundamental strip.
        NTFzPole inside critical strip?)r
   r   r   r   rS   r   )r   is_numer)r   r   rB   rC   left  s    z_rewrite_gamma.<locals>.leftr   rO   c                 S   s   g | ]}|j rt|n|qS rB   )is_extended_realr   rv   rB   rB   rC   rx   8  s    z"_rewrite_gamma.<locals>.<listcomp>c                    s   g | ]}|  qS rB   rB   rv   )common_coefficientrB   rC   rx   >  r   c                 s   s    | ]}|j V  qd S rV   )is_Rationalrv   rB   rB   rC   rj   ?  s    z!_rewrite_gamma.<locals>.<genexpr>GammaNzNonrational multiplierc                 S      g | ]}t |jqS rB   )r   qrv   rB   rB   rC   rx   B  s    c                 S   r   rB   )r   prv   rB   rB   rC   rx   I  s    TFc                    s   t d d|  S )NInverse MellinzUnrecognised form '%s'.)r9   )fact)rZ   rB   rC   	exceptiona     z!_rewrite_gamma.<locals>.exceptionc                    s8   |  s	 t| }| dkr | S )z7 Test if arg is of form a*s+b, raise exception if not. rO   )is_polynomialr5   degree
all_coeffs)r   r   )r   r   r\   rB   rC   
linear_argl  s   

z"_rewrite_gamma.<locals>.linear_argc                    s   g | ]}|  fqS rB   rB   r   )r   r\   rB   rC   rx     s    r   z Gammas partially over the strip.)evaluaterQ   za is not an integerr   )6r   rl   r)   rg   rL   rm   as_independentr   r%   r#   r&   r$   r   Oner   allr   r9   r   r   r}   r   r   as_numer_denomr   	make_argsrt   zipr   ry   is_Powrz   r   baser   
is_Integerr   r   r5   r   LTr3   r6   	all_rootsr   NegativeOnerX   r   	TypeErrorrangeHalfr|   r   r   )-rZ   r\   r   r   r   s_multipliersgr   r   _r[   s_multiplierfacexponentnumerdenomrL   facsdfacsnumer_gammasdenom_gammasexponentialsugammaslgammasufacsr   r   exp_re   r   rsr   gamma1gamma2fac_anapbmbqgammasplusminusnewanewckrB   )r   r   r   r   rZ   r   r   r\   rC   _rewrite_gamma  sT  ?







$










  
&

 
h

&&

r  c              	      sB  t dd| dd| t} t| t| t| fD ]}|jrT fdd|jD }dd |D }dd |D }t| } sHt||	t
d	}||t| f  S zt|d
 d \}	}
}}}W n	 tyo   Y qw zt|	|
||  }W n	 ty   Y qw  r|}nDzd
dlm} ||}W n ty   td| dw |jrt|jdkrt
t| |jd
 jd
  t
t| |jd jd
   }tt|j|jt k g}|ttt|jt|jkd
t|jd ktt|j|jt kg7 }t| }|dkrtd| d|| ||f  S td| d)zs A helper for the real inverse_mellin_transform function, this one here
        assumes x to be real and positive. r   zinverse-mellin-transformT)positivec              
      s    g | ]}t | d dqS )Fr   )_inverse_mellin_transform)rh   G
as_meijergr\   stripr[   rB   rC   rx     s
    
z-_inverse_mellin_transform.<locals>.<listcomp>c                 S      g | ]}|d  qS )rO   rB   rh   r   rB   rB   rC   rx     r   c                 S   r  )r   rB   r  rB   rB   rC   rx     r   )gensr   rO   )hyperexpandr   zCould not calculate integral   Fzdoes not convergerb   ) r-   rewriter)   r4   r   r
   rm   rL   r   rl   r(   r   r2   r  r9   r*   
ValueErrorr   r  rX   r   r}   r   r   argumentdeltar   r1   r	  r  r   nu)r   r\   x_r  r  r   r   r   r   r   r   Cer   r  hr  re   rB   r  rC   r    s`   
$*
r  Nc                   @   sH   e Zd ZdZdZedZedZdd Ze	dd Z
d	d
 Zdd ZdS )InverseMellinTransformz
    Class representing unevaluated inverse Mellin transforms.

    For usage of this class, see the :class:`IntegralTransform` docstring.

    For how to compute inverse Mellin transforms, see the
    :func:`inverse_mellin_transform` docstring.
    r   Noner   c                 K   s8   |d u rt j}|d u rt j}tj| |||||fi |S rV   )r'  _none_sentinelrI   __new__)clsr   r\   r[   r   r   optsrB   rB   rC   r*  C  s
   zInverseMellinTransform.__new__c                 C   s:   | j d | j d }}|tju rd }|tju rd }||fS )Nr     )rL   r'  r)  )r=   r   r   rB   rB   rC   fundamental_stripJ  s   

z(InverseMellinTransform.fundamental_stripc                 K   s   | dd td u rtttttttt	t
ttthat|D ]}|jr3||r3|jtvr3td|d| q| j}t||||fi |S )Nrs   Tr   zComponent %s not recognised.)ry   _allowedr   r)   r%   r#   r&   r$   r   r   r   r   r   r   r   is_Functionrg   ri   r9   r.  r  )r=   r   r\   r[   r]   rZ   r  rB   rB   rC   r^   S  s   z)InverseMellinTransform._compute_transformc                 C   sJ   | j j}t|||   ||tjtj  |tjtj  fdtj tj  S NrQ   )rA   _cr,   r   ImaginaryUnitr   Pi)r=   r   r\   r[   r   rB   rB   rC   ra   c  s    
z#InverseMellinTransform._as_integralN)rD   rE   rF   rG   r~   r   r)  r2  r*  r   r.  r^   ra   rB   rB   rB   rC   r'  5  s    	
r'  c                 K   s$   t | |||d |d jdi |S )a"  
    Compute the inverse Mellin transform of `F(s)` over the fundamental
    strip given by ``strip=(a, b)``.

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

    This can be defined as

    .. math:: f(x) = \frac{1}{2\pi i} \int_{c - i\infty}^{c + i\infty} x^{-s} F(s) \mathrm{d}s,

    for any `c` in the fundamental strip. Under certain regularity
    conditions on `F` and/or `f`,
    this recovers `f` from its Mellin transform `F`
    (and vice versa), for positive real `x`.

    One of `a` or `b` may be passed as ``None``; a suitable `c` will be
    inferred.

    If the integral cannot be computed in closed form, this function returns
    an unevaluated :class:`InverseMellinTransform` object.

    Note that this function will assume x to be positive and real, regardless
    of the SymPy assumptions!

    For a description of possible hints, refer to the docstring of
    :func:`sympy.integrals.transforms.IntegralTransform.doit`.

    Examples
    ========

    >>> from sympy import inverse_mellin_transform, oo, gamma
    >>> from sympy.abc import x, s
    >>> inverse_mellin_transform(gamma(s), s, x, (0, oo))
    exp(-x)

    The fundamental strip matters:

    >>> f = 1/(s**2 - 1)
    >>> inverse_mellin_transform(f, s, x, (-oo, -1))
    x*(1 - 1/x**2)*Heaviside(x - 1)/2
    >>> inverse_mellin_transform(f, s, x, (-1, 1))
    -x*Heaviside(1 - x)/2 - Heaviside(x - 1)/(2*x)
    >>> inverse_mellin_transform(f, s, x, (1, oo))
    (1/2 - x**2/2)*Heaviside(1 - x)/x

    See Also
    ========

    mellin_transform
    hankel_transform, inverse_hankel_transform
    r   rO   NrB   )r'  ru   )r   r\   r[   r  r]   rB   rB   rC   inverse_mellin_transformi  s   $5r5  c           
      C   s   t ||  t|tj | |  |tjtjf}|ts$t||tj	fS t | |tjtjf}|tjtjtj
fv s=|trCt|| d|jsLt|| d|jd \}}	|tr^t|| dt|||	fS )z
    Compute a general Fourier-type transform

    .. math::

        F(k) = a \int_{-\infty}^{\infty} e^{bixk} f(x)\, dx.

    For suitable choice of *a* and *b*, this reduces to the standard Fourier
    and inverse Fourier transforms.
    z$function not integrable on real axisr   r   r   )r+   r   r   r3  r   r   rg   r,   r   r   NaNr9   r   rL   )
rZ   r[   r  r   r   rc   rs   r   
integral_fre   rB   rB   rC   _fourier_transform  s   .

r8  c                   @   0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )FourierTypeTransformz# Base class for Fourier transforms.c                 C      t d| j Nz,Class %s must implement a(self) but does notrX   rA   rM   rB   rB   rC   r        zFourierTypeTransform.ac                 C   r;  Nz,Class %s must implement b(self) but does notr=  rM   rB   rB   rC   r     r>  zFourierTypeTransform.bc                 K   s&   t ||||  |  | jjfi |S rV   )r8  r   r   rA   r~   r=   rZ   r[   r  r]   rB   rB   rC   r^     s   z'FourierTypeTransform._compute_transformc                 C   s>   |   }|  }t|| t|tj | |  |tjtjfS rV   )r   r   r,   r   r   r3  r   r   )r=   rZ   r[   r  r   r   rB   rB   rC   ra     s   .z!FourierTypeTransform._as_integralNrD   rE   rF   rG   r   r   r^   ra   rB   rB   rB   rC   r:    s    r:  c                   @   $   e Zd ZdZdZdd Zdd ZdS )FourierTransformz
    Class representing unevaluated Fourier transforms.

    For usage of this class, see the :class:`IntegralTransform` docstring.

    For how to compute Fourier transforms, see the :func:`fourier_transform`
    docstring.
    Fourierc                 C      dS r   rB   rM   rB   rB   rC   r     r_   zFourierTransform.ac                 C   
   dt j S )Nr   r4  rM   rB   rB   rC   r        
zFourierTransform.bNrD   rE   rF   rG   r~   r   r   rB   rB   rB   rC   rC    
    	rC  c                 K   r   )a  
    Compute the unitary, ordinary-frequency Fourier transform of ``f``, defined
    as

    .. math:: F(k) = \int_{-\infty}^\infty f(x) e^{-2\pi i x k} \mathrm{d} x.

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

    If the transform cannot be computed in closed form, this
    function returns an unevaluated :class:`FourierTransform` object.

    For other Fourier transform conventions, see the function
    :func:`sympy.integrals.transforms._fourier_transform`.

    For a description of possible hints, refer to the docstring of
    :func:`sympy.integrals.transforms.IntegralTransform.doit`.
    Note that for this transform, by default ``noconds=True``.

    Examples
    ========

    >>> from sympy import fourier_transform, exp
    >>> from sympy.abc import x, k
    >>> fourier_transform(exp(-x**2), x, k)
    sqrt(pi)*exp(-pi**2*k**2)
    >>> fourier_transform(exp(-x**2), x, k, noconds=False)
    (sqrt(pi)*exp(-pi**2*k**2), True)

    See Also
    ========

    inverse_fourier_transform
    sine_transform, inverse_sine_transform
    cosine_transform, inverse_cosine_transform
    hankel_transform, inverse_hankel_transform
    mellin_transform, laplace_transform
    NrB   )rC  ru   rZ   r[   r  r]   rB   rB   rC   fourier_transform     'rM  c                   @   rB  )InverseFourierTransformz
    Class representing unevaluated inverse Fourier transforms.

    For usage of this class, see the :class:`IntegralTransform` docstring.

    For how to compute inverse Fourier transforms, see the
    :func:`inverse_fourier_transform` docstring.
    zInverse Fourierc                 C   rE  r   rB   rM   rB   rB   rC   r   #  r_   zInverseFourierTransform.ac                 C   rF  r1  rH  rM   rB   rB   rC   r   &  rI  zInverseFourierTransform.bNrJ  rB   rB   rB   rC   rO    rK  rO  c                 K   r   )a  
    Compute the unitary, ordinary-frequency inverse Fourier transform of `F`,
    defined as

    .. math:: f(x) = \int_{-\infty}^\infty F(k) e^{2\pi i x k} \mathrm{d} k.

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

    If the transform cannot be computed in closed form, this
    function returns an unevaluated :class:`InverseFourierTransform` object.

    For other Fourier transform conventions, see the function
    :func:`sympy.integrals.transforms._fourier_transform`.

    For a description of possible hints, refer to the docstring of
    :func:`sympy.integrals.transforms.IntegralTransform.doit`.
    Note that for this transform, by default ``noconds=True``.

    Examples
    ========

    >>> from sympy import inverse_fourier_transform, exp, sqrt, pi
    >>> from sympy.abc import x, k
    >>> inverse_fourier_transform(sqrt(pi)*exp(-(pi*k)**2), k, x)
    exp(-x**2)
    >>> inverse_fourier_transform(sqrt(pi)*exp(-(pi*k)**2), k, x, noconds=False)
    (exp(-x**2), True)

    See Also
    ========

    fourier_transform
    sine_transform, inverse_sine_transform
    cosine_transform, inverse_cosine_transform
    hankel_transform, inverse_hankel_transform
    mellin_transform, laplace_transform
    NrB   )rO  ru   r   r  r[   r]   rB   rB   rC   inverse_fourier_transform*  rN  rQ  c           
      C   s   t ||  ||| |  |tjtjf}|ts!t||tjfS |js*t	|| d|j
d \}}	|tr<t	|| dt|||	fS )a  
    Compute a general sine or cosine-type transform
        F(k) = a int_0^oo b*sin(x*k) f(x) dx.
        F(k) = a int_0^oo b*cos(x*k) f(x) dx.

    For suitable choice of a and b, this reduces to the standard sine/cosine
    and inverse sine/cosine transforms.
    r   r   r   )r+   r   r   r   rg   r,   r   r   r   r9   rL   )
rZ   r[   r  r   r   Krc   rs   r   re   rB   rB   rC   _sine_cosine_transformX  s   (


rS  c                   @   r9  )SineCosineTypeTransformzK
    Base class for sine and cosine transforms.
    Specify cls._kern.
    c                 C   r;  r<  r=  rM   rB   rB   rC   r   w  r>  zSineCosineTypeTransform.ac                 C   r;  r?  r=  rM   rB   rB   rC   r   {  r>  zSineCosineTypeTransform.bc                 K   s,   t ||||  |  | jj| jjfi |S rV   )rS  r   r   rA   _kernr~   r@  rB   rB   rC   r^     s   z*SineCosineTypeTransform._compute_transformc                 C   s@   |   }|  }| jj}t|| ||| |  |tjtjfS rV   )r   r   rA   rU  r,   r   r   r   )r=   rZ   r[   r  r   r   rR  rB   rB   rC   ra     s   (z$SineCosineTypeTransform._as_integralNrA  rB   rB   rB   rC   rT  q  s    rT  c                   @   (   e Zd ZdZdZeZdd Zdd ZdS )SineTransformz
    Class representing unevaluated sine transforms.

    For usage of this class, see the :class:`IntegralTransform` docstring.

    For how to compute sine transforms, see the :func:`sine_transform`
    docstring.
    Sinec                 C      t dt t S r1  r!   r   rM   rB   rB   rC   r     r   zSineTransform.ac                 C      t jS rV   r   r   rM   rB   rB   rC   r     r   zSineTransform.bN	rD   rE   rF   rG   r~   r%   rU  r   r   rB   rB   rB   rC   rW        	rW  c                 K   r   )a1  
    Compute the unitary, ordinary-frequency sine transform of `f`, defined
    as

    .. math:: F(k) = \sqrt{\frac{2}{\pi}} \int_{0}^\infty f(x) \sin(2\pi x k) \mathrm{d} x.

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

    If the transform cannot be computed in closed form, this
    function returns an unevaluated :class:`SineTransform` object.

    For a description of possible hints, refer to the docstring of
    :func:`sympy.integrals.transforms.IntegralTransform.doit`.
    Note that for this transform, by default ``noconds=True``.

    Examples
    ========

    >>> from sympy import sine_transform, exp
    >>> from sympy.abc import x, k, a
    >>> sine_transform(x*exp(-a*x**2), x, k)
    sqrt(2)*k*exp(-k**2/(4*a))/(4*a**(3/2))
    >>> sine_transform(x**(-a), x, k)
    2**(1/2 - a)*k**(a - 1)*gamma(1 - a/2)/gamma(a/2 + 1/2)

    See Also
    ========

    fourier_transform, inverse_fourier_transform
    inverse_sine_transform
    cosine_transform, inverse_cosine_transform
    hankel_transform, inverse_hankel_transform
    mellin_transform, laplace_transform
    NrB   )rW  ru   rL  rB   rB   rC   sine_transform     $r_  c                   @   rV  )InverseSineTransformz
    Class representing unevaluated inverse sine transforms.

    For usage of this class, see the :class:`IntegralTransform` docstring.

    For how to compute inverse sine transforms, see the
    :func:`inverse_sine_transform` docstring.
    zInverse Sinec                 C   rY  r1  rZ  rM   rB   rB   rC   r     r   zInverseSineTransform.ac                 C   r[  rV   r\  rM   rB   rB   rC   r     r   zInverseSineTransform.bNr]  rB   rB   rB   rC   ra    r^  ra  c                 K   r   )am  
    Compute the unitary, ordinary-frequency inverse sine transform of `F`,
    defined as

    .. math:: f(x) = \sqrt{\frac{2}{\pi}} \int_{0}^\infty F(k) \sin(2\pi x k) \mathrm{d} k.

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

    If the transform cannot be computed in closed form, this
    function returns an unevaluated :class:`InverseSineTransform` object.

    For a description of possible hints, refer to the docstring of
    :func:`sympy.integrals.transforms.IntegralTransform.doit`.
    Note that for this transform, by default ``noconds=True``.

    Examples
    ========

    >>> from sympy import inverse_sine_transform, exp, sqrt, gamma
    >>> from sympy.abc import x, k, a
    >>> inverse_sine_transform(2**((1-2*a)/2)*k**(a - 1)*
    ...     gamma(-a/2 + 1)/gamma((a+1)/2), k, x)
    x**(-a)
    >>> inverse_sine_transform(sqrt(2)*k*exp(-k**2/(4*a))/(4*sqrt(a)**3), k, x)
    x*exp(-a*x**2)

    See Also
    ========

    fourier_transform, inverse_fourier_transform
    sine_transform
    cosine_transform, inverse_cosine_transform
    hankel_transform, inverse_hankel_transform
    mellin_transform, laplace_transform
    NrB   )ra  ru   rP  rB   rB   rC   inverse_sine_transform  s   %rb  c                   @   rV  )CosineTransformz
    Class representing unevaluated cosine transforms.

    For usage of this class, see the :class:`IntegralTransform` docstring.

    For how to compute cosine transforms, see the :func:`cosine_transform`
    docstring.
    Cosinec                 C   rY  r1  rZ  rM   rB   rB   rC   r     r   zCosineTransform.ac                 C   r[  rV   r\  rM   rB   rB   rC   r     r   zCosineTransform.bN	rD   rE   rF   rG   r~   r#   rU  r   r   rB   rB   rB   rC   rc    r^  rc  c                 K   r   )a:  
    Compute the unitary, ordinary-frequency cosine transform of `f`, defined
    as

    .. math:: F(k) = \sqrt{\frac{2}{\pi}} \int_{0}^\infty f(x) \cos(2\pi x k) \mathrm{d} x.

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

    If the transform cannot be computed in closed form, this
    function returns an unevaluated :class:`CosineTransform` object.

    For a description of possible hints, refer to the docstring of
    :func:`sympy.integrals.transforms.IntegralTransform.doit`.
    Note that for this transform, by default ``noconds=True``.

    Examples
    ========

    >>> from sympy import cosine_transform, exp, sqrt, cos
    >>> from sympy.abc import x, k, a
    >>> cosine_transform(exp(-a*x), x, k)
    sqrt(2)*a/(sqrt(pi)*(a**2 + k**2))
    >>> cosine_transform(exp(-a*sqrt(x))*cos(a*sqrt(x)), x, k)
    a*exp(-a**2/(2*k))/(2*k**(3/2))

    See Also
    ========

    fourier_transform, inverse_fourier_transform,
    sine_transform, inverse_sine_transform
    inverse_cosine_transform
    hankel_transform, inverse_hankel_transform
    mellin_transform, laplace_transform
    NrB   )rc  ru   rL  rB   rB   rC   cosine_transform  r`  rf  c                   @   rV  )InverseCosineTransformz
    Class representing unevaluated inverse cosine transforms.

    For usage of this class, see the :class:`IntegralTransform` docstring.

    For how to compute inverse cosine transforms, see the
    :func:`inverse_cosine_transform` docstring.
    zInverse Cosinec                 C   rY  r1  rZ  rM   rB   rB   rC   r   L  r   zInverseCosineTransform.ac                 C   r[  rV   r\  rM   rB   rB   rC   r   O  r   zInverseCosineTransform.bNre  rB   rB   rB   rC   rg  ?  r^  rg  c                 K   r   )a(  
    Compute the unitary, ordinary-frequency inverse cosine transform of `F`,
    defined as

    .. math:: f(x) = \sqrt{\frac{2}{\pi}} \int_{0}^\infty F(k) \cos(2\pi x k) \mathrm{d} k.

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

    If the transform cannot be computed in closed form, this
    function returns an unevaluated :class:`InverseCosineTransform` object.

    For a description of possible hints, refer to the docstring of
    :func:`sympy.integrals.transforms.IntegralTransform.doit`.
    Note that for this transform, by default ``noconds=True``.

    Examples
    ========

    >>> from sympy import inverse_cosine_transform, sqrt, pi
    >>> from sympy.abc import x, k, a
    >>> inverse_cosine_transform(sqrt(2)*a/(sqrt(pi)*(a**2 + k**2)), k, x)
    exp(-a*x)
    >>> inverse_cosine_transform(1/sqrt(k), k, x)
    1/sqrt(x)

    See Also
    ========

    fourier_transform, inverse_fourier_transform,
    sine_transform, inverse_sine_transform
    cosine_transform
    hankel_transform, inverse_hankel_transform
    mellin_transform, laplace_transform
    NrB   )rg  ru   rP  rB   rB   rC   inverse_cosine_transformS  r`  rh  c                 C   s   t | t|||  | |tjtjf}|ts t||tjfS |j	s)t
|| d|jd \}}|tr;t
|| dt|||fS )zv
    Compute a general Hankel transform

    .. math:: F_\nu(k) = \int_{0}^\infty f(r) J_\nu(k r) r \mathrm{d} r.
    r   r   r   )r+   r'   r   r   r   rg   r,   r   r   r   r9   rL   )rZ   r   r  r"  rc   rs   r   re   rB   rB   rC   _hankel_transform~  s   &

ri  c                   @   s4   e Zd ZdZdd Zdd Zdd Zedd	 Zd
S )HankelTypeTransformz+
    Base class for Hankel transforms.
    c                 K   s$   | j | j| j| j| jd fi |S Nr  )r^   r<   rP   rR   rL   )r=   r]   rB   rB   rC   ru     s   zHankelTypeTransform.doitc                 K   s   t ||||| jfi |S rV   )ri  r~   )r=   rZ   r   r  r"  r]   rB   rB   rC   r^     s   z&HankelTypeTransform._compute_transformc                 C   s&   t |t|||  | |tjtjfS rV   )r,   r'   r   r   r   )r=   rZ   r   r  r"  rB   rB   rC   ra     s   &z HankelTypeTransform._as_integralc                 C   s   |  | j| j| j| jd S rk  )ra   r<   rP   rR   rL   rM   rB   rB   rC   r     s
   zHankelTypeTransform.as_integralN)	rD   rE   rF   rG   ru   r^   ra   r   r   rB   rB   rB   rC   rj    s    rj  c                   @      e Zd ZdZdZdS )HankelTransformz
    Class representing unevaluated Hankel transforms.

    For usage of this class, see the :class:`IntegralTransform` docstring.

    For how to compute Hankel transforms, see the :func:`hankel_transform`
    docstring.
    HankelNrD   rE   rF   rG   r~   rB   rB   rB   rC   rm        	rm  c                 K      t | |||jdi |S )a  
    Compute the Hankel transform of `f`, defined as

    .. math:: F_\nu(k) = \int_{0}^\infty f(r) J_\nu(k r) r \mathrm{d} r.

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

    If the transform cannot be computed in closed form, this
    function returns an unevaluated :class:`HankelTransform` object.

    For a description of possible hints, refer to the docstring of
    :func:`sympy.integrals.transforms.IntegralTransform.doit`.
    Note that for this transform, by default ``noconds=True``.

    Examples
    ========

    >>> from sympy import hankel_transform, inverse_hankel_transform
    >>> from sympy import exp
    >>> from sympy.abc import r, k, m, nu, a

    >>> ht = hankel_transform(1/r**m, r, k, nu)
    >>> ht
    2*k**(m - 2)*gamma(-m/2 + nu/2 + 1)/(2**m*gamma(m/2 + nu/2))

    >>> inverse_hankel_transform(ht, k, r, nu)
    r**(-m)

    >>> ht = hankel_transform(exp(-a*r), r, k, 0)
    >>> ht
    a/(k**3*(a**2/k**2 + 1)**(3/2))

    >>> inverse_hankel_transform(ht, k, r, 0)
    exp(-a*r)

    See Also
    ========

    fourier_transform, inverse_fourier_transform
    sine_transform, inverse_sine_transform
    cosine_transform, inverse_cosine_transform
    inverse_hankel_transform
    mellin_transform, laplace_transform
    NrB   )rm  ru   )rZ   r   r  r"  r]   rB   rB   rC   hankel_transform     .rr  c                   @   rl  )InverseHankelTransformz
    Class representing unevaluated inverse Hankel transforms.

    For usage of this class, see the :class:`IntegralTransform` docstring.

    For how to compute inverse Hankel transforms, see the
    :func:`inverse_hankel_transform` docstring.
    zInverse HankelNro  rB   rB   rB   rC   rt    rp  rt  c                 K   rq  )a  
    Compute the inverse Hankel transform of `F` defined as

    .. math:: f(r) = \int_{0}^\infty F_\nu(k) J_\nu(k r) k \mathrm{d} k.

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

    If the transform cannot be computed in closed form, this
    function returns an unevaluated :class:`InverseHankelTransform` object.

    For a description of possible hints, refer to the docstring of
    :func:`sympy.integrals.transforms.IntegralTransform.doit`.
    Note that for this transform, by default ``noconds=True``.

    Examples
    ========

    >>> from sympy import hankel_transform, inverse_hankel_transform
    >>> from sympy import exp
    >>> from sympy.abc import r, k, m, nu, a

    >>> ht = hankel_transform(1/r**m, r, k, nu)
    >>> ht
    2*k**(m - 2)*gamma(-m/2 + nu/2 + 1)/(2**m*gamma(m/2 + nu/2))

    >>> inverse_hankel_transform(ht, k, r, nu)
    r**(-m)

    >>> ht = hankel_transform(exp(-a*r), r, k, 0)
    >>> ht
    a/(k**3*(a**2/k**2 + 1)**(3/2))

    >>> inverse_hankel_transform(ht, k, r, 0)
    exp(-a*r)

    See Also
    ========

    fourier_transform, inverse_fourier_transform
    sine_transform, inverse_sine_transform
    cosine_transform, inverse_cosine_transform
    hankel_transform
    mellin_transform, laplace_transform
    NrB   )rt  ru   )r   r  r   r"  r]   rB   rB   rC   inverse_hankel_transform  rs  ru  )F)T)rG   	functoolsr   r   	itertoolsr   
sympy.corer   r   sympy.core.addr   sympy.core.functionr   r	   r
   r   r   sympy.core.mulr   sympy.core.intfuncr   r   sympy.core.sortingr   sympy.core.symbolr   sympy.core.traversalr   (sympy.functions.combinatorial.factorialsr   r   $sympy.functions.elementary.complexesr   r   r   &sympy.functions.elementary.exponentialr   r   %sympy.functions.elementary.hyperbolicr   r   r   r   #sympy.functions.elementary.integersr   (sympy.functions.elementary.miscellaneousr   r    r!   $sympy.functions.elementary.piecewiser"   (sympy.functions.elementary.trigonometricr#   r$   r%   r&   sympy.functions.special.besselr'   'sympy.functions.special.delta_functionsr(   'sympy.functions.special.gamma_functionsr)   sympy.functions.special.hyperr*   sympy.integralsr+   r,   sympy.integrals.meijerintr-   sympy.logic.boolalgr.   r/   r0   r1   r2   sympy.polys.polyrootsr3   sympy.polys.polytoolsr4   r5   sympy.polys.rootoftoolsr6   sympy.utilities.iterablesr7   sympy.utilities.miscr8   rX   r9   rI   r   r   _nocondsr   r   r   r   r   r  r   r  r  r/  r'  r5  r8  r:  rC  rM  rO  rQ  rS  rT  rW  r_  ra  rb  rc  rf  rg  rh  ri  rj  rm  rr  rt  ru  sympy.integrals.laplace	integralslaplace_laplaceLaplaceTransformlaplace_transformlaplace_correspondencelaplace_initial_condsInverseLaplaceTransforminverse_laplace_transformrB   rB   rB   rC   <module>   s     D!,-  -:4<*.'('+16
