a
    RG5dHe                    @   s6  d 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mZ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mZmZmZm Z m!Z! dd
l"m#Z#m$Z$ ddl%m&Z&m'Z'm(Z( ddl)m*Z* ddl+m,Z,m-Z- ddl.m/Z/m0Z0m1Z1m2Z2m3Z3 ddl4m5Z5m6Z6m7Z7 ddl8m9Z9m:Z:m;Z;m<Z<m=Z= ddl>m?Z? ddl@mAZAmBZBmCZC ddlDmEZEmFZF ddlGmHZHmIZImJZJmKZKmLZL ddlMmNZNmOZOmPZPmQZQ ddlRmSZSmTZT ddlUmVZVmWZWmXZX ddlYmZZZm[Z[m\Z\ ddl]m^Z^ ddl_m`Z`maZa ddlbmcZc ddldmeZemfZfmgZgmhZhmiZi ddljmkZk ddllmmZmmnZn ddlompZp dd lqmrZrmsZs dd!ltmuZu dd"lvmwZwmxZx dd#lymzZzm{Z{m|Z| dd$l}m~Z~ dd%lmZ G d&d' d'eZG d(d) d)eZd*d+ Zd,d- Zed.Zd/d0 Zeed1fd2d3ZG d4d5 d5eZd6d7 Zd8d9 ZG d:d; d;eZd<d= Zed1dd>d?Zd@aG dAdB dBeZdCdD ZdEdF ZdGdH ZeddIdJZdKdL ZdMdN ZdOdP ZddQdRZddSdTZddUdVZddWdXZddYdZZdd[d\ZG d]d^ d^eZdd_d`Zed1ddadbZG dcdd ddeZddedfZdgdh Zed1ddidjZG dkdl dleZG dmdn dneZdodp ZG dqdr dreZdsdt Zed1ddudvZG dwdx dxeZG dydz dzeZd{d| ZG d}d~ d~eZdd ZG dd deZdd ZG dd deZdd Zed1dddZG dd deZG dd deZdd ZG dd deZdd Zd@S )z Integral Transforms     )reducewraps)repeat)SpiI)Add)	AppliedUndef	count_ops
Derivativeexpandexpand_complex
expand_mulFunctionLambdaWildFunction)Mul)igcdilcm)
_canonicalGeGtLt
UnequalityEq)default_sort_keyordered)DummysymbolsWild)postorder_traversal)	factorialrf)reargAbs
polar_liftperiodic_argument)explog	exp_polar)coshcothsinhtanhasinh)ceiling)MaxMinsqrt)	Piecewisepiecewise_fold)coscotsintanatan)besselibesseljbesselkbessely)
DiracDelta	Heaviside)erferfcEi)digammagamma
lowergamma)meijerg)	integrateIntegral)_dummy)to_cnf	conjuncts	disjunctsOrAnd)
MatrixBase)_lin_eq2dictPolyNonlinearError)roots)factorPoly)together)CRootOfRootSum)sympy_deprecation_warningSymPyDeprecationWarningignore_warnings)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	transformra   msg	__class__ V/var/www/html/django/DPS/env/lib/python3.9/site-packages/sympy/integrals/transforms.pyr`   @   s    
zIntegralTransformError.__init__)__name__
__module____qualname____doc__r`   __classcell__rg   rg   re   rh   r^   2   s   r^   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   s
   | j d S )z! The function to be transformed. r   argsrb   rg   rg   rh   ra   ]   s    zIntegralTransform.functionc                 C   s
   | j d S )z; The dependent variable of the function to be transformed.    ro   rq   rg   rg   rh   function_variableb   s    z#IntegralTransform.function_variablec                 C   s
   | j d S )z% The independent transform variable.    ro   rq   rg   rg   rh   transform_variableg   s    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.
        )ra   free_symbolsunionru   rs   rq   rg   rg   rh   rv   l   s    zIntegralTransform.free_symbolsc                 K   s   t d S NNotImplementedErrorrb   fxshintsrg   rg   rh   _compute_transformu   s    z$IntegralTransform._compute_transformc                 C   s   t d S rx   ry   rb   r|   r}   r~   rg   rg   rh   _as_integralx   s    zIntegralTransform._as_integralc                 C   s$   t | }|dkr t| jjd d|S )NF )rO   r^   rf   name)rb   extracondrg   rg   rh   _collapse_extra{   s    z!IntegralTransform._collapse_extrac                    s|   d }t  fdd jtD  }|r`z  j j j jfi |}W n ty^   d }Y n0  j}|jstt	|}||fS )Nc                 3   s   | ]}|  jV  qd S rx   )hasrs   .0funcrq   rg   rh   	<genexpr>   s   z2IntegralTransform._try_directly.<locals>.<genexpr>)
anyra   atomsr	   r   rs   ru   r^   is_Addr   )rb   r   TZtry_directlyfnrg   rq   rh   _try_directly   s"    



zIntegralTransform._try_directlyc                    s    dd}  dd}| d< jf i  \}}|dur@|S |jrB| d<  fdd|jD }g }g }|D ]\}	t|	ts|	g}	||	d  t|	d	kr||	d
  qrt|	d	krr||	d
d g7 }qr|dkrt| 	 }nt| }|s|S z6
|}t|r t|gt| W S ||fW S W n ty@   Y n0 |rZt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f i  qS )rr   N)rf   listrp   doitr   r}   r   rb   rg   rh   
<listcomp>   s   z*IntegralTransform.doit.<locals>.<listcomp>r   rt   rr   )popr   r   rp   
isinstancetupleappendlenr   r   r   r\   r^   rf   _namera   as_coeff_mulrs   r   r   )rb   r   r   r   r   r   resr   ressr}   coeffrestrg   r   rh   r      sN    


zIntegralTransform.doitc                 C   s   |  | j| j| jS rx   )r   ra   rs   ru   rq   rg   rg   rh   as_integral   s    zIntegralTransform.as_integralc                 O   s   | j S rx   )r   )rb   rp   kwargsrg   rg   rh   _eval_rewrite_as_Integral   s    z+IntegralTransform._eval_rewrite_as_IntegralN)ri   rj   rk   rl   propertyra   rs   ru   rv   r   r   r   r   r   r   r   rg   rg   rg   rh   rn   F   s"   



G
rn   c                 C   s4   |r0ddl m} ddlm} ||t| ddS | S )Nr   r   )	powdenestT)polar)sympy.simplifyr   sympy.simplify.powsimpr   r5   )exprr   r   r   rg   rg   rh   	_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   rg   )r   rp   r   r   r   rg   rh   wrapper   s    z0_noconds_.<locals>.make_wrapper.<locals>.wrapper)r   )r   r   defaultr   rh   make_wrapper   s    z_noconds_.<locals>.make_wrapperrg   )r   r   rg   r   rh   	_noconds_   s    r   Fc                 C   s   t | |tjtjfS rx   )rH   r   ZeroInfinity)r|   r}   rg   rg   rh   _default_integrator  s    r   Tc                    s   t dd| ||d  |  |}|tsNt|||tjtjftjfS |j	s`t
d| d|jd \}}|trt
d| dfdd	  fd
dt|D }dd |D }|jdd d |st
d| d|d \}}	}
t|||||	f|
fS )z0 Backend function to compute Mellin transforms. r~   zmellin-transformrr   Mellincould not compute integralr   integral in unexpected formc                    sR  ddl m} tj}tj}tj}tt| }tddd}|D ]
}tj}tj}	g }
t	|D ]}|
tdd t |}|jr|jdv s| s||s|
|g7 }
qX|||}|jr|jdv r|
|g7 }
qX|j|krt|j|	}	qXt|j|}qX|tjur||krt||}q:|	tjur8|	|kr8t|	|}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}   rg   rg   rh   <lambda>3      z:_mellin_transform.<locals>.process_conds.<locals>.<lambda>z==z!=)sympy.solvers.inequalitiesr   r   NegativeInfinityr   truerL   rK   r   rM   replacer#   subsis_Relationalrel_opr   ltsr1   gtsr2   rO   rN   )r   r   abauxcondsr   ca_b_aux_dd_solnr~   rg   rh   process_conds#  sP    




z(_mellin_transform.<locals>.process_condsc                    s   g | ]} |qS rg   rg   r   r   r   rg   rh   r   J  r   z%_mellin_transform.<locals>.<listcomp>c                 S   s   g | ]}|d  dkr|qS )rt   Frg   r   rg   rg   rh   r   K  r   c                 S   s   | d | d  t | d fS )Nr   rr   rt   r
   r   rg   rg   rh   r   L  r   z#_mellin_transform.<locals>.<lambda>keyno convergence found)rJ   r   rI   r   r   r   r   r   r   is_Piecewiser^   rp   rM   sort)r|   r}   s_
integratorr   Fr   r   r   r   r   rg   )r   r~   rh   _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 rx   )r   r{   rg   rg   rh   r   a  s    z"MellinTransform._compute_transformc                 C   s    t |||d   |tjtjfS Nrr   )rI   r   r   r   r   rg   rg   rh   r   d  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rtdd d|S )Nr   rr   TFr   zno combined convergence.)r1   r2   rO   r^   )	rb   r   r   r   r   sasbr   r   rg   rg   rh   r   g  s    

(zMellinTransform._collapse_extraN)ri   rj   rk   rl   r   r   r   r   rg   rg   rg   rh   r   U  s
   	r   c                 K   s   t | ||jf 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
    )r   r   )r|   r}   r~   r   rg   rg   rh   mellin_transformv  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   rr   )r   r   r0   r   rE   )Zm_nr~   r   r   mnrrg   rg   rh   _rewrite_sin  s
    %r   c                   @   s   e Zd ZdZdS )MellinTransformStripErrorzF
    Exception raised by _rewrite_gamma. Mainly for internal use.
    N)ri   rj   rk   rl   rg   rg   rg   rh   r     s   r   c           -         s  t ||g\  fdd}g }tD ]F}|s<q,|jd }|jrZ|d }|\}}	||g7 }q,tt	t
tD ]J}|sq|jd }|jr|d }|\}}	||t g7 }qdd |D }t j|D ]}
|
js|
 qqfdd|D }tdd	 |D r*js6td
ddttdd |D t j }|krt|dkrp}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}s|g7 }q4jstt rTjrj!}j }nt"d}j }|j#r}|dk r| }|||fgt$| 7 }q4nL|sH||\}}s*d| }||| g7 }||| g7 }nq4%rXt&}|' dkr|( d }t)|}t||' krt*+|}||g7 }|fdd|D 7 }q4|, \}}||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 }q4ttr|jd \}}r|dkr|| | dks|dk r|| | dkrt.d|||fg7 }q4ttrTjd }rt|t td|t  t  } }!}"nt/|| \} }!}"||  f|! fg7 }||"g7 }ntt
rjd }|t|ddfttd | dd fg7 }ntt	rЈjd }|ttd | ddfg7 }nNttrjd }|ttd | ddft|dd fg7 }nq4|t| t|  9 }g g g g f\}#}$}%}&||#|%df||&|$dffD ]$\}'}(})|'rb|' \}}|dkr^|dkr^t$t |}|| }*|| }+|j#st0dt1|D ]},|'|*|+|,|  fg7 }'qʈr$|dt d| d  ||t j2   9 }||| g7 }n6|dt d| d  ||t j2    }|||  g7 }qp|dkrx|(3d|  n
|)3| qpqbt| }|#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 r2| k S du rB|  kS | kdkrRdS |  kdkrbdS |rjdS  js|js|| jrdS tddS )zU
        Decide whether pole at c lies to the left of the fundamental strip.
        NTFzPole inside critical strip?)r   r#   r   r   rv   r   )r   is_numer)r   r   rg   rh   left  s     z_rewrite_gamma.<locals>.leftr   rr   c                 S   s   g | ]}|j rt|n|qS rg   )is_extended_realr%   r   rg   rg   rh   r   B  r   z"_rewrite_gamma.<locals>.<listcomp>c                    s   g | ]}|  qS rg   rg   r   )common_coefficientrg   rh   r   H  r   c                 s   s   | ]}|j V  qd S rx   )is_Rationalr   rg   rg   rh   r   I  r   z!_rewrite_gamma.<locals>.<genexpr>GammaNzNonrational multiplierc                 S   s   g | ]}t |jqS rg   )r   qr   rg   rg   rh   r   L  s   c                 S   s   g | ]}t |jqS rg   )r   pr   rg   rg   rh   r   S  r   TFc                    s   t d d|  S )NInverse MellinzUnrecognised form '%s'.)r^   )factr|   rg   rh   	exceptionk  s    z!_rewrite_gamma.<locals>.exceptionc                    s8   |  s t| }| dkr0 | S )z7 Test if arg is of form a*s+b, raise exception if not. rr   )is_polynomialrU   degree
all_coeffs)r$   r   )r  r   r~   rg   rh   
linear_argv  s    

z"_rewrite_gamma.<locals>.linear_argc                    s   g | ]}|  fqS rg   rg   r   )r   r~   rg   rh   r     r   r   z Gammas partially over the strip.)evaluatert   za is not an integerr   )6r   r   rE   r   rp   r   as_independentr   r8   r6   r9   r7   r   Oner   allr   r^   r   r   r   r   r   as_numer_denomr   	make_argsr   zipr   r   is_Powr   r(   baser*   
is_Integerr%   r  rU   r  LTrS   rW   	all_rootsr  NegativeOnerz   r   	TypeErrorrangeHalfr   r   r   )-r|   r~   r   r   r   Zs_multipliersgr$   r   _r}   Zs_multiplierfacexponentnumerdenomrp   facsZdfacsZnumer_gammasZdenom_gammasexponentialsZugammasZlgammasZufacsr  r  Zexp_r   r   rsr   Zgamma1Zgamma2fac_anapbmbqZgammasplusminusnewaZnewckrg   )r   r   r   r  r|   r   r   r~   rh   _rewrite_gamma  sR   ?










$










 
&

 


&&
r(  c              	      s\  t dd| dd| t} t| t| t| fD ]}|jr fdd|jD }dd |D }dd |D }t| } st||	t
d	}||t| f  S z$t|d
 d \}	}
}}}W n ty   Y q0Y n0 zt|	|
||  }W n ty   Y q0Y n0  r"|}nzd
dlm} ||}W n  tyZ   td| dY n0 |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r4td| d|| ||f  S td| ddS )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)r   G
as_meijergr~   stripr}   rg   rh   r     s   z-_inverse_mellin_transform.<locals>.<listcomp>c                 S   s   g | ]}|d  qS )rr   rg   r   r   rg   rg   rh   r     r   c                 S   s   g | ]}|d  qS )r   rg   r/  rg   rg   rh   r     r   )gensr   rr   )hyperexpandr   zCould not calculate integral   Fzdoes not converger   N) rJ   rewriterE   rT   r   r   r   rp   r   r   r@   r   rO   r(  r^   rG   
ValueErrorr   r1  rz   r   r   r%   r$   argumentdeltar   rN   r!  r#  r#   nu)r   r~   x_r.  r-  r  r   r   r   r   r   Cer  r+  hr1  r   rg   r,  rh   r*    sZ    
$


*
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 rx   )r<  _none_sentinelrn   __new__)clsr   r~   r}   r   r   optsrg   rg   rh   r?  M  s
    zInverseMellinTransform.__new__c                 C   s:   | j d | j d  }}|tju r$d }|tju r2d }||fS )Nr2     )rp   r<  r>  )rb   r   r   rg   rg   rh   fundamental_stripT  s    

z(InverseMellinTransform.fundamental_stripc                 K   s   | dd td u r0tttttttt	t
ttthat|D ].}|jr8||r8|jtvr8td|d| q8| j}t||||fi |S )Nr   Tr   zComponent %s not recognised.)r   _allowedr(   rE   r8   r6   r9   r7   r+   r-   r.   r,   r!   r"   r    is_Functionr   r   r^   rC  r*  )rb   r   r~   r}   r   r|   r.  rg   rg   rh   r   ]  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 Nrt   )rf   _crI   r   ImaginaryUnitr   Pi)rb   r   r~   r}   r   rg   rg   rh   r   m  s     
z#InverseMellinTransform._as_integralN)ri   rj   rk   rl   r   r   r>  rG  r?  r   rC  r   r   rg   rg   rg   rh   r<  ?  s   	
r<  c                 K   s$   t | |||d |d jf 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   rr   )r<  r   )r   r~   r}   r.  r   rg   rg   rh   inverse_mellin_transforms  s    5rJ  c                    s   fdd fddfddfdd}d	d
 }ddl m} || } || t} || tfdd} || t|} 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)
    c                    s&   |  krdS | j r"| j kr"| jS d S r   )r  r  r(   )exr   rg   rh   power  s
    z_simplifyconds.<locals>.powerc                    s   |  r| rdS t| tr,| jd } t|tr@|jd }|  r\d| d|  S |}|du rpdS zP|dkrt| t | kdkrW dS |dk rt| t | kdkrW dS W n ty   Y n0 dS )z_ Return True only if |ex1| > |ex2|, False only if |ex1| < |ex2|.
            Else return None. Nr   rr   TF)r   r   r%   rp   r  )ex1ex2r   )r   biggerrL  r~   rg   rh   rO    s$    




  
z_simplifyconds.<locals>.biggerc                    sH   | j st| tr |j s(t|ts(| |k S  | |}|dur@| S | |k S )z simplify x < y N)is_positiver   r%   )r}   yr   rO  rg   rh   replie  s    
z_simplifyconds.<locals>.repliec                    s     | |}|dv rdS t | |S )NTFT)r   )r}   rQ  r   rR  rg   rh   replue  s    
z_simplifyconds.<locals>.repluec                 W   s   | dv rt | S | j| S )NrT  )boolr   )rK  rp   rg   rg   rh   repl  s    z_simplifyconds.<locals>.replr   )collect_absc                    s
    || S rx   rg   )r}   rQ  )rS  rg   rh   r     r   z _simplifyconds.<locals>.<lambda>)sympy.simplify.radsimprX  r   r   r   r   )r   r~   r   rU  rW  rX  rg   )r   rO  rL  rS  r~   rh   _simplifyconds  s     
rZ  c                 C   s   t | | tS )zs
    Expand an expression involving DiractDelta to get it as a linear
    combination of DiracDelta functions.
    )rQ   r   r?   r   rg   rg   rh   expand_dirac_delta  s    r\  c                    s:  t dtdgd}g }g }zt\}}W n tyL   tddY n0 | D ]j\}	}
|	t| }|r||
	d||   qV|	j
d 	djrtddqV||	|
  qVttt  t|g|R   tjtjft| }|ts"t|	|tjtjfS |js6tdd|j
d \}}|tr\t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 |stdd|d \}}fdd}|rt||}t||}t|	|||t||fS )z The backend function for Laplace transforms.

    This backend assumes that the frontend has already split sums
    such that `f` is to an addition anymore.
    r~   r   excludeLaplacez'could not expand DiracDelta expressionsr   znot implemented yet.r   r   c                    s  ddl m} tj}tj}tt| } tdtgd\}}}}}}	}
|t	t
| |  |k |t	t
| |  |kt	t| | | ||k t	t| | | ||kt	tt| | | ||k t	tt| | | ||kf}| D ]}tj}g }t|D ]F}|jr0|jjv r0|j}|jrNt|ttfrN|j}|D ]}||  rR qpqR r | jr |  |  td krt |   dk }||t|t	t
|
  | t	| |	   dk   s.|t|t	t| |
 ||  t	| |	  dk   st||tt	tt| |
 || t	| |	   dk   rt fdd||||	|
fD rt | k}|tdd	 t}|jr|jd
v s| s| s||g7 }q||}|jr |jd
v r.||g7 }q|j!krHt"ddnt#|j!|}q|tjurpt$||}qt%|t&| }q||jr|j'n|fS )z7 Turn ``conds`` into a strip and auxiliary conditions. r   r   zp q w1 w2 w3 w4 w5r@  r^  rt   c                 3   s   | ]} | j V  qd S rx   )rP  )r   wildr   rg   rh   r   _  r   z<_laplace_transform.<locals>.process_conds.<locals>.<genexpr>c                 S   s   |    d S r   )r   r   r   rg   rg   rh   r   b  r   z;_laplace_transform.<locals>.process_conds.<locals>.<lambda>r   r_  zconvergence not in half-plane?)(r   r   r   r   r   rL   rK   r   r   r%   r$   r'   r&   r   rM   r   rhsrv   reversedr   r   r   reversedsignmatchrP  r   r#   r6   r	  r   r   r   r   r   r^   r2   r1   rO   rN   	canonical)r   r   r   r   r   r   w1w2Zw3Zw4Zw5patternsr   r   r   r   patr   r   )r|   r~   r   rb  rh   r   9  s      


&:4"(


z)_laplace_transform.<locals>.process_condsc                    s   g | ]} |qS rg   rg   r   r   rg   rh   r   x  r   z&_laplace_transform.<locals>.<listcomp>c                 S   s*   g | ]"}|d  dkr|d t jur|qS )rr   Fr   )r   r   r   rg   rg   rh   r   y  r   c                 S   s   g | ]}|d  dkr|qS )rr   Frg   r   rg   rg   rh   r   {  r   c                 S   s   | dv rdS |   S )NrT  r   r   r[  rg   rg   rh   cnt~  s    z_laplace_transform.<locals>.cntc                    s   | d   | d fS Nr   rr   rg   r   )rl  rg   rh   r     r   z$_laplace_transform.<locals>.<lambda>r   r   c                    s   |   S rx   )r   r[  )r~   r   rg   rh   sbs  s    z_laplace_transform.<locals>.sbs)r   r   r\  rR   r^   itemsrf  r?   r   r   rp   is_zeror   rH   r(   r   r   r   r   rI   r   r   r   r   rM   r   r   r   rZ  r   )r|   r   r   r   r   Z	deltazeroZdeltanonzeroZintegratableZ	deltadictZ
dirac_funcZdirac_coeffr   r   r   r   Zconds2r   rn  rg   )rl  r|   r   r~   r   r   rh   _laplace_transform  sf    
 ?rq  c                    sT   | j }t| j}t| jdkr"| S  fdd|D }|jrH||  S || S dS )a  
    This is an internal helper function that traverses through the epression
    tree of `f(t)` and collects arguments. The purpose of it is that
    anything like `f(w*t-1*t-c)` will be written as `f((w-1)*t-c)` such that
    it can match `f(a*t+b)`.
    r   c                    s   g | ]}t | qS rg   _laplace_deep_collect)r   r$   r   rg   rh   r     r   z)_laplace_deep_collect.<locals>.<listcomp>N)r   r   rp   r   r   collect)r|   r   r   rp   rg   rt  rh   rs    s    
rs  c           	   ]      s(  t d gd}t d gd}t d gd}t d gd}t d gd} fdd}||| tjtj|ft|  | t| | | t| tt|d	k|d	kt|d	k |d	ktj|ft|  | td	tt|d	k |d	kt|d	k|d	ktj|fd
d
| tjtj|ft	|  | t| | | | t|d	k|d	ktj|ft	|  | d
t| | |  | t|d	k |d	k tj|ft	|  | d
| t|d	k|d	ktj|ft	|  | d	t|d	k |d	ktj|f d
|d  tjtj|fd
|  |  t| | |  t
| | |  | |d	ktj|fd
t|  |  t|t | t|| |  tt|| |  | |d	ktj|ft  |  tt| tt| t||  tt||   tjtj|f|  | td d  d|td
 d   dt| | td
d   t|| |  tt|| |  |  |d	ktj|f td
d   | d  t| td
d  t|td
d   t||  tt||   tjtj|fd
|t   d   t|td
d   t||  tt||  tjtj|f | t|d
 ||d
   |dktj|f|  | | t|d
 || | t| | |  ||d
   | t|dk|d	ktj|f |  |  || t|d
  t| ||  |dktj|ft|  | t| ||  tj||f t|  |  t| || d  tj||f | t|   t|d
 || |d
   |dk||ft|  d  ttd | t|d d |  t|td|   |d	ktj|f t|  d   d
d|  dtt d| tdd   | t|td|    tjtj|ft|   dt||  td
dt||   |d	ktj|ft t|    td
d tt|d   d
dt||    tdt||   |d	ktj|ft|   t  tt| tdt||   |d	ktj|ft|    t   tt| tdt||   |d	ktj|f | t|    d|| |d
 d   t|d
 dt||   |d	ktj|ftdt|   |d tt| |td d   t||  tt||   tjtj|ftdt|   t  t| td
d  t||  tt||  tjtj|ft|  ||d |d   tjt||ft|  d d|d  |d d|d  |d    tjtd| |ft|    t|| ||  d tj||f | t|   t|d
 d || | d
  || | d
    |dkt||ftdt|   tt| | t| t||  tjtj|ft tdt|    ttd
d  |td d   |d |  t||  tt||  |td
d  |d   tjtj|ftdt|   t  ttd
d  |td
 d   t||  tt||  tjtj|ftt|  d t  ttd
d  d |td
 d   t|| d
  tjtj|ft|  ||d |d   tjt||ft|  d |d d|d   |d d|d  |d    tjtd| |f | t|   t|d
 d || | d
  || | d
    |dkt||ftdt|   d
| tt| | t| t||  tt||   tjtj|ft tdt|    ttd
d  |td d   |d |  t||  tjtj|ftdt|   t  ttd
d  |td
 d   t||  tjtj|ftt|  d t  ttd
d  d |td
 d   t|| d
  tjtj|ft|  t|| tj  | |d	ktj|ftd
|   t||  | t
| |  tjtj|ft|  | t|t|| | | | t
| |   | | |d	ktj|ft t  tt|  td| tj  tjtj|f | t  t|d
 || d
   t|d
 t|  |dktj|ft|  d t|| tj d td d  | |d	ktj|ft|   t  t|| tj  ||  tj| |ft|  ||d |d   tjtj|ftt|  ||d |d   tt| d |  |d	ktj|ft|    t|| tjtj|ft|  d   td
d|d  |d   d tjtj|ft|  d  d  |td| |  |td
d|d  |d    d  tjtj|ftdt|   tt| | t| t| |  |d	ktj|ftdt|     ttt||  |d	ktj|ft|  ||d |d   tjtj|ft|  d |d d|d   |d d|d    | tjtj|ft tdt|    ttd |td d   |d|   t| |  |d	ktj|ftdt|   t  tt| t| |  |d	ktj|ft|  t|   d| | | |d || d   |d || d   tjtj|ft|  t|   ||d |d  |d   |d || d   |d || d   tjtj|ft|  t|   ||d |d  |d   |d || d   |d || d   tjtj|ft|  t|   ||| d |d   tj||ft|  t|   || || d |d   tj||ft|  t|d d| d  t|d|   | |d	ktj|ftt|  t|t||  | |d	ktj|ft|  tt|   t|t| ||  |d	k||ftt|  d d
tt||   | |d	ktj|ftt|  t|| t| t||  | |d	ktj|ft|  tt|   d
|t||   |d	ktj|ftt|  d tt||  | |d	ktj|ft||  || t|d |d  |t|d |d   |   t|d	k|dktj|f | t||   d| tt t|tj  ||  |d |d  | tj   tt|d	k|tj kt||tj|f | t||   d|d
  tt t|tdd   ||  | |d |d  | tdd    tt|d	k|dkt||d
 tj|ftd	dt|   t| | | |d	ktj|f | t|dt|    ||d  || d
   t| |  tt|d	k|dkt||tj tj|ftd	|t d |    t|| |t|d |d    t|d |d   |d	ktj|ft||  || t|d |d  |t|d |d   |   t|d	k|dkt||f | t||   d| tt t|tj  ||  |d |d  | tj   tt|d	k|tj kt||t||f | t||   d|d
  tt t|tdd   ||  | |d |d  | tdd    tt|d	k|dkt||d
 t||f | t|dt|    ||d  || d
   t||  tt|d	k|dkt||tj tj|ftd	|  dt t ||  t|d |d   |d	ktj|ftd	|  t|t|d |d   t|d |d   |d	kt||fgW}|S )z
    This is an internal helper function that returns the table of Laplace
    transfrom rules in terms of the time variable `t` and the frequency
    variable `s`.  It is used by `_laplace_apply_rules`.
    r   r]  r   r   tauomegac                    s
   t |  S rx   rr  r   rt  rg   rh   r     r   z&_laplace_build_rules.<locals>.<lambda>r   rr   rt   r2  r   g      ?rB        )!r   r   r   r   r?   r(   r%   rN   rO   r@   rC   r3   r   rB   rE   rF   r=   r-   r)   rA   r+   
EulerGammarD   r8   r,   r:   r6   r<   r  r   r;   r>   r/   )	r   r~   r   r   r   rv  rw  ZdcoZlaplace_transform_rulesrg   rt  rh   _laplace_build_rules  s   **


(62
XB
.
6"
6B
$B0@
.

&2"
`
<
4

.2:
8
,
4


4
,$


&


6
$

*
66
B
B

*
"6@&T&&(66@(T($(&.    ir|  c                 K   s$   | dd }|r| ||fS | S dS )z
    Internal helper function that will return `(f, a, c)` unless `**hints`
    contains `noconds=True`, in which case it will only return `f`.
    r   FN)get)r|   r   r   r   r   rg   rg   rh   _laplace_cr  s    
r~  c                    s  | dd}td gd}tddd}| j dd	\}}	|	|}
|
r|
| jd
  }||  }|r|| d
krtd td| |
|f  td || dkr|dkrt fdd|
| 	t
D s|t|
|   ||d S |t|
|   |fi | S nrt|
|   |||  fd|i|}z"|\}}}|||  | ||fW S  ty   |||  |  Y S 0 dS )a  
    This internal helper function tries to apply the time-scaling rule of the
    Laplace transform and returns `None` if it cannot do it.

    Time-scaling means the following: if $F(s)$ is the Laplace transform of,
    $f(t)$, then, for any $a>0$, the Laplace transform of $f(at)$ will be
    $\frac1a F(\frac{s}{a})$. This scaling will also affect the transform's
    convergence plane.
    r   Tr   r]  r  rr   nargsFas_Addr   _laplace_apply_rules match:      f:    %s ( %s, %s )z1      rule: amplitude and time scaling (1.1, 1.2)c                 3   s   | ]}|  V  qd S rx   )r   r   rt  rg   rh   r   8  r   z*_laplace_rule_timescale.<locals>.<genexpr>r   r   N)r   r   r   r  rf  rp   ru  r]   r   r   r	   rq  r   LaplaceTransform_laplace_apply_rulesr  )r|   r   r~   r   r   r   r   r  r'  r   ma1r$   ma2Lr   r   r   rg   rt  rh   _laplace_rule_timescale!  s>    

$
r  c                 K   sh  | dd td|gd}td|gd}td}tddd	}| j|d
d\}	}
|
t|| }|rd|| || }|| jd ||| }|rd|| dkrd|rd|| || krdtd td| |||f  td t	|| 
|||fd|i|}z,|\}}}|	t||  |  | ||fW S  tyb   |	t||  |  |  Y S 0 dS )z
    This internal helper function tries to transform a product containing the
    `Heaviside` function and returns `None` if it cannot do it.
    r   Tr   r]  r   rQ  r  rr   r  Fr  r   r  z      f:    %s ( %s, %s, %s )z      rule: time shift (1.3)r   N)r   r   r   r  rf  r@   rp   ru  r]   r  r   r(   r  )r|   r   r~   r   r   r   r   rQ  r  r'  r   r  r  Zma3r  r   r   r   rg   rg   rh   _laplace_rule_heavisideH  s*    ,"
" r  c                 K   s   | dd td|gd}td}td}| j|dd\}}	|	t|| }
|
r|
| ||| }|rtd	 td
| |
|f  td t|
| ||||  fd|i|}z|\}}}||||  |fW S  ty   | Y S 0 dS )z
    This internal helper function tries to transform a product containing the
    `exp` function and returns `None` if it cannot do it.
    r   Tr   r]  rQ  zFr  r  r  z#      rule: multiply with exp (1.5)r   N)	r   r   r  rf  r(   ru  r]   r  r  )r|   r   r~   r   r   r   rQ  r  r'  r   r  r  r  r   r   r   rg   rg   rh   _laplace_rule_expd  s&    $

r  c                 K   sB  | dd}td|gd}td}td}| j|dd\}	}
t|d	d
dd
ft|dd
d
d
ft|dt dtft|dd
d
tfg}|D ]}|\}}}}}|
|| }|r|| 	||| }|rt
d t
d| ||f  t
d|j|f  t|| ||fd|i|}zv|\}}}|d
kr4t|| }nd}|||||||   |||||||       d || |fW   S  ty:   |dkr|dkr|||||||   |||||||       d  Y   S |||||||   |||||||      d  Y   S Y q0 qdS )z
    This internal helper function tries to transform a product containing a
    trigonometric function (`sin`, `cos`, `sinh`, `cosh`, ) and returns
    `None` if it cannot do it.
    r   Tr   r]  rQ  r  Fr  z1.6rr   r   z1.7z1.81.9r  r  z!      rule: multiply with %s (%s)r   r   rt   N)r   r   r  r-   r+   r8   r   r6   rf  ru  r]   r   r  r%   r   r   r  )r|   r   r~   r   r   r   r   rQ  r  r'  r   Z	trigrulesZtrigrulefmr7  s1s2sdr  r  r  r   r   r   Zcp_shiftrg   rg   rh   _laplace_rule_trig~  sV     "



r  c                 K   sR  | dd td|gd}td}td|gd}tddd	}| |t|||f }	|	rN|	| jd
 |krN|	| jrNtd td| f  td g }
t|	| D ]b}|d
kr|	| 	|
|d
}n t|	| 	|||f
|d
}|
||	| | d  |  q||	|  t|	| 	|||fd|i| }|	| |t|
   S dS )z
    This internal helper function tries to transform an expression containing
    a derivative of an undefined function and returns `None` if it cannot
    do it.
    r   Tr   r]  rQ  r   r  rr   r  r   r        f:    %sz(      rule: time derivative (1.11, 1.12)r   N)r   r   r   rf  r   rp   
is_integerr]   r  r   r   r   r  r   )r|   r   r~   r   r   r   rQ  r   r  r  r   r'  r   rg   rg   rh   _laplace_rule_diff  s*    &  $r  c              	   K   s:  | j |dd\}}t||}|D ]\}}	}
}}|||}|r td td|f  td||	f  z`td|
f  |
|}td|
|f  |dkrt||	| ||tjfi |W   S W q  ty   td	 Y q 0 q | 	t
rd
S tttttg}|D ]0}|| ||fd|i|}|d
ur|  S qd
S )aM  
    Helper function for the class LaplaceTransform.

    This function does a Laplace transform based on rules and, after
    applying the rules, hands the rest over to `_laplace_transform`, which
    will attempt to integrate.

    If it is called with `doit=False`, then it will instead return
    `LaplaceTransform` objects.
    Fr  r  r  z      rule: %s o---o %sz      try   %sz      check %s -> %sTz#_laplace_apply_rules did not match.Nr   )r  r|  rf  r]   xreplacer~  r   r   	Exceptionr   r?   r  r  r  r  r  )r|   r   r~   r   r   r'  r   Zsimple_rulesZt_domZs_domcheckplaneprepmar   Z
prog_rulesZp_ruler  rg   rg   rh   r    s<    



r  c                   @   s4   e Zd ZdZdZdd Zdd Zdd Zd	d
 ZdS )r  z
    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.
    r_  c                 K   sd   t |||fi |}|d u r\|dd}td|f  td|f  t|||fd|i|S |S d S )Nr   Tz0_laplace_apply_rules could not match function %sz    hints: %s)r  r   r]   rq  )rb   r|   r   r~   r   r  r   rg   rg   rh   r     s    z#LaplaceTransform._compute_transformc                 C   s"   t |t| |  |tjtjfS rx   )rI   r(   r   r   r   )rb   r|   r   r~   rg   rg   rh   r     s    zLaplaceTransform._as_integralc                 C   sV   g }g }|D ]\}}| | | | qt| }t| }|dkrNtdd d||fS )NFr_  zNo combined convergence.)r   rO   r1   r^   )rb   r   r   Zplanesr  r   rg   rg   rh   r     s    
z LaplaceTransform._collapse_extrac                 K   sl   | j }td|f  | j}| j}d }|jsdt|}z| j|||fi |}W n tyb   d }Y n0 ||fS )Nz----> _try_directly: %s)ra   r]   rs   ru   r   r   r   r^   )rb   r   r   t_r   r  rg   rg   rh   r     s    
zLaplaceTransform._try_directlyN)	ri   rj   rk   rl   r   r   r   r   r   rg   rg   rg   rh   r    s   	
r  c                    s  t d| f  t| t rt| d r dd }|r|rtdddd tt& |  fd	d
W  d   S 1 s0    Y  nj fdd| D }|rt	| \}}}	t
| g | j|R  }
|
t| t|	 fS t
| g | j|R  S t| jf i  S )ak	  
    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

    .. math :: a < \operatorname{Re}(s)

    This function returns ``(F, a, cond)`` where ``F`` is the Laplace
    transform of ``f``, `a` is the half-plane of convergence, and `cond` are
    auxiliary convergence conditions.

    The implementation is rule-based, and if you are interested in which
    rules are applied, and whether integration is attemped, you can switch
    debug information on by setting ``sympy.SYMPY_DEBUG=True``.

    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 implicitly as

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

    by applying rules.

    If the integral cannot be fully 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 import DiracDelta, exp, laplace_transform
    >>> from sympy.abc import t, s, a
    >>> laplace_transform(t**4, t, s)
    (24/s**5, 0, True)
    >>> 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)
    (s/(a + s), Max(0, -a), True)

    See Also
    ========

    inverse_laplace_transform, mellin_transform, fourier_transform
    hankel_transform, inverse_hankel_transform

    z$
***** laplace_transform(%s, %s, %s)	applyfuncr   Fz
Calling laplace_transform() on a Matrix with noconds=False (the default) is
deprecated. Either noconds=True or use legacy_matrix=False to get the new
behavior.
                r  z#deprecated-laplace-transform-matrix)deprecated_since_versionactive_deprecations_targetc                    s   t | fi  S rx   laplace_transform)fijr   r~   r   rg   rh   r     r   z#laplace_transform.<locals>.<lambda>Nc                    s    g | ]}t |fi  qS rg   r  )r   r  r  rg   rh   r     r   z%laplace_transform.<locals>.<listcomp>)r]   r   rP   hasattrr}  rY   r[   rZ   r  r  typeshaper1   rO   r  r   )r|   r   r~   Zlegacy_matrixr   r   Zelements_transelementsavals
conditionsZ	f_laplacerg   r  rh   r  .  s$    B
6r  c                    s  ddl m}m  tddd fdd}| r>| } | jrxtfdd	| jD  }t	|
|dfS z(t| t d
tjfddd\}}W n ty   d
}Y n0 |d
u r$|| }|d
u rtd|d|jr|jd \}}|trtd|dntj}|t|}|jr<|
||fS tdtjffdd	}	|t|	}dd }
|t|
}t	|
||fS )z6 The backend function for inverse Laplace transforms. r   )meijerint_inversion_get_coeff_expr   Tr   c                     s   t | dkrt|  S | d jd j} |\}}| d jd }| d jd }tdt| |  | t| dt|  |  S )z3 Simplify a piecewise expression from hyperexpand. r2  rt   r   rr   )r   r4   rp   r5  r@   r%   )rp   r$   r   r  e1e2)r  r   rg   rh   pw_simp  s    z+_inverse_laplace_transform.<locals>.pw_simpc                    s   g | ]}t | qS rg   )_inverse_laplace_transform)r   X)r  r~   r   r   rg   rh   r     s   z._inverse_laplace_transform.<locals>.<listcomp>NF)r   r   Inverse Laplacer   z(inversion integral of unrecognised form.uc                    s   |  t  }| r&t| |S ddlm} ||dk}|jkrbt|j}t | |S t|j}t |  |S d S )Nr   r   )	r   r(   r   r@   r   r   r   r)   r   )r$   H0r   r   relr'  )r   r  rg   rh   simp_heaviside  s    




z2_inverse_laplace_transform.<locals>.simp_heavisidec                 S   s   t t| S rx   )r   r(   )r$   rg   rg   rh   simp_exp  s    z,_inverse_laplace_transform.<locals>.simp_exp)sympy.integrals.meijerintr  r  r   is_rational_functionapartr   r   rp   r   r   rJ  r(   r   r   r^   r   r   rI   r   r   r4   r  r@   )r   r~   r  r  r   r  r  r|   r   r  r  rg   )r  r  r~   r   r   r  rh   r    sH    



r  c                   @   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 )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.
    r  r=  r   c                 K   s(   |d u rt j}tj| ||||fi |S rx   )r  r>  rn   r?  )r@  r   r~   r}   r  rA  rg   rg   rh   r?    s    zInverseLaplaceTransform.__new__c                 C   s   | j d }|tju rd }|S Nr2  )rp   r  r>  )rb   r  rg   rg   rh   fundamental_plane  s    

z)InverseLaplaceTransform.fundamental_planec                 K   s   t |||| jfi |S rx   )r  r  )rb   r   r~   r   r   rg   rg   rh   r     s    z*InverseLaplaceTransform._compute_transformc                 C   sL   | j j}tt|| | ||tjtj  |tjtj  fdtj tj  S rF  )rf   rG  rI   r(   r   rH  r   rI  )rb   r   r~   r   r   rg   rg   rh   r     s     z$InverseLaplaceTransform._as_integralN)ri   rj   rk   rl   r   r   r>  rG  r?  r   r  r   r   rg   rg   rg   rh   r    s   	
r  c                    sF   t | tr,t| dr,|  fddS t| jf 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 import inverse_laplace_transform, 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
    r  c                    s   t | fi  S rx   )inverse_laplace_transform)ZFijr   r  r~   r   rg   rh   r   0  r   z+inverse_laplace_transform.<locals>.<lambda>)r   rP   r  r  r  r   )r   r~   r   r  r   rg   r  rh   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, nr`  c                    sR   |  s| S | jr | S | jr*| S | jr8| S t| trJ| S td S rx   )r   r   is_Mulr  r   rX   rz   r:  )_ilt_add_ilt_mul_ilt_pow_ilt_rootsumr~   rg   rh   _ilt8  s    

z#_fast_inverse_laplace.<locals>._iltc                    s   | j t | j S rx   )r   maprp   r  r  rg   rh   r  F  s    z'_fast_inverse_laplace.<locals>._ilt_addc                    s$   |  \}}|jrt| | S rx   )r  r  rz   )r:  r   r   )r  r~   rg   rh   r  I  s    z'_fast_inverse_laplace.<locals>._ilt_mulc                    s   |      }|d ur| |  |   }}}|jr||dk r|| d  t||    ||  t|   S |dkrt||   | S td S rm  )rf  r  r(   rE   rz   )r:  rf  nmamr"  )r   r   r   r~   r   rg   rh   r  O  s    4z'_fast_inverse_laplace.<locals>._ilt_powc                    s,   | j j}| j j\}t| jt|t |S rx   )funr   	variablesrX   polyr   rV   )r:  r   variabler  rg   rh   r  Y  s    
z+_fast_inverse_laplace.<locals>._ilt_rootsum)r   r   )r:  r~   r   rg   )
r  r  r  r  r  r   r   r   r~   r   rh   _fast_inverse_laplace4  s    
r  c           
      C   s   t ||  t|tj | |  |tjtjf}|tsHt||tj	fS t | |tjtjf}|tjtjtj
fv sz|trt|| d|jst|| d|jd \}}	|trt|| 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   )rH   r(   r   rH  r   r   r   rI   r   r   NaNr^   r   rp   )
r|   r}   r'  r   r   r   r   r   Z
integral_fr   rg   rg   rh   _fourier_transforme  s    .

r  c                   @   s0   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   s   t d| j d S Nz,Class %s must implement a(self) but does notrz   rf   rq   rg   rg   rh   r     s    zFourierTypeTransform.ac                 C   s   t d| j d S Nz,Class %s must implement b(self) but does notr  rq   rg   rg   rh   r     s    zFourierTypeTransform.bc                 K   s&   t ||||  |  | jjfi |S rx   )r  r   r   rf   r   rb   r|   r}   r'  r   rg   rg   rh   r     s    z'FourierTypeTransform._compute_transformc                 C   s>   |   }|  }t|| t|tj | |  |tjtjfS rx   )r   r   rI   r(   r   rH  r   r   )rb   r|   r}   r'  r   r   rg   rg   rh   r     s    z!FourierTypeTransform._as_integralNri   rj   rk   rl   r   r   r   r   rg   rg   rg   rh   r    s
   r  c                   @   s$   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   s   dS r   rg   rq   rg   rg   rh   r     s    zFourierTransform.ac                 C   s
   dt j S )Nrx  r   rI  rq   rg   rg   rh   r     s    zFourierTransform.bNri   rj   rk   rl   r   r   r   rg   rg   rg   rh   r    s   	r  c                 K   s   t | ||jf i |S )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
    )r  r   r|   r}   r'  r   rg   rg   rh   fourier_transform  s    'r  c                   @   s$   e Zd ZdZdZdd Zdd ZdS )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   s   dS r   rg   rq   rg   rg   rh   r     s    zInverseFourierTransform.ac                 C   s
   dt j S rF  r  rq   rg   rg   rh   r     s    zInverseFourierTransform.bNr  rg   rg   rg   rh   r    s   	r  c                 K   s   t | ||jf i |S )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
    )r  r   r   r'  r}   r   rg   rg   rh   inverse_fourier_transform  s    'r  c           
      C   s   t ||  ||| |  |tjtjf}|tsBt||tjfS |jsTt	|| d|j
d \}}	|trxt	|| 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   )rH   r   r   r   r   rI   r   r   r   r^   rp   )
r|   r}   r'  r   r   Kr   r   r   r   rg   rg   rh   _sine_cosine_transform	  s    
(

r  c                   @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )SineCosineTypeTransformzK
    Base class for sine and cosine transforms.
    Specify cls._kern.
    c                 C   s   t d| j d S r  r  rq   rg   rg   rh   r   7	  s    zSineCosineTypeTransform.ac                 C   s   t d| j d S r  r  rq   rg   rg   rh   r   ;	  s    zSineCosineTypeTransform.bc                 K   s,   t ||||  |  | jj| jjfi |S rx   )r  r   r   rf   _kernr   r  rg   rg   rh   r   @	  s    z*SineCosineTypeTransform._compute_transformc                 C   s@   |   }|  }| jj}t|| ||| |  |tjtjfS rx   )r   r   rf   r  rI   r   r   r   )rb   r|   r}   r'  r   r   r  rg   rg   rh   r   F	  s    z$SineCosineTypeTransform._as_integralNr  rg   rg   rg   rh   r  1	  s
   r  c                   @   s(   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   s   t dt t S rF  r3   r   rq   rg   rg   rh   r   Z	  s    zSineTransform.ac                 C   s   t jS rx   r   r  rq   rg   rg   rh   r   ]	  s    zSineTransform.bN	ri   rj   rk   rl   r   r8   r  r   r   rg   rg   rg   rh   r  M	  s
   	r  c                 K   s   t | ||jf i |S )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
    )r  r   r  rg   rg   rh   sine_transforma	  s    $r  c                   @   s(   e Zd ZdZdZeZdd Zdd ZdS )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   s   t dt t S rF  r  rq   rg   rg   rh   r   	  s    zInverseSineTransform.ac                 C   s   t jS rx   r  rq   rg   rg   rh   r   	  s    zInverseSineTransform.bNr  rg   rg   rg   rh   r  	  s
   	r  c                 K   s   t | ||jf i |S )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
    )r  r   r  rg   rg   rh   inverse_sine_transform	  s    %r  c                   @   s(   e Zd ZdZdZeZdd Zdd ZdS )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   s   t dt t S rF  r  rq   rg   rg   rh   r   	  s    zCosineTransform.ac                 C   s   t jS rx   r  rq   rg   rg   rh   r   	  s    zCosineTransform.bN	ri   rj   rk   rl   r   r6   r  r   r   rg   rg   rg   rh   r  	  s
   	r  c                 K   s   t | ||jf i |S )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
    )r  r   r  rg   rg   rh   cosine_transform	  s    $r  c                   @   s(   e Zd ZdZdZeZdd Zdd ZdS )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   s   t dt t S rF  r  rq   rg   rg   rh   r   
  s    zInverseCosineTransform.ac                 C   s   t jS rx   r  rq   rg   rg   rh   r   
  s    zInverseCosineTransform.bNr  rg   rg   rg   rh   r  	  s
   	r  c                 K   s   t | ||jf i |S )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
    )r  r   r  rg   rg   rh   inverse_cosine_transform
  s    $r  c                 C   s   t | t|||  | |tjtjf}|ts@t||tjfS |j	sRt
|| d|jd \}}|trvt
|| 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   )rH   r<   r   r   r   r   rI   r   r   r   r^   rp   )r|   r   r'  r7  r   r   r   r   rg   rg   rh   _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  )r   ra   rs   ru   rp   )rb   r   rg   rg   rh   r   Y
  s    zHankelTypeTransform.doitc                 K   s   t ||||| jfi |S rx   )r  r   )rb   r|   r   r'  r7  r   rg   rg   rh   r   `
  s    z&HankelTypeTransform._compute_transformc                 C   s&   t |t|||  | |tjtjfS rx   )rI   r<   r   r   r   )rb   r|   r   r'  r7  rg   rg   rh   r   c
  s    z HankelTypeTransform._as_integralc                 C   s   |  | j| j| j| jd S r  )r   ra   rs   ru   rp   rq   rg   rg   rh   r   f
  s
    zHankelTypeTransform.as_integralN)	ri   rj   rk   rl   r   r   r   r   r   rg   rg   rg   rh   r  T
  s   r  c                   @   s   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ri   rj   rk   rl   r   rg   rg   rg   rh   r  n
  s   	r  c                 K   s   t | |||jf 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
    )r  r   )r|   r   r'  r7  r   rg   rg   rh   hankel_transform{
  s    .r  c                   @   s   e Zd ZdZdZdS )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  rg   rg   rg   rh   r  
  s   	r  c                 K   s   t | |||jf i |S )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
    )r  r   )r   r'  r   r7  r   rg   rg   rh   inverse_hankel_transform
  s    .r  )F)T)T)T)T)T)T)T)T)T)N)T)T)T)rl   	functoolsr   r   	itertoolsr   
sympy.corer   r   r   sympy.core.addr   sympy.core.functionr	   r
   r   r   r   r   r   r   r   sympy.core.mulr   sympy.core.numbersr   r   sympy.core.relationalr   r   r   r   r   r   sympy.core.sortingr   r   sympy.core.symbolr   r   r   sympy.core.traversalr    (sympy.functions.combinatorial.factorialsr!   r"   $sympy.functions.elementary.complexesr#   r$   r%   r&   r'   &sympy.functions.elementary.exponentialr(   r)   r*   %sympy.functions.elementary.hyperbolicr+   r,   r-   r.   r/   #sympy.functions.elementary.integersr0   (sympy.functions.elementary.miscellaneousr1   r2   r3   $sympy.functions.elementary.piecewiser4   r5   (sympy.functions.elementary.trigonometricr6   r7   r8   r9   r:   sympy.functions.special.besselr;   r<   r=   r>   'sympy.functions.special.delta_functionsr?   r@   'sympy.functions.special.error_functionsrA   rB   rC   'sympy.functions.special.gamma_functionsrD   rE   rF   sympy.functions.special.hyperrG   sympy.integralsrH   rI   r  rJ   sympy.logic.boolalgrK   rL   rM   rN   rO   sympy.matrices.matricesrP   Zsympy.polys.matrices.linsolverQ   rR   sympy.polys.polyrootsrS   sympy.polys.polytoolsrT   rU   sympy.polys.rationaltoolsrV   sympy.polys.rootoftoolsrW   rX   sympy.utilities.exceptionsrY   rZ   r[   sympy.utilities.iterablesr\   sympy.utilities.miscr]   rz   r^   rn   r   r   Z_nocondsr   r   r   r   r   r4  r   r(  r*  rD  r<  rJ  rZ  r\  rq  rs  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  r  r  r  r  r  r  r  r  r  rg   rg   rg   rh   <module>   s   ,  D!,-  -:4<X  w
'


5

)5
bP#
01*.'('+1