o
    8Va	                    @   s  d Z ddlmZ ddlmZmZ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mZmZ ddl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" ddl#m$Z$m%Z%m&Z&m'Z'm(Z( ddl)m*Z* ddl+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2m3Z3 G dd de4Z5G dd deZ6ddl7m8Z8 dd Z9dd Z:e:dZ;dd Z<e;e<d fd!d"Z=G d#d$ d$e6Z>d%d& Z?d'd( Z@G d)d* d*eAZBd+d, ZCe:d dsd-d.ZDd/aEG d0d1 d1e6ZFd2d3 ZGd4d5 ZHd6d7 ZIe;dtd8d9ZJG d:d; d;e6ZKdtd<d=ZLe:d dtd>d?ZMG d@dA dAe6ZNdudBdCZOdDdE ZPe:d dtdFdGZQG dHdI dIe6ZRG dJdK dKeRZSdLdM ZTG dNdO dOeRZUdPdQ ZVddRlmWZWmXZXmYZYmZZZ e:d dtdSdTZ[G dUdV dVe6Z\G dWdX dXe\Z]dYdZ Z^G d[d\ d\e\Z_d]d^ Z`G d_d` d`e\Zadadb ZbG dcdd dde\Zcdedf Zde:d dtdgdhZeG didj dje6ZfG dkdl dlefZgdmdn ZhG dodp dpefZidqdr Zjd/S )vz Integral Transforms     )reduce)symbolsWildRootSumLambdatogetherexpgamma)S)iterableordered)Function)
_canonicalGeGtoo)Dummy)
DiracDeltaMax)	integrateIntegral)_dummy)to_cnf	conjuncts	disjunctsOrAnd)simplify)default_sort_key)SymPyDeprecationWarning)
MatrixBase)_lin_eq2dictPolyNonlinearErrorc                       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)selfZ	transformr(   msg	__class__ </usr/lib/python3/dist-packages/sympy/integrals/transforms.pyr'   +   s   

zIntegralTransformError.__init__)__name__
__module____qualname____doc__r'   __classcell__r-   r-   r+   r.   r%      s    r%   c                   @   st   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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.integrals.transforms 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)   r-   r-   r.   r(   H      
zIntegralTransform.functionc                 C   r5   )z; The dependent variable of the function to be transformed.    r6   r8   r-   r-   r.   function_variableM   r9   z#IntegralTransform.function_variablec                 C   r5   )z% The independent transform variable.    r6   r8   r-   r-   r.   transform_variableR   r9   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unionr=   r;   r8   r-   r-   r.   r>   W   s   zIntegralTransform.free_symbolsc                 K      t NNotImplementedErrorr)   fxshintsr-   r-   r.   _compute_transform`      z$IntegralTransform._compute_transformc                 C   r@   rA   rB   r)   rE   rF   rG   r-   r-   r.   _as_integralc   rJ   zIntegralTransform._as_integralc                 C   s$   t | }|dkrt| jjd d|S )NF )r   r%   r,   name)r)   extracondr-   r-   r.   _collapse_extraf   s   z!IntegralTransform._collapse_extrac                    s  ddl m}m}m} ddlm}  dd}tfddj	|D  }|rAzj
jjjfi  W S  ty@   Y nw j}|jsK||}|jr| d<  fdd	|jD }	g }
g }|	D ].}t|tsm|g}||d  t|d
kr|
|d  qct|d
kr|
|dd g7 }
qc|| }	|
s|	S z|
}
t|
rt|	gt|
 W S |	|
fW S  ty   Y nw |rtjjjd|j\}}|j|| 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, don't 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)``.
        r   )Add
expand_mulMul)AppliedUndefneedevalFc                 3   s    | ]	}|  jV  qd S rA   )hasr;   ).0funcr8   r-   r.   	<genexpr>   s    z)IntegralTransform.doit.<locals>.<genexpr>c                    s6   g | ]}j |gtjd d   jdi  qS )r:   Nr-   )r,   listr7   doitrX   rF   rH   r)   r-   r.   
<listcomp>   s    .z*IntegralTransform.doit.<locals>.<listcomp>r<   r:   N)sympyrR   rS   rT   sympy.core.functionrU   popanyr(   atomsrI   r;   r=   r%   is_Addr7   
isinstancetupleappendlenrQ   r   r,   _nameas_coeff_mulr[   )r)   rH   rR   rS   rT   rU   rV   Ztry_directlyfnresrO   ressrF   coeffrestr-   r^   r.   r\   l   sh   




&zIntegralTransform.doitc                 C   s   |  | j| j| jS rA   )rL   r(   r;   r=   r8   r-   r-   r.   as_integral   s   zIntegralTransform.as_integralc                 O   s   | j S rA   )rq   )r)   r7   kwargsr-   r-   r.   _eval_rewrite_as_Integral   s   z+IntegralTransform._eval_rewrite_as_IntegralN)r/   r0   r1   r2   propertyr(   r;   r=   r>   rI   rL   rQ   r\   rq   rs   r-   r-   r-   r.   r4   1   s"    



K
r4   )_solve_inequalityc                 C   s,   ddl m}m} |rt||| ddS | S )Nr   )	powdenestpiecewise_foldT)Zpolar)r`   rv   rw   r   )exprr\   rv   rw   r-   r-   r.   	_simplify   s   ry   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*   ddl m} | d fdd
}|S )Nr   )wrapsnocondsc                    s    |i |}| r|d S |S Nr   r-   )r|   r7   rr   rm   rY   r-   r.   wrapper   s   z0_noconds_.<locals>.make_wrapper.<locals>.wrapper)Zsympy.core.decoratorsrz   )rY   rz   r   defaultr~   r.   make_wrapper   s   z_noconds_.<locals>.make_wrapperr-   )r   r   r-   r   r.   	_noconds_   s   
r   Fc                 C   s   t | |dtfS r}   )r   r   )rE   rF   r-   r-   r.   _default_integrator      r   Tc                    s  ddl mm mm tdd| ||d  |  |}|ts2t|	||t
 t
ftjfS |js;td| d|jd \}}|trMtd| d fd	d
fddt|D }dd |D }|jfddd |sztd| d|d \}}	}
t|	||||	f|
fS )z0 Backend function to compute Mellin transforms. r   )rer   Min	count_opsrG   zmellin-transformr:   Mellincould not compute integralintegral in unexpected formc                    s6  t  }t }tj}tt| }tddd}|D ]}t }t  }g }	t|D ]M}
|
dd |}|
j	rE|
j
dv sE|sE||sK|	|
g7 }	q#t||}|j	rX|j
dv r^|	|
g7 }	q#|j|krj |j|}q#|j|}q#|t kr||kr ||}q|t  kr||kr||}qt|t|	 }q|||fS )zN
        Turn ``cond`` into a strip (a, b), and auxiliary conditions.
        tTrealc                 S   s   |   d S r}   )as_real_imagrF   r-   r-   r.   <lambda>  s    z:_mellin_transform.<locals>.process_conds.<locals>.<lambda>z==z!=)r   r
   truer   r   r   r   replacesubsis_Relationalrel_oprW   ru   ltsgtsr   r   )rP   abauxcondsr   ca_b_aux_dd_soln)r   r   r   rG   r-   r.   process_conds  sN   




z(_mellin_transform.<locals>.process_condsc                       g | ]} |qS r-   r-   rX   r   r   r-   r.   r_   +      z%_mellin_transform.<locals>.<listcomp>c                 S      g | ]
}|d  dkr|qS )r<   Fr-   r]   r-   r-   r.   r_   ,      c                    s   | d | d   | d fS )Nr   r:   r<   r-   r   r   r-   r.   r   -  r   z#_mellin_transform.<locals>.<lambda>keyno convergence found)r`   r   r   r   r   r   rW   r   ry   r   r   r
   r   is_Piecewiser%   r7   r   sort)rE   rF   s_Z
integratorr   FrP   r   r   r   r   r-   )r   r   r   r   r   rG   r.   _mellin_transform   s(   
 
&r   c                   @   ,   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      t |||fi |S rA   )r   rD   r-   r-   r.   rI   B     z"MellinTransform._compute_transformc                 C   s   t |||d   |dtfS )Nr:   r   )r   r   rK   r-   r-   r.   rL   E  s   zMellinTransform._as_integralc                 C   s   ddl m}m} g }g }g }|D ]\\}}}	||g7 }||g7 }||	g7 }q|| || ft| f}
|
d d |
d d kdksF|
d dkrLtdd d|
S )Nr   )r   r   r:   TFr   zno combined convergence.)r`   r   r   r   r%   )r)   rO   r   r   r   r   rP   ZsaZsbr   rm   r-   r-   r.   rQ   H  s   

(zMellinTransform._collapse_extraNr/   r0   r1   r2   rj   rI   rL   rQ   r-   r-   r-   r.   r   6  s    	r   c                 K      t | ||jdi |S )aE  
    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.integrals.transforms import mellin_transform
    >>> from sympy import 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
    Nr-   )r   r\   )rE   rF   rG   rH   r-   r-   r.   mellin_transformX  s   *r   c                 C   s   ddl m}m}m}m} | \}}	||| }||	| }	|| | |	 d  }
||| |	 |
 |d|	 |
 ||  d|
 | 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   )rS   piceilingr	   r:   )r`   rS   r   r   r	   r   )Zm_nrG   r   r   rS   r   r   r	   mnrr-   r-   r.   _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)r/   r0   r1   r2   r-   r-   r-   r.   r     s    r   c           ;         s$  ddl m} ddlm m}m}m	m}m}m	m
}	m}
m}m}m}m}m}m}m} t||g\	fdd}g }|D ]#}|
sJqB|jd }|jrY|
d }|
\}}||g7 }qB||||D ]%}|
svqn|jd }|jr|
d }|
\}}||| g7 }qndd |D }tj|D ]	}|js| nqfd	d|D }td
d |D sjstdddt|
dd |D tj }|krt |dkr}nt|dd |D  }!

| tj| }tj| }dur|9 dur|9 " \}}|#|}|#|}t$t%||dt$t%||d }g }g } g }!g }"g }#fdd|r7|& \rV|!|"}$}%|}&n|"|!}$}%| }& 
fdd}'
ss|&g7 }&nj's}t(|rшj'rj)}(j})n|d}(j})|)j*r}*|)dk r|* }*||(|*fgt+|) 7 }qB|(
s|'|)\}}sd|( }(|#|(| g7 }#||(| g7 }ng,
rR 
}+|+- dkr|+. d }|	|+
},t |,|+- kr|/|+},|&|g7 }&|
fdd|,D 7 }qB|+0 \}}-|&|g7 }&|-|  }-||-r:|$tj|- d fg7 }$|%tj|- fg7 }%n|&dg7 }&|$tj1|-d fg7 }$|%tj1|-fg7 }%nt(|r|'jd \}}r|dkrt|| | dks|dk r|| | dkrt2d|$||fg7 }$nt(|rψjd }r||| |d||  |}.}/}0nt3|'|
\}.}/}0||. f|/ fg7 }|&|0g7 }&net(|rjd }|||ddf||d | dd fg7 }nBt(|rjd }|||d | ddfg7 }n't(|r0jd }|||d | ddf||dd fg7 }n|sE||| ||   9 }g g g g f\}1}2}3}4|!|1|3df|"|4|2dffD ]\}5}6}7|5r|5& \}}-|dkr|dkrt+t|}+||+ }8|-|+ }9|j*st4dt5|+D ]}:|5|8|9|:|+  fg7 }5qr|d| d|+ d  |+|-tj6   9 }|#|+| g7 }#n|d| d|+ d  |+|-tj6    }|#|+|  g7 }#q]|dkr|67d|-  n|77|- |5s`qW||# }|1j8t9d |2j8t9d |3j8t9d |4j8t9d |1|2f|3|4f|||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)
    r   )repeat)Polyr	   rT   r   CRootOfr   expandrootsilcmr   sincostancotigcd	exp_polarc                    s   | }  du rt u rdS  du r| k S du r |  kS | kdkr(dS |  kdkr0dS |r4d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   is_numer)r   r   r   r   r-   r.   left  s    z_rewrite_gamma.<locals>.leftr:   c                 S   s   g | ]}|j rt|n|qS r-   )is_extended_realabsr]   r-   r-   r.   r_   )  s    z"_rewrite_gamma.<locals>.<listcomp>c                    s   g | ]}|  qS r-   r-   r]   )common_coefficientr-   r.   r_   /  r   c                 s   s    | ]}|j  V  qd S rA   )is_Rationalr]   r-   r-   r.   rZ   0  s    z!_rewrite_gamma.<locals>.<genexpr>ZGammaNzNonrational multiplierc                 S      g | ]}t |jqS r-   )r
   qr]   r-   r-   r.   r_   3  s    c                 S   r   r-   )r
   pr]   r-   r-   r.   r_   :      TFc                    s   t d d|  S )NInverse MellinzUnrecognised form '%s'.)r%   )fact)rE   r-   r.   	exceptionR  r   z!_rewrite_gamma.<locals>.exceptionc                    s8   |  s	 | }| dkr| S )z7 Test if arg is of form a*s+b, raise exception if not. r:   )is_polynomialdegree
all_coeffs)argr   )r   r   r   rG   r-   r.   
linear_arg]  s   

z"_rewrite_gamma.<locals>.linear_argc                    s   g | ]}|  fqS r-   r-   r   )r   rG   r-   r.   r_     s    r   z Gammas partially over the strip.)Zevaluater<   za is not an integerr   ):	itertoolsr   r`   r   r	   rT   r   r   r   r   r   r   r   r   r   r   r   r   r   r
   rd   rW   r7   re   as_independentrk   ZOner   rc   r   r%   r   ri   r   Zas_numer_denomZ	make_argsr[   ziprb   is_Powrf   base
is_Integerr   r   r   ZLTZ	all_rootsr   ZNegativeOnerC   r   	TypeErrorrangeHalfrh   r   r    );rE   rG   r   r   r   r	   rT   r   Zexp_r   r   r   r   r   r   r   r   r   r   Zs_multipliersgr   ro   _rF   Zs_multiplierfacexponentZnumerZdenomr7   ZfacsZdfacsZnumer_gammasZdenom_gammasZexponentialsZugammasZlgammasZufacsr   r   r   rP   r   Zrsr   Zgamma1Zgamma2Zfac_ZanapbmbqZgammasZplusZminusZnewaZnewckr-   )r   r   r   r   r   r   rE   r   r   r   rG   r.   _rewrite_gamma  s^  5H









$










 
&

 
h

&&

r   c              	      sh  ddl m}m}m}m}m}	m}
m}m}m	}m
}m} tdd| dd| |} || || || fD ]}|jrm fdd|jD }d	d |D }d
d |D }|| } sa||||d}||t| f  S zt|d d \}}}}}W n	 ty   Y q2w z|||||  }W n	 ty   Y q2w  r|}n>z||}W n ty   td| dw |jrt|jdkr|t| |jd jd  |t| |jd jd   }t|	|j|j|
 k g}|ttt|jt|jkd||jd kt|	|j|j|
 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   )r   rS   hyperexpandmeijergr   r   r   factor	Heavisider	   rR   r   zinverse-mellin-transformT)Zpositivec              
      s    g | ]}t | d dqS )Fr{   )_inverse_mellin_transform)rX   G
as_meijergrG   striprF   r-   r.   r_     s
    
z-_inverse_mellin_transform.<locals>.<listcomp>c                 S      g | ]}|d  qS )r:   r-   rX   r   r-   r-   r.   r_     r   c                 S   r   )r   r-   r   r-   r-   r.   r_     r   )Zgensr:   r   zCould not calculate integral   Fzdoes not convergerM   ) r`   r   rS   r   r   r   r   r   r   r   r	   rR   r   Zrewritere   r7   rd   r   r   r   r%   
ValueErrorrC   r   ri   r   argumentZdeltar   r   r   nu)r   rG   Zx_r   r   r   rS   r   r   r   r   r   r   r   r	   rR   r   rn   r   rm   r   r   Cer   r   hrP   r-   r   r.   r     s`   4
$*
r   Nc                   @   H   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 rA   )r  _none_sentinelr4   __new__)clsr   rG   rF   r   r   optsr-   r-   r.   r
  5  s
   zInverseMellinTransform.__new__c                 C   s:   | j d | j d }}|tju rd }|tju rd }||fS )Nr      )r7   r  r	  )r)   r   r   r-   r-   r.   fundamental_strip<  s   

z(InverseMellinTransform.fundamental_stripc                 K   s   ddl m} td u r4ddl m}m}m}m}	m}
m}m	}m
}m}m}m}m} ||||	|
|||||||ha||D ]}|jrO||rO|jtvrOtd|d| q8| j}t||||fi |S )Nr   )postorder_traversal)r   r	   r   r   r   r   coshsinhtanhcoth	factorialrfr   zComponent %s not recognised.)r`   r  _allowedr   r	   r   r   r   r   r  r  r  r  r  r  Zis_FunctionrW   rY   r%   r  r   )r)   r   rG   rF   rH   r  r   r	   r   r   r   r   r  r  r  r  r  r  rE   r   r-   r-   r.   rI   E  s   8z)InverseMellinTransform._compute_transformc                 C   sN   ddl m} | jj}t|||   |||t  ||t  fdtj tj  S )Nr   )Ir<   )	r`   r  r,   _cr   r   r
   PiImaginaryUnit)r)   r   rG   rF   r  r   r-   r-   r.   rL   V  s   :z#InverseMellinTransform._as_integralN)r/   r0   r1   r2   rj   r   r	  r  r
  rt   r  rI   rL   r-   r-   r-   r.   r  '  s    	
r  c                 K   s$   t | |||d |d jdi |S )aP  
    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.integrals.transforms import inverse_mellin_transform
    >>> from sympy import 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   r:   Nr-   )r  r\   )r   rG   rF   r   rH   r-   r-   r.   inverse_mellin_transform\  s   $6r  c                    s   ddl m}m}m ddlm  fdd fdd fdd	fd
d}dd }ddlm} || } || |} || |fdd} || |} t| S )a  
    Naively simplify some conditions occurring in ``expr``, given that `\operatorname{Re}(s) > a`.

    Examples
    ========

    >>> from sympy.integrals.transforms import _simplifyconds as simp
    >>> from sympy.abc import x
    >>> from sympy import sympify as S
    >>> simp(abs(x**2) < 1, x, 1)
    False
    >>> simp(abs(x**2) < 1, x, 2)
    False
    >>> simp(abs(x**2) < 1, x, 0)
    Abs(x**2) < 1
    >>> simp(abs(1/x**2) < 1, x, 1)
    True
    >>> simp(S(1) < abs(x), x, 1)
    True
    >>> simp(S(1) < abs(1/x), x, 1)
    False

    >>> from sympy import Ne
    >>> simp(Ne(1, x**3), x, 1)
    True
    >>> simp(Ne(1, x**3), x, 2)
    True
    >>> simp(Ne(1, x**3), x, 0)
    Ne(1, x**3)
    r   )StrictGreaterThanStrictLessThan
Unequality)Absc                    s&   |  krdS | j r| j kr| jS d S Nr:   )r   r   r   )ex)rG   r-   r.   power  s
   z_simplifyconds.<locals>.powerc                    s   |  r| rdS t|  r| jd } t| r |jd }|  r.d| d|  S |}|du r8dS z,|dkrLt| t| kdkrLW dS |dk r_t| t| kdkrbW dS W dS W dS  tyn   Y dS w )z_ Return True only if |ex1| > |ex2|, False only if |ex1| < |ex2|.
            Else return None. Nr   r:   TF)rW   rf   r7   r   r   )Zex1Zex2r   )r  r   biggerr"  rG   r-   r.   r#    s(   




  z_simplifyconds.<locals>.biggerc                    sH   | j st|  r|j st| s| |k S | |}|dur | S | |k S )z simplify x < y N)is_positiverf   )rF   yr   )r  r#  r-   r.   replie  s   
z_simplifyconds.<locals>.repliec                    s(   | |}|dks|dkrdS  | |S NTFr-   )rF   r%  r   )r  r#  r-   r.   replue  s   

z_simplifyconds.<locals>.repluec                 W   s"   | dks| dkrt | S | j| S r'  )boolr   )r!  r7   r-   r-   r.   repl  s   
z_simplifyconds.<locals>.repl)collect_absc                    s
    || S rA   r-   )rF   r%  )r&  r-   r.   r     s   
 z _simplifyconds.<locals>.<lambda>)	sympy.core.relationalr  r  r  r`   r  Zsympy.simplify.radsimpr+  r
   )rx   rG   r   r  r  r(  r*  r+  r-   )r  r  r   r#  r"  r&  rG   r.   _simplifyconds  s   
r-  c                 C   s   t | | tS )zs
    Expand an expression involving DiractDelta to get it as a linear
    combination of DiracDelta functions.
    )r#   rd   r   rx   r-   r-   r.   expand_dirac_delta  s   r/  c                    st  ddl mm m}mmmmmm	m
m	m} tddgd}g }g }zt\}	}
W n ty@   tddw |
 D ]4\}}|t| }|rb||d||   qE|jd djrrtdd|||  qE|t|  ||	g|R   dtf|| }|tst||t tjfS |jstdd	|jd \}}|trtdd
 	fdd

fddt |D }dd |D }|sdd |D }t!t"|}dd |j#fddd |stdd|d \}}fdd}|r(t$||}t$||}t||||t%||fS )z. The backend function for Laplace transforms. r   )r   r   r   r   r   periodic_argumentr   r   r   r   
polar_liftrR   rG   r   )excludeLaplacez'could not expand DiracDelta expressionsznot implemented yet.r   r   c                    sl  t  }tj}tt| } dgd\}}}}}}}	|t| |  |k |t| |  |kt| | | ||k t| | | ||kt	| | | ||k t	| | | ||kf}
| D ]3}t }g }t|D ]}|jr|jj	v r|j
}|jrt|ttfr|j}|
D ]}||  r nq rȈ | jrȈ |  |  d krȈ
 |   dk }|||t|	  | t| |   dk   s||t| |	 ||  t| |  dk   s)||t	| |	 || t| |   dk   rEt fdd|||||	fD rE
 | k}|
dd 
}|jri|jd	v si|si|so||g7 }qt|}|jr~|jd	v r||g7 }q|jkrtd
d|j|}q|t kr||}qut|t| }qu||jr|jfS |fS )z7 Turn ``conds`` into a strip and auxiliary conditions. zp q w1 w2 w3 w4 w5r  r2  r<   r   c                 3   s    | ]} | j V  qd S rA   )r$  )rX   Zwildr   r-   r.   rZ   G  s    z<_laplace_transform.<locals>.process_conds.<locals>.<genexpr>c                 S   s   |    d S r}   )r   r   r   r-   r-   r.   r   J  s    z;_laplace_transform.<locals>.process_conds.<locals>.<lambda>r   r3  zconvergence not in half-plane?)r   r
   r   r   r   r   r   r   Zrhsr>   reversedrf   r   r   Zreversedsignmatchr$  allr   r   r   rW   ru   r   r%   r   r   Z	canonical)r   r   r   r   r   Zw1Zw2Zw3Zw4Zw5patternsr   r   r   r   patr   r   )r   r   r   r   arg_r   rE   r   r1  r   rG   r   r   r5  r.   r   "  s     

":4"(



z)_laplace_transform.<locals>.process_condsc                    r   r-   r-   r   r   r-   r.   r_   `  r   z&_laplace_transform.<locals>.<listcomp>c                 S   s*   g | ]}|d  dkr|d t  kr|qS )r:   Fr   r   r]   r-   r-   r.   r_   a  s   * c                 S   r   )r:   Fr-   r]   r-   r-   r.   r_   c  r   c                 S   s   | dks| dkr
dS |   S )NTFr   r   r.  r-   r-   r.   cntf  s   z_laplace_transform.<locals>.cntc                    s   | d   | d fS Nr   r:   r-   r   )r<  r-   r.   r   j  r   z$_laplace_transform.<locals>.<lambda>r   r   c                    s   |   S rA   )r   r.  )rG   r   r-   r.   sbsp     z_laplace_transform.<locals>.sbs)&r`   r   r   r   r   r   r0  r   r   r   r   r1  rR   r   r/  r$   r%   itemsr7  r   rh   r   r7   Zis_zeror   r   rW   r   ry   r
   r   r   r   r[   r   r   r-  r   )rE   r   r   r   r   rR   r   Z	deltazeroZdeltanonzeroZintegratableZ	deltadictZ
dirac_funcZdirac_coeffr   r   rP   r   Zconds2r   r>  r-   )r   r   r   r   r;  r<  r   rE   r   r1  r   r   rG   r   r   r   r.   _laplace_transform  sf   8*

$>$rA  c                   @   r   )
LaplaceTransformz
    Class representing unevaluated Laplace transforms.

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

    For how to compute Laplace transforms, see the :func:`laplace_transform`
    docstring.
    r3  c                 K   r   rA   )rA  )r)   rE   r   rG   rH   r-   r-   r.   rI     r   z#LaplaceTransform._compute_transformc                 C   s*   ddl m} t||| |  |dtfS )Nr   )r   )r`   r   r   r   )r)   rE   r   rG   r   r-   r-   r.   rL     s   zLaplaceTransform._as_integralc                 C   sb   ddl m} g }g }|D ]\}}|| || qt| }|| }|dkr-tdd d||fS )Nr   r   Fr3  zNo combined convergence.)r`   r   rh   r   r%   )r)   rO   r   r   ZplanesplanerP   r-   r-   r.   rQ     s   
z LaplaceTransform._collapse_extraNr   r-   r-   r-   r.   rB  x  s    	rB  c                    s   t | tr_t| dr_ dd }|r*|r*tddddd  |  fd	d
S  fdd| D }|rSt| \}}}	t| g | j	|R  }
|
t
| t|	 fS t| g | j	|R  S t| jdi  S )ay  
    Compute the Laplace Transform `F(s)` of `f(t)`,

    .. math :: F(s) = \int_{0^{-}}^\infty e^{-st} f(t) \mathrm{d}t.

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

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

    This function returns ``(F, a, cond)`` where ``F`` is the Laplace
    transform of ``f``, `\operatorname{Re}(s) > a` is the half-plane
    of convergence, and ``cond`` are auxiliary convergence conditions.

    The lower bound is `0^{-}`, meaning that this bound should be approached
    from the lower side. This is only necessary if distributions are involved.
    At present, it is only done if `f(t)` contains ``DiracDelta``, in which
    case the Laplace transform is computed as

    .. math :: F(s) = \lim_{\tau\to 0^{-}} \int_{\tau}^\infty e^{-st} f(t) \mathrm{d}t.

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

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

    .. deprecated:: 1.9
        Legacy behavior for matrices where ``laplace_transform`` with
        ``noconds=False`` (the default) returns a Matrix whose elements are
        tuples. The behavior of ``laplace_transform`` for matrices will change
        in a future release of SymPy to return a tuple of the transformed
        Matrix and the convergence conditions for the matrix as a whole. Use
        ``legacy_matrix=False`` to enable the new behavior.

    Examples
    ========

    >>> from sympy.integrals import laplace_transform
    >>> from sympy.abc import t, s, a
    >>> from sympy.functions import DiracDelta, exp
    >>> laplace_transform(t**a, t, s)
    (gamma(a + 1)/(s*s**a), 0, re(a) > -1)
    >>> laplace_transform(DiracDelta(t)-a*exp(-a*t),t,s)
    (-a/(a + s) + 1, 0, Abs(arg(a)) <= pi/2)

    See Also
    ========

    inverse_laplace_transform, mellin_transform, fourier_transform
    hankel_transform, inverse_hankel_transform

    	applyfuncr|   Fz:laplace_transform of a Matrix with noconds=False (default)z7the option legacy_matrix=False to get the new behaviouri T  z1.9)ZfeatureZ
useinsteadZissueZdeprecated_since_versionc                    s   t | fi  S rA   laplace_transform)fijrH   rG   r   r-   r.   r     r   z#laplace_transform.<locals>.<lambda>c                    s    g | ]}t |fi  qS r-   rE  )rX   rG  rH  r-   r.   r_     s     z%laplace_transform.<locals>.<listcomp>Nr-   )rf   r"   hasattrgetr!   warnrD  r   typeshaper   r   rB  r\   )rE   r   rG   Zlegacy_matrixrH   r   Zelements_transelementsZavalsZ
conditionsZ	f_laplacer-   rH  r.   rF    s$   9rF  c                    s  ddl mm mmm}mm} ddlm	}m
 tddd	 	fdd}| r3| } | jrP|	fd	d
| jD  }	t|		|dfS zt| 	 dtfddd\}	}
W n tyn   d}	Y nw |	du r|| 	}	|	du rtd|	d|	jr|	jd \}	}
|	|rtd|	dntj}
|	|}	|	jr|		||
fS td
tjf 	
fdd	}|	 |}	fdd}|	|}	t|		||
fS )z6 The backend function for inverse Laplace transforms. r   )r   r   logexpand_complexr   	PiecewiserR   )meijerint_inversion_get_coeff_expr   Tr   c                     s   t | dkr
|  S | d jd j}|\}}| d jd }| d jd } dt| |  |  | dt|  |  S )z3 Simplify a piecewise expression from hyperexpand. r   r<   r   r:   )ri   r7   r  r   )r7   r   ro   r   Ze1Ze2)r   rQ  rS  r   r-   r.   pw_simp  s   z+_inverse_laplace_transform.<locals>.pw_simpc                    s   g | ]
}t | qS r-   )_inverse_laplace_transform)rX   X)rC  rG   r   r   r-   r.   r_     s    z._inverse_laplace_transform.<locals>.<listcomp>NF)rV   r|   Inverse LaplacerM   z(inversion integral of unrecognised form.uc                    sp   |   }|r | |S t|dk}|jkr+|j} | |S |j} |  |S r}   )r   rW   ru   r   r   )r   ZH0r   Zrelr   )r   r   rO  r   rX  r-   r.   simp_heaviside$  s   




z2_inverse_laplace_transform.<locals>.simp_heavisidec                    s    | S rA   r-   )r   )r   rP  r-   r.   simp_exp2  r?  z,_inverse_laplace_transform.<locals>.simp_exp)r`   r   r   rO  rP  r   rQ  rR   sympy.integrals.meijerintrR  rS  r   Zis_rational_functionZapartre   r7   ry   r   r  r   r%   r   rW   r
   r   r   r   )r   rG   Zt_rC  r   r   rR   rR  rT  rE   rP   rY  rZ  r-   )r   rQ  rS  r   rP  rO  rC  rG   r   r   rX  r.   rU    sN   $


rU  c                   @   r  )InverseLaplaceTransformz
    Class representing unevaluated inverse Laplace transforms.

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

    For how to compute inverse Laplace transforms, see the
    :func:`inverse_laplace_transform` docstring.
    rW  r  r   c                 K   s(   |d u rt j}tj| ||||fi |S rA   )r\  r	  r4   r
  )r  r   rG   rF   rC  r  r-   r-   r.   r
  K  s   zInverseLaplaceTransform.__new__c                 C   s   | j d }|tju rd }|S Nr   )r7   r\  r	  )r)   rC  r-   r-   r.   fundamental_planeP  s   

z)InverseLaplaceTransform.fundamental_planec                 K   s   t |||| jfi |S rA   )rU  r^  )r)   r   rG   r   rH   r-   r-   r.   rI   W  s   z*InverseLaplaceTransform._compute_transformc                 C   sT   ddl m}m} | jj}t||| | |||t  ||t  fdtj tj	  S )Nr   )r  r   r<   )
r`   r  r   r,   r  r   r   r
   r  r  )r)   r   rG   r   r  r   r   r-   r-   r.   rL   Z  s   <z$InverseLaplaceTransform._as_integralN)r/   r0   r1   r2   rj   r   r	  r  r
  rt   r^  rI   rL   r-   r-   r-   r.   r\  =  s    	
r\  c                    sF   t | trt| dr|  fddS t| jdi  S )a<  
    Compute the inverse Laplace transform of `F(s)`, defined as

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

    for `c` so large that `F(s)` has no singularites in the
    half-plane `\operatorname{Re}(s) > c-\epsilon`.

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

    The plane can be specified by
    argument ``plane``, but will be inferred if passed as None.

    Under certain regularity conditions, this recovers `f(t)` from its
    Laplace Transform `F(s)`, for non-negative `t`, and vice
    versa.

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

    Note that this function will always assume `t` to be real,
    regardless of the sympy assumption on `t`.

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

    Examples
    ========

    >>> from sympy.integrals.transforms import inverse_laplace_transform
    >>> from sympy import exp, Symbol
    >>> from sympy.abc import s, t
    >>> a = Symbol('a', positive=True)
    >>> inverse_laplace_transform(exp(-a*s)/s, s, t)
    Heaviside(-a + t)

    See Also
    ========

    laplace_transform, _fast_inverse_laplace
    hankel_transform, inverse_hankel_transform
    rD  c                    s   t | fi  S rA   )inverse_laplace_transform)ZFijrH   rC  rG   r   r-   r.   r     r   z+inverse_laplace_transform.<locals>.<lambda>Nr-   )rf   r"   rI  rD  r\  r\   )r   rG   r   rC  rH   r-   r`  r.   r_  `  s   ,r_  c                    sl   t dtgd\fdd  fdd fdd	fd	d
 fdd | S )zEFast inverse Laplace transform of rational function including RootSumza, b, nr4  c                    sN   |  s| S | jr | S | jr| S | jr| S t| tr%| S trA   )rW   re   is_Mulr   rf   r   rC   r  )_ilt_add_ilt_mul_ilt_pow_ilt_rootsumrG   r-   r.   _ilt  s   

z#_fast_inverse_laplace.<locals>._iltc                    s   | j t | j S rA   )rY   mapr7   rb  rg  r-   r.   rc    s   z'_fast_inverse_laplace.<locals>._ilt_addc                    s$   |  \}}|jrt| | S rA   )r   ra  rC   )r  ro   rx   )rg  rG   r-   r.   rd    s   z'_fast_inverse_laplace.<locals>._ilt_mulc                    s   |      }|d urM| |  | }}}|jr>|dk r>| d  t||    ||  t|   S |dkrMt||   | S tr=  )r7  r   r   r	   rC   )r  r7  Znmamr   )r   r   r   rG   r   r-   r.   re    s   4z'_fast_inverse_laplace.<locals>._ilt_powc                    s,   | j j}| j j\}t| jt|t |S rA   )Zfunrx   Z	variablesr   Zpolyr   r   )r  rx   variableri  r-   r.   rf    s   
z+_fast_inverse_laplace.<locals>._ilt_rootsum)r   r   )r  rG   r   r-   )
rg  rc  rd  re  rf  r   r   r   rG   r   r.   _fast_inverse_laplace  s   
rl  c                 C   s   ddl m}m} t||  ||| | |  |t tf}	|	ts*t|	|tj	fS t| |t tf}
|
t ttj
fv sA|
trGt|| d|	jsPt|| d|	jd \}	}|	trbt|| 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.
    r   r   r  z$function not integrable on real axisr   r   )r`   r   r  r   r   rW   r   ry   r
   r   ZNaNr%   r   r7   )rE   rF   r   r   r   rN   r   r   r  r   Z
integral_frP   r-   r-   r.   _fourier_transform  s   *

rn  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rC   r,   r8   r-   r-   r.   r        zFourierTypeTransform.ac                 C   rq  Nz,Class %s must implement b(self) but does notrs  r8   r-   r-   r.   r     rt  zFourierTypeTransform.bc                 K   s&   t ||||  |  | jjfi |S rA   )rn  r   r   r,   rj   r)   rE   rF   r   rH   r-   r-   r.   rI     s   z'FourierTypeTransform._compute_transformc                 C   sJ   ddl m}m} |  }|  }t|| ||| | |  |t tfS )Nr   rm  )r`   r   r  r   r   r   r   )r)   rE   rF   r   r   r  r   r   r-   r-   r.   rL     s   *z!FourierTypeTransform._as_integralNr/   r0   r1   r2   r   r   rI   rL   r-   r-   r-   r.   rp    s    rp  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.
    ZFourierc                 C      dS r   r-   r8   r-   r-   r.   r     rJ   zFourierTransform.ac                 C   
   dt j S )Nr
   r  r8   r-   r-   r.   r        
zFourierTransform.bNr/   r0   r1   r2   rj   r   r   r-   r-   r-   r.   ry    
    	ry  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
    Nr-   )ry  r\   rE   rF   r   rH   r-   r-   r.   fourier_transform     'r  c                   @   rx  )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   rz  r   r-   r8   r-   r-   r.   r   B  rJ   zInverseFourierTransform.ac                 C   r{  Nr<   r}  r8   r-   r-   r.   r   E  r~  zInverseFourierTransform.bNr  r-   r-   r-   r.   r  6  r  r  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
    Nr-   )r  r\   r   r   rF   rH   r-   r-   r.   inverse_fourier_transformI  r  r  )r   r   sqrtr   c           
      C   s   t ||  ||| |  |dt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   rW   r   ry   r
   r   r   r%   r7   )
rE   rF   r   r   r   KrN   r   r   rP   r-   r-   r.   _sine_cosine_transformz  s   $


r  c                   @   ro  )SineCosineTypeTransformzK
    Base class for sine and cosine transforms.
    Specify cls._kern.
    c                 C   rq  rr  rs  r8   r-   r-   r.   r     rt  zSineCosineTypeTransform.ac                 C   rq  ru  rs  r8   r-   r-   r.   r     rt  zSineCosineTypeTransform.bc                 K   s,   t ||||  |  | jj| jjfi |S rA   )r  r   r   r,   _kernrj   rv  r-   r-   r.   rI     s   z*SineCosineTypeTransform._compute_transformc                 C   s<   |   }|  }| jj}t|| ||| |  |dtfS r}   )r   r   r,   r  r   r   )r)   rE   rF   r   r   r   r  r-   r-   r.   rL     s   $z$SineCosineTypeTransform._as_integralNrw  r-   r-   r-   r.   r    s    r  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.
    ZSinec                 C      t dt t S r  r  r   r8   r-   r-   r.   r     r   zSineTransform.ac                 C   rz  r   r-   r8   r-   r-   r.   r     rJ   zSineTransform.bN	r/   r0   r1   r2   rj   r   r  r   r   r-   r-   r-   r.   r        	r  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
    Nr-   )r  r\   r  r-   r-   r.   sine_transform     $r  c                   @   r  )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   r  r  r  r8   r-   r-   r.   r     r   zInverseSineTransform.ac                 C   rz  r   r-   r8   r-   r-   r.   r     rJ   zInverseSineTransform.bNr  r-   r-   r-   r.   r    r  r  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
    Nr-   )r  r\   r  r-   r-   r.   inverse_sine_transform  s   %r  c                   @   r  )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.
    ZCosinec                 C   r  r  r  r8   r-   r-   r.   r   3  r   zCosineTransform.ac                 C   rz  r   r-   r8   r-   r-   r.   r   6  rJ   zCosineTransform.bN	r/   r0   r1   r2   rj   r   r  r   r   r-   r-   r-   r.   r  &  r  r  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
    Nr-   )r  r\   r  r-   r-   r.   cosine_transform:  r  r  c                   @   r  )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   r  r  r  r8   r-   r-   r.   r   n  r   zInverseCosineTransform.ac                 C   rz  r   r-   r8   r-   r-   r.   r   q  rJ   zInverseCosineTransform.bNr  r-   r-   r-   r.   r  a  r  r  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
    Nr-   )r  r\   r  r-   r-   r.   inverse_cosine_transformu  r  r  c           	      C   s   ddl m} t| ||||  | |dt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   besseljr   r   )r`   r  r   r   rW   r   ry   r
   r   r   r%   r7   )	rE   r   r   r  rN   r   r  r   rP   r-   r-   r.   _hankel_transform  s   "

r  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 r]  )rI   r(   r;   r=   r7   )r)   rH   r-   r-   r.   r\     s   zHankelTypeTransform.doitc                 K   s   t ||||| jfi |S rA   )r  rj   )r)   rE   r   r   r  rH   r-   r-   r.   rI     s   z&HankelTypeTransform._compute_transformc                 C   s.   ddl m} t|||||  | |dtfS )Nr   r  )r`   r  r   r   )r)   rE   r   r   r  r  r-   r-   r.   rL     s   "z HankelTypeTransform._as_integralc                 C   s   |  | j| j| j| jd S r]  )rL   r(   r;   r=   r7   r8   r-   r-   r.   rq     s
   zHankelTypeTransform.as_integralN)	r/   r0   r1   r2   r\   rI   rL   rt   rq   r-   r-   r-   r.   r    s    r  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.
    ZHankelNr/   r0   r1   r2   rj   r-   r-   r-   r.   r        	r  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
    Nr-   )r  r\   )rE   r   r   r  rH   r-   r-   r.   hankel_transform     .r  c                   @   r  )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 HankelNr  r-   r-   r-   r.   r    r  r  c                 K   r  )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
    Nr-   )r  r\   )r   r   r   r  rH   r-   r-   r.   inverse_hankel_transform  r  r  )F)TrA   )kr2   	functoolsr   r`   r   r   r   r   r   r   r	   Z
sympy.corer
   Zsympy.core.compatibilityr   r   ra   r   r,  r   r   r   Zsympy.core.numbersr   Zsympy.core.symbolr   Zsympy.functionsr   Z(sympy.functions.elementary.miscellaneousr   Zsympy.integralsr   r   r[  r   Zsympy.logic.boolalgr   r   r   r   r   Zsympy.simplifyr   Zsympy.utilitiesr    Zsympy.utilities.exceptionsr!   Zsympy.matrices.matricesr"   Zsympy.polys.matrices.linsolver#   r$   rC   r%   r4   Zsympy.solvers.inequalitiesru   ry   r   Z_nocondsr   r   r   r   r   r   r   r   r   r  r  r  r-  r/  rA  rB  rF  rU  r\  r_  rl  rn  rp  ry  r  r  r  r   r   r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r-   r-   r-   r.   <module>   s    $ D"-.  0;5=[|
"QQ
#11*.'('+1