a
    <bd                    @   s^  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{ dd$l|m}Z} dd%l~mZ dd&lmZmZmZ dd'lmZ dd(lmZ G d)d* d*eZG d+d, d,eZd-d. Zd/d0 Zed1Zd2d3 Zeed4fd5d6ZG d7d8 d8eZd9d: Zd;d< ZG d=d> d>eZd?d@ Zed4ddAdBZdCaG dDdE dEeZdFdG ZdHdI ZdJdK ZeddLdMZdNdO ZdPdQ ZdRdS ZddTdUZddVdWZddXdYZddZd[Zdd\d]Zdd^d_ZG d`da daeZddbdcZed4ddddeZG dfdg dgeZddhdiZdjdk Zed4ddldmZG dndo doeZG dpdq dqeZdrds ZG dtdu dueZdvdw Zed4ddxdyZG dzd{ d{eZG d|d} d}eZd~d ZG dd deZdd ZG dd deZdd ZG dd deZdd Zed4dddZG dd deZG dd deZdd ZG dd deZdd ZdCS )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)simplifyhyperexpand)	powdenest)_solve_inequality)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)selfZ	transformre   msg	__class__ j/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/site-packages/sympy/integrals/transforms.pyrd   C   s    
zIntegralTransformError.__init__)__name__
__module____qualname____doc__rd   __classcell__rj   rj   rh   rk   rb   5   s   rb   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rf   rj   rj   rk   re   `   s    zIntegralTransform.functionc                 C   s
   | j d S )z; The dependent variable of the function to be transformed.    rr   rt   rj   rj   rk   function_variablee   s    z#IntegralTransform.function_variablec                 C   s
   | j d S )z% The independent transform variable.    rr   rt   rj   rj   rk   transform_variablej   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.
        )re   free_symbolsunionrx   rv   rt   rj   rj   rk   ry   o   s    zIntegralTransform.free_symbolsc                 K   s   t d S NNotImplementedErrorrf   fxshintsrj   rj   rk   _compute_transformx   s    z$IntegralTransform._compute_transformc                 C   s   t d S r{   r|   rf   r   r   r   rj   rj   rk   _as_integral{   s    zIntegralTransform._as_integralc                 C   s$   t | }|dkr t| jjd d|S )NF )rO   rb   ri   name)rf   extracondrj   rj   rk   _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 r{   )hasrv   .0funcrt   rj   rk   	<genexpr>   s   z2IntegralTransform._try_directly.<locals>.<genexpr>)
anyre   atomsr	   r   rv   rx   rb   is_Addr   )rf   r   TZtry_directlyfnrj   rt   rk   _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)``.
        needevalFrY   TNc                    s6   g | ].}j |gtjd d   jf i  qS )ru   N)ri   listrs   doitr   r   r   rf   rj   rk   
<listcomp>   s   z*IntegralTransform.doit.<locals>.<listcomp>r   rw   ru   )popr   r   rs   
isinstancetupleappendlenr   rY   r   r`   rb   ri   _namere   as_coeff_mulrv   r   r   )rf   r   r   rY   r   r   resr   ressr   coeffrestrj   r   rk   r      sN    


zIntegralTransform.doitc                 C   s   |  | j| j| jS r{   )r   re   rv   rx   rt   rj   rj   rk   as_integral   s    zIntegralTransform.as_integralc                 O   s   | j S r{   )r   )rf   rs   kwargsrj   rj   rk   _eval_rewrite_as_Integral   s    z+IntegralTransform._eval_rewrite_as_IntegralN)rl   rm   rn   ro   propertyre   rv   rx   ry   r   r   r   r   r   r   r   rj   rj   rj   rk   rq   I   s"   



G
rq   c                 C   s   |rt tt| ddS | S )NT)Zpolar)rY   r[   r5   )exprr   rj   rj   rk   	_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   rj   )r   rs   r   r   r   rj   rk   wrapper   s    z0_noconds_.<locals>.make_wrapper.<locals>.wrapper)r   )r   r   defaultr   rk   make_wrapper   s    z_noconds_.<locals>.make_wrapperrj   )r   r   rj   r   rk   	_noconds_   s    r   Fc                 C   s   t | |tjtjfS r{   )rH   r   ZeroInfinity)r   r   rj   rj   rk   _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-transformru   Mellincould not compute integralr   integral in unexpected formc                    sF  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 }	qLt||}|jr|jdv r|	|
g7 }	qL|j|krt|j|}qLt|j|}qL|t jur
||kr
t||}q.|t jur,||kr,t||}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r   rj   rj   rk   <lambda>3      z:_mellin_transform.<locals>.process_conds.<locals>.<lambda>z==z!=)r   NegativeInfinityr   truerL   rK   r   rM   replacer#   subsis_Relationalrel_opr   r\   ltsr1   gtsr2   rO   rN   )r   abauxcondsr   ca_b_aux_dd_solnr   rj   rk   process_conds$  sN    




z(_mellin_transform.<locals>.process_condsc                    s   g | ]} |qS rj   rj   r   r   r   rj   rk   r   J  r   z%_mellin_transform.<locals>.<listcomp>c                 S   s   g | ]}|d  dkr|qS )rw   Frj   r   rj   rj   rk   r   K  r   c                 S   s   | d | d  t | d fS )Nr   ru   rw   r
   r   rj   rj   rk   r   L  r   z#_mellin_transform.<locals>.<lambda>keyno convergence found)rJ   r   rI   r   r   r   r   r   r   is_Piecewiserb   rs   rM   sort)r   r   s_Z
integratorrY   Fr   r   r   r   r   rj   )r   r   rk   _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 r{   )r   r~   rj   rj   rk   r   a  s    z"MellinTransform._compute_transformc                 C   s    t |||d   |tjtjfS Nru   )rI   r   r   r   r   rj   rj   rk   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   ru   TFr   zno combined convergence.)r1   r2   rO   rb   )	rf   r   r   r   r   saZsbr   r   rj   rj   rk   r   g  s    

(zMellinTransform._collapse_extraN)rl   rm   rn   ro   r   r   r   r   rj   rj   rj   rk   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   rj   rj   rk   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   ru   )r   r   r0   r   rE   )Zm_nr   r   r   mnrrj   rj   rk   _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)rl   rm   rn   ro   rj   rj   rj   rk   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   ry   r   )r   is_numer)r   r   rj   rk   left  s     z_rewrite_gamma.<locals>.leftr   ru   c                 S   s   g | ]}|j rt|n|qS rj   )is_extended_realr%   r   rj   rj   rk   r   B  r   z"_rewrite_gamma.<locals>.<listcomp>c                    s   g | ]}|  qS rj   rj   r   )common_coefficientrj   rk   r   H  r   c                 s   s   | ]}|j V  qd S r{   )is_Rationalr   rj   rj   rk   r   I  r   z!_rewrite_gamma.<locals>.<genexpr>GammaNzNonrational multiplierc                 S   s   g | ]}t |jqS rj   )r   qr   rj   rj   rk   r   L  s   c                 S   s   g | ]}t |jqS rj   )r   pr   rj   rj   rk   r   S  r   TFc                    s   t d d|  S )NInverse MellinzUnrecognised form '%s'.)rb   )factr   rj   rk   	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. ru   )is_polynomialrU   degree
all_coeffs)r$   r   )r   r   r   rj   rk   
linear_argv  s    

z"_rewrite_gamma.<locals>.linear_argc                    s   g | ]}|  fqS rj   rj   r   )r   r   rj   rk   r     r   r   z Gammas partially over the strip.)evaluaterw   za is not an integerr   )6r   r   rE   r   rs   r   as_independentr   r8   r6   r9   r7   r   Oner   allr   rb   r   r   r   r   r   Zas_numer_denomr   Z	make_argsr   zipr   r   is_Powr   r(   baser*   
is_Integerr%   r   rU   r   LTrS   rW   Z	all_rootsr   ZNegativeOner}   r   	TypeErrorrangeHalfr   r   r   )-r   r   r   r   r   Zs_multipliersgr$   r   _r   Zs_multiplierfacexponentZnumerZdenomrs   ZfacsZdfacsZnumer_gammasZdenom_gammasZexponentialsZugammasZlgammasZufacsr   r  Zexp_r   r   rsr   Zgamma1Zgamma2Zfac_ZanapbmbqZgammasplusminusZnewaZnewckrj   )r   r   r   r   r   r   r   r   rk   _rewrite_gamma  sR   ?










$










 
&

 


&&
r  c              	      sP  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t|}W n  tyN   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r(t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)Zpositivec              
      s    g | ]}t | d dqS )Fr   )_inverse_mellin_transform)r   G
as_meijergr   stripr   rj   rk   r     s   z-_inverse_mellin_transform.<locals>.<listcomp>c                 S   s   g | ]}|d  qS )ru   rj   r   r   rj   rj   rk   r     r   c                 S   s   g | ]}|d  qS )r   rj   r  rj   rj   rk   r     r   )Zgensr   ru   r   zCould not calculate integral   Fzdoes not converger   N)rJ   ZrewriterE   rT   r   r   r   rs   r   r   r@   r   rO   r  rb   rG   
ValueErrorrZ   r}   r   r   r%   r$   argumentdeltar   rN   r  r  r#   nu)r   r   Zx_r  r  r
  r   r   r   r   r   Cer  r  hr   rj   r  rk   r    sX    
$


*
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 r{   )r$  _none_sentinelrq   __new__)clsr   r   r   r   r   optsrj   rj   rk   r'  L  s
    zInverseMellinTransform.__new__c                 C   s:   | j d | j d  }}|tju r$d }|tju r2d }||fS )Nr     )rs   r$  r&  )rf   r   r   rj   rj   rk   fundamental_stripS  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 )NrY   Tr   zComponent %s not recognised.)r   _allowedr(   rE   r8   r6   r9   r7   r+   r-   r.   r,   r!   r"   r    Zis_Functionr   r   rb   r+  r  )rf   r   r   r   r   r   r  rj   rj   rk   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 Nrw   )ri   _crI   r   ImaginaryUnitr   Pi)rf   r   r   r   r   rj   rj   rk   r   l  s     
z#InverseMellinTransform._as_integralN)rl   rm   rn   ro   r   r   r&  r.  r'  r   r+  r   r   rj   rj   rj   rk   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   ru   )r$  r   )r   r   r   r  r   rj   rj   rk   inverse_mellin_transformr  s    5r1  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   rj   rk   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   ru   TF)r   r   r%   rs   r  )Zex1Zex2r   )r   biggerr3  r   rj   rk   r4    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   r4  rj   rk   replie  s    
z_simplifyconds.<locals>.repliec                    s     | |}|dv rdS t | |S )NTFT)r   )r   r6  r   r7  rj   rk   replue  s    
z_simplifyconds.<locals>.repluec                 W   s   | dv rt | S | j| S )Nr9  )boolr   )r2  rs   rj   rj   rk   repl  s    z_simplifyconds.<locals>.replr   )collect_absc                    s
    || S r{   rj   )r   r6  )r8  rj   rk   r     r   z _simplifyconds.<locals>.<lambda>)Zsympy.simplify.radsimpr=  r   r   r   r   )r   r   r   r:  r<  r=  rj   )r   r4  r3  r8  r   rk   _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.
    )rQ   r   r?   r   rj   rj   rk   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  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r$|jjv r$|j}|jrBt|ttfrB|j}|
D ]}||  rF qdqF r | jr |  |  td krt |   dk }||t|tt|	  | t| |   dk   s"|t|tt	| |	 ||  t| |  dk   sh||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t|}|jr|jd	v r"||g7 }q|j kr<t!d
dnt"|j |}q|t jurdt#||}qt$|t%| }q||jr|j&n|fS )z7 Turn ``conds`` into a strip and auxiliary conditions. zp q w1 w2 w3 w4 w5r(  rB  rw   r   c                 3   s   | ]} | j V  qd S r{   )r5  )r   Zwildr   rj   rk   r   ]  r   z<_laplace_transform.<locals>.process_conds.<locals>.<genexpr>c                 S   s   |    d S r   )r   r   r   rj   rj   rk   r   `  r   z;_laplace_transform.<locals>.process_conds.<locals>.<lambda>r   rC  zconvergence not in half-plane?)'r   r   r   rL   rK   r   r   r%   r$   r'   r&   r   rM   r   rhsry   reversedr   r   r   Zreversedsignmatchr5  r   r#   r6   r  r   r   r   r   r\   r   rb   r2   r1   rO   rN   	canonical)r   r   r   r   r   Zw1Zw2Zw3Zw4Zw5patternsr   r   r   r   patr   r   )r   r   r   rE  rk   r   8  s      


&:4"(


z)_laplace_transform.<locals>.process_condsc                    s   g | ]} |qS rj   rj   r   r   rj   rk   r   v  r   z&_laplace_transform.<locals>.<listcomp>c                 S   s*   g | ]"}|d  dkr|d t jur|qS )ru   Fr   )r   r   r   rj   rj   rk   r   w  r   c                 S   s   g | ]}|d  dkr|qS )ru   Frj   r   rj   rj   rk   r   y  r   c                 S   s   | dv rdS |   S )Nr9  r   r   r?  rj   rj   rk   cnt|  s    z_laplace_transform.<locals>.cntc                    s   | d   | d fS Nr   ru   rj   r   )rL  rj   rk   r     r   z$_laplace_transform.<locals>.<lambda>r   r   c                    s   |   S r{   )r   r?  )r   r   rj   rk   sbs  s    z_laplace_transform.<locals>.sbs)r   r   r@  rR   rb   itemsrH  r?   r   r   rs   is_zeror   rH   r(   r   r   r   r   rI   r   r   r   r   rM   r   r   r   r>  r   )r   r   r   rY   r   Z	deltazeroZdeltanonzeroZintegratableZ	deltadictZ
dirac_funcZdirac_coeffr   r   r   r   Zconds2r   rN  rj   )rL  r   r   r   r   r   rk   _laplace_transform  sf    
 >rQ  c                 C   sf   | j }t| j}t| jdkr"| S tt|D ]}t|| |||< q.|jrZ|| |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   N)r   r   rs   r   r  _laplace_deep_collectr   collect)r   r   r   rs   r  rj   rj   rk   rR    s    
rR  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   rA  r   r   tauomegac                    s
   t |  S r{   )rR  r   r   rj   rk   r     r   z&_laplace_build_rules.<locals>.<lambda>r   ru   rw   r  r   g      ?r*        )!r   r   r   r   r?   r(   r%   rN   rO   r@   rC   r3   r   rB   rE   rF   r=   r-   r)   rA   r+   Z
EulerGammarD   r8   r,   r:   r6   r<   r	  r   r;   r>   r/   )	r   r   r   r   r   rT  rU  ZdcoZlaplace_transform_rulesrj   rV  rk   _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($(&.    irZ  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   rj   rj   rk   _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.
    rY   Tr   rA  r
  ru   nargsFZ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 r{   )r   r   rV  rj   rk   r   7  r   z*_laplace_rule_timescale.<locals>.<genexpr>)rY   r   N)r   r   r   r   rH  rs   rS  ra   r   r   r	   rQ  r   LaplaceTransform_laplace_apply_rulesr  )r   r   r   r   r   r   r   r
  r  r   ma1r$   ma2Lr   r   r   rj   rV  rk   _laplace_rule_timescale   s>    

$
rg  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.
    rY   Tr   rA  r   r6  r
  ru   r]  Fr_  r   r`  z      f:    %s ( %s, %s, %s )z      rule: time shift (1.3)r   N)r   r   r   r   rH  r@   rs   rS  ra   rc  r   r(   r  )r   r   r   r   r   r   r   r6  r
  r  r   rd  re  Zma3rf  r   r   r   rj   rj   rk   _laplace_rule_heavisideG  s*    ,"
" rh  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.
    rY   Tr   rA  r6  zFr_  r`  ra  z#      rule: multiply with exp (1.5)r   N)	r   r   r   rH  r(   rS  ra   rc  r  )r   r   r   r   r   r   r6  ri  r  r   rd  re  rf  r   r   r   rj   rj   rk   _laplace_rule_expc  s&    $

rj  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.
    rY   Tr   rA  r6  ri  Fr_  z1.6ru   r   z1.7z1.81.9r`  ra  z!      rule: multiply with %s (%s)r   r   rw   N)r   r   r   r-   r+   r8   r   r6   rH  rS  ra   r   rc  r%   r   rY   r  )r   r   r   r   r   r   r   r6  ri  r  r   Z	trigrulesZtrigruleZfmr   s1s2sdrd  re  rf  r   r   r   Zcp_shiftrj   rj   rk   _laplace_rule_trig}  sV     "



ro  c                 K   sJ  | dd td|gd}td}td|gd}tddd	}| |t|||f }	|	rF|	| jd
 |krF|	| jrFt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.
    rY   Tr   rA  r6  r   r
  ru   r]  r   r`        f:    %sz(      rule: time derivative (1.11, 1.12)r   N)r   r   r   rH  r   rs   
is_integerra   r  r   r   r   rc  r   )r   r   r   r   r   r   r6  r   r
  rd  r   r  r   rj   rj   rk   _laplace_rule_diff  s*    &  $rr  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`  rp  z      rule: %s o---o %sz      try   %sz      check %s -> %sTz#_laplace_apply_rules did not match.Nr   )r   rZ  rH  ra   Zxreplacer\  r   r   	Exceptionr   r?   rg  rh  rj  ro  rr  )r   r   r   r   r   r  r   Zsimple_rulesZt_domZs_domcheckplaneprepmar   Z
prog_rulesZp_ruler  rj   rj   rk   rc    s<    



rc  c                   @   s4   e Zd ZdZdZdd Zdd Zdd Zd	d
 ZdS )rb  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.
    rC  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 )NrY   Tz0_laplace_apply_rules could not match function %sz    hints: %s)rc  r   ra   rQ  )rf   r   r   r   r   r  r   rj   rj   rk   r     s    z#LaplaceTransform._compute_transformc                 C   s"   t |t| |  |tjtjfS r{   )rI   r(   r   r   r   )rf   r   r   r   rj   rj   rk   r     s    zLaplaceTransform._as_integralc                 C   sV   g }g }|D ]\}}| | | | qt| }t| }|dkrNtdd d||fS )NFrC  zNo combined convergence.)r   rO   r1   rb   )rf   r   r   Zplanesru  r   rj   rj   rk   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)re   ra   rv   rx   r   r   r   rb   )rf   r   r   t_r   r  rj   rj   rk   r     s    
zLaplaceTransform._try_directlyN)	rl   rm   rn   ro   r   r   r   r   r   rj   rj   rj   rk   rb    s   	
rb  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.
                rk  z#deprecated-laplace-transform-matrix)Zdeprecated_since_versionZactive_deprecations_targetc                    s   t | fi  S r{   laplace_transform)fijr   r   r   rj   rk   r     r   z#laplace_transform.<locals>.<lambda>Nc                    s    g | ]}t |fi  qS rj   rz  )r   r|  r}  rj   rk   r     r   z%laplace_transform.<locals>.<listcomp>)ra   r   rP   hasattrr[  r]   r_   r^   ry  r  typeshaper1   rO   rb  r   )r   r   r   Zlegacy_matrixr   r   Zelements_transelementsZavalsZ
conditionsZ	f_laplacerj   r}  rk   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. r  rw   r   ru   )r   r4   rs   r  r@   r%   )rs   r$   r   r  e1e2)r  r   rj   rk   pw_simp  s    z+_inverse_laplace_transform.<locals>.pw_simpc                    s   g | ]}t | qS rj   )_inverse_laplace_transform)r   X)ru  r   rY   r   rj   rk   r     s   z._inverse_laplace_transform.<locals>.<listcomp>NF)r   r   Inverse Laplacer   z(inversion integral of unrecognised form.uc                    st   |  t  }| r&t| |S t|dk}|jkrVt|j}t | |S t|j}t |  |S d S r   )r   r(   r   r@   r\   r   r)   r   )r$   ZH0r   relr  )r   r  rj   rk   simp_heaviside  s    




z2_inverse_laplace_transform.<locals>.simp_heavisidec                 S   s   t t| S r{   )r   r(   )r$   rj   rj   rk   simp_exp  s    z,_inverse_laplace_transform.<locals>.simp_exp)sympy.integrals.meijerintr  r  r   Zis_rational_functionZapartr   r   rs   r   r   r1  r(   r   r   rb   r   r   rI   r   r   r4   r	  r@   )r   r   rx  ru  rY   r  r  r   r   r  r  rj   )r  ru  r   rY   r   r  rk   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 r{   )r  r&  rq   r'  )r(  r   r   r   ru  r)  rj   rj   rk   r'    s    zInverseLaplaceTransform.__new__c                 C   s   | j d }|tju rd }|S Nr  )rs   r  r&  )rf   ru  rj   rj   rk   fundamental_plane  s    

z)InverseLaplaceTransform.fundamental_planec                 K   s   t |||| jfi |S r{   )r  r  )rf   r   r   r   r   rj   rj   rk   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 r-  )ri   r.  rI   r(   r   r/  r   r0  )rf   r   r   r   r   rj   rj   rk   r     s     z$InverseLaplaceTransform._as_integralN)rl   rm   rn   ro   r   r   r&  r.  r'  r   r  r   r   rj   rj   rj   rk   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
    ry  c                    s   t | fi  S r{   )inverse_laplace_transform)ZFijr   ru  r   r   rj   rk   r   .  r   z+inverse_laplace_transform.<locals>.<lambda>)r   rP   r~  ry  r  r   )r   r   r   ru  r   rj   r  rk   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, nrD  c                    sR   |  s| S | jr | S | jr*| S | jr8| S t| trJ| S td S r{   )r   r   is_Mulr  r   rX   r}   r"  )_ilt_add_ilt_mul_ilt_pow_ilt_rootsumr   rj   rk   _ilt6  s    

z#_fast_inverse_laplace.<locals>._iltc                    s   | j t | j S r{   )r   maprs   r  r  rj   rk   r  D  s    z'_fast_inverse_laplace.<locals>._ilt_addc                    s$   |  \}}|jrt| | S r{   )r   r  r}   )r"  r   r   )r  r   rj   rk   r  G  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  )rH  r  r(   rE   r}   )r"  rH  nmamr  )r   r   r   r   r   rj   rk   r  M  s    4z'_fast_inverse_laplace.<locals>._ilt_powc                    s,   | j j}| j j\}t| jt|t |S r{   )Zfunr   	variablesrX   Zpolyr   rV   )r"  r   variabler  rj   rk   r  W  s    
z+_fast_inverse_laplace.<locals>._ilt_rootsum)r   r   )r"  r   r   rj   )
r  r  r  r  r  r   r   r   r   r   rk   _fast_inverse_laplace2  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   r/  r   r   r   rI   r   r   NaNrb   r   rs   )
r   r   r  r   r   r   rY   r   Z
integral_fr   rj   rj   rk   _fourier_transformc  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r}   ri   rt   rj   rj   rk   r     s    zFourierTypeTransform.ac                 C   s   t d| j d S Nz,Class %s must implement b(self) but does notr  rt   rj   rj   rk   r     s    zFourierTypeTransform.bc                 K   s&   t ||||  |  | jjfi |S r{   )r  r   r   ri   r   rf   r   r   r  r   rj   rj   rk   r     s    z'FourierTypeTransform._compute_transformc                 C   s>   |   }|  }t|| t|tj | |  |tjtjfS r{   )r   r   rI   r(   r   r/  r   r   )rf   r   r   r  r   r   rj   rj   rk   r     s    z!FourierTypeTransform._as_integralNrl   rm   rn   ro   r   r   r   r   rj   rj   rj   rk   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   rj   rt   rj   rj   rk   r     s    zFourierTransform.ac                 C   s
   dt j S )NrW  r   r0  rt   rj   rj   rk   r     s    zFourierTransform.bNrl   rm   rn   ro   r   r   r   rj   rj   rj   rk   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   rj   rj   rk   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   rj   rt   rj   rj   rk   r     s    zInverseFourierTransform.ac                 C   s
   dt j S r-  r  rt   rj   rj   rk   r     s    zInverseFourierTransform.bNr  rj   rj   rj   rk   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   rj   rj   rk   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   rb   rs   )
r   r   r  r   r   Kr   rY   r   r   rj   rj   rk   _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  rt   rj   rj   rk   r   5	  s    zSineCosineTypeTransform.ac                 C   s   t d| j d S r  r  rt   rj   rj   rk   r   9	  s    zSineCosineTypeTransform.bc                 K   s,   t ||||  |  | jj| jjfi |S r{   )r  r   r   ri   _kernr   r  rj   rj   rk   r   >	  s    z*SineCosineTypeTransform._compute_transformc                 C   s@   |   }|  }| jj}t|| ||| |  |tjtjfS r{   )r   r   ri   r  rI   r   r   r   )rf   r   r   r  r   r   r  rj   rj   rk   r   D	  s    z$SineCosineTypeTransform._as_integralNr  rj   rj   rj   rk   r  /	  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 r-  r3   r   rt   rj   rj   rk   r   X	  s    zSineTransform.ac                 C   s   t jS r{   r   r   rt   rj   rj   rk   r   [	  s    zSineTransform.bN	rl   rm   rn   ro   r   r8   r  r   r   rj   rj   rj   rk   r  K	  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  rj   rj   rk   sine_transform_	  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 r-  r  rt   rj   rj   rk   r   	  s    zInverseSineTransform.ac                 C   s   t jS r{   r  rt   rj   rj   rk   r   	  s    zInverseSineTransform.bNr  rj   rj   rj   rk   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  rj   rj   rk   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 r-  r  rt   rj   rj   rk   r   	  s    zCosineTransform.ac                 C   s   t jS r{   r  rt   rj   rj   rk   r   	  s    zCosineTransform.bN	rl   rm   rn   ro   r   r6   r  r   r   rj   rj   rj   rk   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  rj   rj   rk   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 r-  r  rt   rj   rj   rk   r   

  s    zInverseCosineTransform.ac                 C   s   t jS r{   r  rt   rj   rj   rk   r   
  s    zInverseCosineTransform.bNr  rj   rj   rj   rk   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  rj   rj   rk   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   rb   rs   )r   r   r  r   r   rY   r   r   rj   rj   rk   _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   re   rv   rx   rs   )rf   r   rj   rj   rk   r   W
  s    zHankelTypeTransform.doitc                 K   s   t ||||| jfi |S r{   )r  r   )rf   r   r   r  r   r   rj   rj   rk   r   ^
  s    z&HankelTypeTransform._compute_transformc                 C   s&   t |t|||  | |tjtjfS r{   )rI   r<   r   r   r   )rf   r   r   r  r   rj   rj   rk   r   a
  s    z HankelTypeTransform._as_integralc                 C   s   |  | j| j| j| jd S r  )r   re   rv   rx   rs   rt   rj   rj   rk   r   d
  s
    zHankelTypeTransform.as_integralN)	rl   rm   rn   ro   r   r   r   r   r   rj   rj   rj   rk   r  R
  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rl   rm   rn   ro   r   rj   rj   rj   rk   r  l
  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  r   r   rj   rj   rk   hankel_transformy
  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  rj   rj   rj   rk   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   r   r   rj   rj   rk   inverse_hankel_transform
  s    .r  )F)T)T)T)T)T)T)T)T)T)N)T)T)T)ro   	functoolsr   r   	itertoolsr   Z
sympy.corer   r   r   Zsympy.core.addr   Zsympy.core.functionr	   r
   r   r   r   r   r   r   r   Zsympy.core.mulr   Zsympy.core.numbersr   r   Zsympy.core.relationalr   r   r   r   r   r   Zsympy.core.sortingr   r   Zsympy.core.symbolr   r   r   Zsympy.core.traversalr    Z(sympy.functions.combinatorial.factorialsr!   r"   Z$sympy.functions.elementary.complexesr#   r$   r%   r&   r'   Z&sympy.functions.elementary.exponentialr(   r)   r*   Z%sympy.functions.elementary.hyperbolicr+   r,   r-   r.   r/   Z#sympy.functions.elementary.integersr0   Z(sympy.functions.elementary.miscellaneousr1   r2   r3   Z$sympy.functions.elementary.piecewiser4   r5   Z(sympy.functions.elementary.trigonometricr6   r7   r8   r9   r:   Zsympy.functions.special.besselr;   r<   r=   r>   Z'sympy.functions.special.delta_functionsr?   r@   Z'sympy.functions.special.error_functionsrA   rB   rC   Z'sympy.functions.special.gamma_functionsrD   rE   rF   Zsympy.functions.special.hyperrG   Zsympy.integralsrH   rI   r  rJ   Zsympy.logic.boolalgrK   rL   rM   rN   rO   Zsympy.matrices.matricesrP   Zsympy.polys.matrices.linsolverQ   rR   Zsympy.polys.polyrootsrS   Zsympy.polys.polytoolsrT   rU   Zsympy.polys.rationaltoolsrV   Zsympy.polys.rootoftoolsrW   rX   Zsympy.simplifyrY   rZ   Zsympy.simplify.powsimpr[   Zsympy.solvers.inequalitiesr\   Zsympy.utilities.exceptionsr]   r^   r_   Zsympy.utilities.iterablesr`   Zsympy.utilities.miscra   r}   rb   rq   r   r   Z_nocondsr   r   r   r   r   r  r   r  r  r,  r$  r1  r>  r@  rQ  rR  rZ  r\  rg  rh  rj  ro  rr  rc  rb  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  rj   rj   rj   rk   <module>   s   ,  C!,-  -94<X~  w
'


5

)5
bO#
01*.'('+1