U
    9%e                     @   sp  d Z ddlmZmZmZ ddlmZ ddlmZ ddl	m
Z
mZmZ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mZmZmZ ddlmZ dd	lm Z 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/m0Z0m1Z1 ddl2m3Z3m4Z4m5Z5 ddl6m7Z7 ddl8m9Z9m:Z:m;Z; ddl<m=Z=m>Z>m?Z?m@Z@ ddlAmBZBmCZC ddlDmEZEmFZFmGZG ddlHmIZImJZJmKZK ddlLmMZMmNZN ddlOmPZPmQZQmRZR ddlSmTZTmUZUmVZVmWZWmXZX ddlYmZZZ ddl[m\Z\ ddl]m^Z^ ddl_m`Z` ddlambZb ddlcmdZd ddlemfZf ddlgmhZhmiZimjZj ddlkmlZlmmZm d d! Znd"d# Zodfd%d&Zpd'd( Zqed)d* Zrd+d, Zsd-d. Ztd/d0 Zud1d2 Zvd3d4 Zwd5d6 Zxd7d8 Zydgd9d:Zzdhd;d<Z{did=d>Z|djd?d@Z}dAdB Z~dCdD ZdkdEdFZG dGdH dHeQZdldIdJZdmdKdLZdMdN ZedOdP ZdQdR ZdSdT ZdUdV ZdWdX ZdYdZ Zd[d\ Zdnd]d^ZG d_d` d`eQZdodbdcZddde ZdaS )pzLaplace Transforms    )SpiI)Add)cacheit)	AppliedUndef
Derivativeexpandexpand_complex
expand_mulexpand_trigLambdaWildFunctiondiff)Mulprod)
_canonicalGeGtLt
UnequalityEq)ordered)DummysymbolsWild)reimargAbs
polar_liftperiodic_argument)explog)coshcothsinhasinh)MaxMinsqrt)	Piecewise)cossinatan)besselibesseljbesselkbessely)
DiracDelta	Heaviside)erferfcEi)digammagamma
lowergamma)	integrateIntegral)	_simplifyIntegralTransformIntegralTransformError)to_cnf	conjuncts	disjunctsOrAnd)
MatrixBase)_lin_eq2dict)PolynomialError)roots)Poly)together)RootSum)sympy_deprecation_warningSymPyDeprecationWarningignore_warnings)debugdebugfc                    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.laplace import _simplifyconds
    >>> from sympy.abc import x
    >>> from sympy import sympify as S
    >>> _simplifyconds(abs(x**2) < 1, x, 1)
    False
    >>> _simplifyconds(abs(x**2) < 1, x, 2)
    False
    >>> _simplifyconds(abs(x**2) < 1, x, 0)
    Abs(x**2) < 1
    >>> _simplifyconds(abs(1/x**2) < 1, x, 1)
    True
    >>> _simplifyconds(S(1) < abs(x), x, 1)
    True
    >>> _simplifyconds(S(1) < abs(1/x), x, 1)
    False

    >>> from sympy import Ne
    >>> _simplifyconds(Ne(1, x**3), x, 1)
    True
    >>> _simplifyconds(Ne(1, x**3), x, 2)
    True
    >>> _simplifyconds(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 )N   )is_Powbaser"   )exs V/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/sympy/integrals/laplace.pypowerH   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krpdS zT|dkrt| t | ktjkrW dS |dk rt| t | ktjkrW dS W n tk
r   Y nX dS )z_ Return True only if |ex1| > |ex2|, False only if |ex1| < |ex2|.
            Else return None. Nr   rQ   FT)has
isinstancer   argsr   true	TypeError)Zex1Zex2n)abiggerrY   rV   rW   rX   ra   O   s$    




""
z_simplifyconds.<locals>.biggerc                    sH   | j st| tr |j s(t|ts(| |k S  | |}|dk	r@| S | |k S )z simplify x < y N)is_positiver[   r   )xyrra   rW   rX   repliee   s    
z_simplifyconds.<locals>.repliec                    s     | |}|dkrdS t | |S )NTFT)r   )rc   rd   brf   rW   rX   replueo   s    
z_simplifyconds.<locals>.repluec                 W   s   | dkrt | S | j| S )Nrh   )boolreplace)rT   r\   rW   rW   rX   replu   s    z_simplifyconds.<locals>.replr   )collect_absc                    s
    || S NrW   )rc   rd   )rg   rW   rX   <lambda>|       z _simplifyconds.<locals>.<lambda>)sympy.simplify.radsimprn   r   r   r   r   )exprrV   r`   rj   rm   rn   rW   )r`   ra   rY   rg   rV   rX   _simplifyconds'   s    !
rt   c                 C   s   t | | tS )zs
    Expand an expression involving DiractDelta to get it as a linear
    combination of DiracDelta functions.
    )rF   atomsr3   rs   rW   rW   rX   expand_dirac_delta   s    rw   Tc                    s  t dtd| f td|f | tr2dS t| t   tjtjf}td|f |t	st
||tjtjfS |jstd dS |jd \}}|t	rtd dS fd	d
fddt|D }dd |D }|sdd |D }tt|}dd  |j fddd |s<td dS |d \}}	fdd}
|rtt||}t|	|}	t
|||
|t|
|	fS )z The backend function for doing Laplace transforms by integration.

    This backend assumes that the frontend has already split sums
    such that `f` is to an addition anymore.
    rV   z&[LT _l_t_i ] started with (%s, %s, %s)z [LT _l_t_i ]     and simplify=%sNz[LT _l_t_i ]     integrated: %sz[LT _l_t_i ]     not piecewise.r   z-[LT _l_t_i ]     integral in unexpected form.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 ]H}|jr0|jjk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
ks| s| s||g7 }q||}|jr |jd
kr.||g7 }q|j!krJt"d   dS t#|j!|}q|tjk	rrt$||}qt%|t&| }q||jr|j'n|fS )z7 Turn ``conds`` into a strip and auxiliary conditions. r   _solve_inequalityzp q w1 w2 w3 w4 w5clsexclude   c                 3   s   | ]} | j V  qd S ro   )rb   ).0ZwildmrW   rX   	<genexpr>   s     zH_laplace_transform_integration.<locals>.process_conds.<locals>.<genexpr>c                 S   s   |    d S )Nr   )r	   as_real_imagrc   rW   rW   rX   rp      rq   zG_laplace_transform_integration.<locals>.process_conds.<locals>.<lambda>)z==z!=z/[LT _l_t_i ]     convergence not in half-plane.N)(sympy.solvers.inequalitiesry   r   NegativeInfinityr]   rA   r@   r   r   r   r   r!   r    InfinityrB   Zis_RelationalrhsZfree_symbolsreversedr[   r   r   Zreversedsignmatchrb   r   r   r,   allrl   subsZrel_oprZ   ltsrO   r)   r(   rD   rC   	canonical)condsry   r`   auxpqZw1Zw2Zw3Zw4Zw5patternscZa_Zaux_dpatZd_Zsoln)rV   tr   rX   process_conds   s        


,:       


z5_laplace_transform_integration.<locals>.process_condsc                    s   g | ]} |qS rW   rW   )r~   r   )r   rW   rX   
<listcomp>   s     z2_laplace_transform_integration.<locals>.<listcomp>c                 S   s,   g | ]$}|d  t jkr|d t jk	r|qS )rQ   r   )r   falser   r~   rc   rW   rW   rX   r      s     c                 S   s   g | ]}|d  t jkr|qS rQ   )r   r   r   rW   rW   rX   r      s      c                 S   s   | dkrdS |   S )Nrh   r   )Z	count_opsrv   rW   rW   rX   cnt   s    z+_laplace_transform_integration.<locals>.cntc                    s   | d   | d fS Nr   rQ   rW   r   )r   rW   rX   rp      rq   z0_laplace_transform_integration.<locals>.<lambda>)keyz&[LT _l_t_i ]     no convergence found.c                    s   |   S ro   )r   rv   )rV   s_rW   rX   sbs   s    z+_laplace_transform_integration.<locals>.sbs)r   rP   rZ   r3   r;   r"   r   Zeror   r<   r=   r   r   r]   is_PiecewiserO   r\   rB   listr   sortrt   r   )fr   r   simplifyFcondr   Zconds2r`   r   r   rW   )r   r   rV   r   r   rX   _laplace_transform_integration   sB    
"

@r   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 rW   _laplace_deep_collect)r~   r   r   rW   rX   r     s     z)_laplace_deep_collect.<locals>.<listcomp>N)funcr   r\   lenis_Addcollect)r   r   r   r\   rW   r   rX   r      s    
r   c               X      sr  t d t d} td gd}td gd}td gd}td gd}td gd} fd	d
}t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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| | |   | tt|| tk tj|fdt|  |  t|t |  t|| |   tt|| |   | tt|| tk tj|f|  | td d  d|td d   dt|  | tdd   t|| |   tt|| |   |  tt|| tk tj|ft  |  tt|  tt| t||   tt||    tt|tk 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tt|| tk tj|f |  |  || t|d  t| ||   t
|dktt|tk tj|ft|  | t| | |  tjt||f t|  |  t| | | d  tjt||f | t|   t|d | | |d   t|dkt||ft|  d  ttd | t| d d |  t| td|   t|dktj|f t|  d   dd|  dtt d| tdd   |  t| td|    t|dktj|ft|   dt||   tddt||    t|dktj|ft t|    tdd tt| d   ddt||     tdt||    t|dktj|ft|   t  tt|  tdt||    t|dktj|ft|    t   tt| tdt||    t|dktj|f | t|    d||  |d d   t|d dt||    t|dktj|ftdt|   | d tt| | td d   t||   tt||    tt|tk tj|ftdt|   t  t|  tdd  t||   tt||   tt|tk tj|ft|  tttj|  |  |  |dktj|ftd|   t| |  |  t|  |  tt|tk tj|ft|  | t|t| | | |  | t|  |   |  | t
|dktt|tk tj|ft t  tt|   td|  ttj  tjtj|f | t  t|d | | d   t|d t|   t|dktj|ft|  d tttj|  | d td d  |  |dktj|ft|  || d |d   tjtt||ftt|  || d |d   tt|  d |  |dktj|ft|    t||  tjtt||ft|  d   tdd|d  | d   d tjdtt| |ft|  d  d  |td| |   | tdd|d  | d    d  tjdtt| |ftdt|   tt| |  t|  t| |   tjtj|ftdt|     ttt||   tjtj|ft|  | | d |d   tjtt||ft|  d | d d|d   | d d|d    |  tjdtt| |ft tdt|    ttd | td d   | d|   t| |   tjtj|ftdt|   t  tt|  t| |   tjtj|ft|  t|   d| | |  | d || d   | d || d   tjtt|tt| |ft|  t|   || d |d  |d   | d || d   | d || d   tjtt|tt| |ft|  t|   | | d |d  |d   | d || d   | d || d   tjtt|tt| |ft|  || d |d   tjtt||ft |  | | d |d   tjtt||ft|  d d|d  | d d|d  |    tjdtt| |ft |  d | d d|d   | d d|d  |    tjdtt| |ft|    t| | | |  d tjtt||f | t|   t|d d | | | d  | | | d    |dkt||f | t |   t|d d | | | d  | | | d    |dkt||ftdt|   tt| |  t|  t||   tjtj|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t||   |tdd  | d   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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|  d t  ttdd  d | td d   t||  d  tjtj|ft|  t| d d| d  t| d|   |  dtt| tk tj|ftt|  t|t| |  |  tjt!tjt| |ft|  tt|   t|t|  | |  tjt!tjt||ftt|  d dtt||    |  t|dktj|ftt|  t| | t| t| |  |  tjt| |ft|  tt|   d| t||    tjtj|ftt|  d tt||   |  t|dktj|ft"||  || t| d |d  | t| d |d   |   t|dktt||f | t"||   d| tt t|tj#  ||  | d |d  | tj#   t
t|tj# kt$||tt||f | t"||   d|d  tt t|tdd   ||  |  | d |d  | tdd    t
t|dkt$||d tt||ft"ddt|   t| |  |  tjtj|f | t"|dt|    ||d  | | d   t| |   t
t|dkt$||tj# tj|ft"d|t d |    t||  |t| d |d    t| d |d   tt|tk tt||ft%||  || t| d |d  | t| d |d   |   t|dktt||f | t%||   d| tt t|tj#  ||  | d |d  | tj#   t
t|tj# kt$||tt||f | t%||   d|d  tt t|tdd   ||  |  | d |d  | tdd    t
t|dkt$||d tt||f | t%|dt|    ||d  | | d   t||   t
t|dkt$||tj# tj|ft&d|  dt t'| |  t| d |d   tjtt||ftd|  t| t| d |d   | t| d |d   tjt| |fgR}| | fS )aY  
    This is an internal helper function that returns the table of Laplace
    transform rules in terms of the time variable `t` and the frequency
    variable `s`.  It is used by ``_laplace_apply_rules``.  Each entry is a
    tuple containing:

        (time domain pattern,
         frequency-domain replacement,
         condition for the rule to be applied,
         convergence plane,
         preparation function)

    The preparation function is a function with one argument that is applied
    to the expression before matching. For most rules it should be
    ``_laplace_deep_collect``.
    r   rV   r`   r|   ri   r_   tauomegac                    s
   t |  S ro   r   r   r   rW   rX   dco+  rq   z!_laplace_build_rules.<locals>.dcoz&_laplace_build_rules is building rulesr   rQ   r}      g      ?         )(r   r   rO   r   r]   r   r3   r"   r   rC   rD   r   r4   r7   r   r   r*   r6   r9   r:   r   r1   r#   Z
EulerGammar8   r-   r   r%   r.   r5   r,   r&   r$   r(   r0   Halfr   r/   r2   r'   )rV   r`   ri   r_   r   r   r   Zlaplace_transform_rulesrW   r   rX   _laplace_build_rules  sr     &$ $ "  &        6  H  X  @  D    D  0    &  ,
  F
  B
  0
  B
  2
  6
  D
  @  H  $  ,  B  0  :
  6   
 4   
 0  6  6  (   
 8  P  2  L  X  X   
  
 0  8  $ 
 D  D  4  L  ,
  R  <  F  N  N  4  $  0  *
  0  ,  &
  B
 
 @ 
 T 
 $  B  6 
 B
 
 @ 
 T 
 @  2 
 >    7r   c                 C   s   t d|gd}tddd}| |}|r|| jd |}||| }|r|| jr|| dkrtd td| ||f td	 td||  || 	| ||||  d
d\}}	}
||	|
fS dS )z
    This function applies the time-scaling rule of the Laplace transform in
    a straight-forward way. For example, if it gets ``(f(a*t), t, s)``, it will
    compute ``LaplaceTransform(f(t)/a, t, s/a)`` if ``a>0``.
    r`   r   grQ   )nargsr   z _laplace_apply_prog rules match:z      f:    %s _ %s, %s )z       rule: time scaling (4.1.4)Fr   N)
r   r   r   r\   r   rb   rO   rP   _laplace_transformr   )r   r   rV   r`   r   ma1r   ma2re   prcrrW   rW   rX   _laplace_rule_timescale  s"    
 
 
r   c                 C   s  t d|gd}t d}t d}| t|| }|r|| || }|r|| jrtd td| ||f td t|| ||||  ||dd	\}}	}
t||  | | |	|
fS |r|| j	rtd td| ||f td
 t|| ||dd	\}}	}
||	|
fS dS )a  
    This function deals with time-shifted Heaviside step functions. If the time
    shift is positive, it applies the time-shift rule of the Laplace transform.
    For example, if it gets ``(Heaviside(t-a)*f(t), t, s)``, it will compute
    ``exp(-a*s)*LaplaceTransform(f(t+a), t, s)``.

    If the time shift is negative, the Heaviside function is simply removed
    as it means nothing to the Laplace transform.

    The function does not remove a factor ``Heaviside(t)``; this is done by
    the simple rules.
    r`   r   rd   r    _laplace_apply_prog_rules match:      f:    %s ( %s, %s )z      rule: time shift (4.1.4)Fr   z9      rule: Heaviside factor, negative time shift (4.1.4)N)
r   r   r4   rb   rO   rP   r   r   r"   is_negative)r   r   rV   r`   rd   r   r   r   re   r   r   rW   rW   rX   _laplace_rule_heaviside  s*    
r   c                 C   s   t d|gd}t d}t d}| t|| }|r|| ||| }|rtd td| ||f td t|| ||||  dd	\}}	}
||	t||  |
fS d
S )a  
    If this function finds a factor ``exp(a*t)``, it applies the
    frequency-shift rule of the Laplace transform and adjusts the convergence
    plane accordingly.  For example, if it gets ``(exp(-a*t)*f(t), t, s)``, it
    will compute ``LaplaceTransform(f(t), t, s+a)``.
    r`   r   rd   zr   r   z%      rule: multiply with exp (4.1.5)Fr   N)r   r   r"   r   rO   rP   r   r   )r   r   rV   r`   rd   r   r   r   re   r   r   rW   rW   rX   _laplace_rule_exp"  s    r   c           
         s  t dgd}t dgd}t d}t d| t|   r  ts | | | }|rtd td|  |f td || ||  }t|d	krt|d	krt	||  ||     
|| ||   ||  }|tjtjfS d	tjtjfS  | rt | }	ti k	rt|	 d
hkrt | t fddt|	 D  }|tjtjfS dS )z
    If this function finds a factor ``DiracDelta(b*t-a)``, it applies the
    masking property of the delta distribution. For example, if it gets
    ``(DiracDelta(t-a)*f(t), t, s)``, it will return
    ``(f(a)*exp(-a*s), -a, True)``.
    r`   r   ri   rd   r   r   r   z$      rule: multiply with DiracDeltar   rQ   c                    sN   g | ]F}t |d krt|d krt|     | qS )r   )r   r   r"   r   r   r   rV   Zsloper   r   rW   rX   r   Z  s     z'_laplace_rule_delta.<locals>.<listcomp>N)r   r   r3   rZ   r   rO   rP   r   r   r"   r   r   r   r]   is_polynomialrH   setvaluesr   r   r   keys)
r   r   rV   r`   ri   rd   r   locre   rorW   r   rX   _laplace_rule_delta:  s6    	>
r   c                 C   s`   t jg}t jg}t| D ],}|ttttt	r<|
| q|
| qt| }t| }||fS )z
    Helper function for `_laplace_rule_trig`.  This function returns two terms
    `f` and `g`.  `f` contains all product terms with sin, cos, sinh, cosh in
    them; `g` contains everything else.
    )r   Oner   	make_argsrZ   r-   r,   r&   r$   r"   append)fnZtrigsothertermr   r   rW   rW   rX   _laplace_trig_split`  s    r   c                 C   s  t d}t d|gd}g }g }| t }t|D ]}||s`|d|ddtdt	di q6|j
dd}||t|  }d	k	r
|| | }	d	k	r|	 }
t|
d
kr|d|| t|
d  d|
d tt|
d t	t	|
d i n
|| n
|| q6|| q6||fS )a  
    Helper function for `_laplace_rule_trig`.  This function expects the `f`
    from `_laplace_trig_split`.  It returns two lists `xm` and `xn`.  `xm` is
    a list of dictionaries with keys `k` and `a` representing a function
    `k*exp(a*t)`.  `xn` is a list of all terms that cannot be brought into
    that form, which may happen, e.g., when a trigonometric function has
    another function in its argument.
    r   r   r   kr`   r   r"   )combineNr}   rQ   )r   rewriter"   r	   r   r   rZ   r   r   r   Zpowsimpr   as_poly
all_coeffsr   )r   r   r   r   xmxnx1r   re   mpZmcrW   rW   rX   _laplace_trig_expsumr  s8    	
    
  
r   c                    s  g }g }dd   fdd} fdd} fdd} fd	d
}dd }	t | dkr|  }
d}d}d}tt | D ]}|
t | | t k}|
t | | t  k}|
t | | t k}|
t | | t  k}|r|r|
t dkr|
t dkr|}qv|r|r|
t dkr|}qv|rv|rv|
t dkrv|}qv|dk	r|dk	r|dk	r|||
| | d | | d | | d | |tt|
d  |||g}|jdd |D ]}| | qqH|dk	r|||
| | d | ||
t  | | qH|dk	r>|||
| | d | |t|
t  | | qH|dk	r|||
| | d | |t|
t  | | qH||	|
| ||
t  qHt| t	| fS )a  
    Helper function for `_laplace_rule_trig`.  This function takes the list of
    exponentials `xm` from `_laplace_trig_expsum` and simplifies complex
    conjugate and real symmetric poles.  It returns the result as a sum and
    the convergence plane.
    c                 S   sj   |   }tt|D ]P}||  }|d trF|| t||< q|d t|d   t||< q|S r   )	copyranger   r   rZ   r   r   r,   r   )Zcoeffsncr   rirW   rW   rX   _simpc  s     z"_laplace_trig_ltex.<locals>._simpcc              	      s  | d | d | t  | t f\}}}}|| | | ||| | |  dt | |  dt | |  |d | | | |  |dt | | dt | |    d|d  |  d|d  |  |d | | | |  |d dt | | dt | |  dt | |  dt | |    |d|d  | d|d  |    g}	tjtjd|d  d|d   tj|d d|d  |d   |d  g}
t fddt|	tt	|	d d d D  }t fd	dt|
tt	|
d d d D  }t
d
||f || S )Nr`   r   r}   r   r   c                    s   g | ]\}}| |  qS rW   rW   r~   rc   rd   rU   rW   rX   r     s     z9_laplace_trig_ltex.<locals>._quadpole.<locals>.<listcomp>r   c                    s   g | ]\}}| |  qS rW   rW   r   rU   rW   rX   r     s     z        quadpole: (%s) / (%s))r   r   r   r   r   r   r   zipr   r   rP   )t1k1k2k3rV   r`   k0a_ra_ir   dcr_   r   r   rU   rX   	_quadpole  s<    $2"F"   ",(z%_laplace_trig_ltex.<locals>._quadpolec                    s   | d | d | t  | t f\}}}}|| | | ||  dt | |  g}tjd| |d |d  g}t fddt|tt|d d d D  }	t fddt|tt|d d d D  }
t	d	|	|
f |	|
 S )
Nr`   r   r}   r   c                    s   g | ]\}}| |  qS rW   rW   r   rU   rW   rX   r     s     z7_laplace_trig_ltex.<locals>._ccpole.<locals>.<listcomp>r   c                    s   g | ]\}}| |  qS rW   rW   r   rU   rW   rX   r     s     z        ccpole: (%s) / (%s)
r   r   r   r   r   r   r   r   r   rP   )r   r   rV   r`   r   r   r   r   r   r_   r   r   rU   rX   _ccpole  s    $*,(z#_laplace_trig_ltex.<locals>._ccpolec                    s   | d | d | t  | t f\}}}}|| || ||  dt | |  g}tjdt | |d  |d  g}t fddt|tt|d d d D  }	t fddt|tt|d d d D  }
t	d	|	|
f |	|
 S )
Nr`   r   r}   r   c                    s   g | ]\}}| |  qS rW   rW   r   rU   rW   rX   r     s     z7_laplace_trig_ltex.<locals>._rspole.<locals>.<listcomp>r   c                    s   g | ]\}}| |  qS rW   rW   r   rU   rW   rX   r     s     z        rspole: (%s) / (%s)r   )r   r   rV   r`   r   r   r   r   r   r_   r   r   rU   rX   _rspole  s    $(",(z#_laplace_trig_ltex.<locals>._rspolec           	         s   | d | d  }}|| |||  g}t jt j|d  g}t fddt|tt|d d d D  }t fddt|tt|d d d D  }td||f || S )	Nr`   r   r}   c                    s   g | ]\}}| |  qS rW   rW   r   rU   rW   rX   r     s     z7_laplace_trig_ltex.<locals>._sypole.<locals>.<listcomp>r   c                    s   g | ]\}}| |  qS rW   rW   r   rU   rW   rX   r     s     z        sypole: (%s) / (%s))r   r   r   r   r   r   r   rP   )	r   r   rV   r`   r   r   r   r_   r   r   rU   rX   _sypole  s    ,(z#_laplace_trig_ltex.<locals>._sypolec                 S   s4   | d | d  }}|}|| }t d||f || S )Nr`   r   z        simplepole: (%s) / (%s))rP   )r   rV   r`   r   r_   r   rW   rW   rX   _simplepole  s
    z'_laplace_trig_ltex.<locals>._simplepoler   Nr   r`   T)reverse)
r   popr   r   r   r   r   r   r   r(   )r   r   rV   resultsplanesr   r   r   r   r   r   Z	i_imagsymZ	i_realsymZ
i_pointsymiZreal_eqZrealsymZimag_eqZimagsymZindices_to_poprW   r   rX   _laplace_trig_ltex  st    
 

 

 



r  c              
   K   s&  t ddd}| tttts dS td| ||f t| ||\}}td||f t	||\}}	td||	f t
|	dkrtd	 dS ||st|||\}
}||
 |tjfS g }g }t|||\}}}|D ]<}||d
 ||||d    ||t|d   qt| ||t| |fS )z
    This rule covers trigonometric factors by splitting everything into a
    sum of exponential functions and collecting complex conjugate poles and
    real symmetric poles.
    r   TrealNz _laplace_rule_trig: (%s, %s, %s)z    f = %s
    g = %sz    xm = %s
    xn = %sr   z#    --> xn is not empty; giving up.r   r`   )r   rZ   r-   r,   r&   r$   rP   r   r   r   r   rO   r  r   r]   r   r   r   r   r(   )r   t_rV   doithintsr   r   r   r   r   re   r   r   r   GZG_planeZG_condr   rW   rW   rX   _laplace_rule_trig(  s*    
"r  c                    sB  t d gd}t d gd}td}| |t| |f }|r>|| jr> fdd|| jD }	t|	dkr>td td	| || f td
 g }
t	|| D ]V}|dkr|| 
 d}nt||  |f
 d}|
||| | d  |  qt||  |dd\}}}|| |||  | t|
   ||fS dS )a  
    This function looks for derivatives in the time domain and replaces it
    by factors of `s` and initial conditions in the frequency domain. For
    example, if it gets ``(diff(f(t), t), t, s)``, it will compute
    ``s*LaplaceTransform(f(t), t, s) - f(0)``.
    r`   r   r_   r   c                    s   g | ]}|  qS rW   rZ   )r~   r   r   rW   rX   r   [  s     z&_laplace_rule_diff.<locals>.<listcomp>rQ   _laplace_apply_rules match:      f, n: %s, %sz#      rule: time derivative (4.1.8)r   Fr   N)r   r   r   r   
is_integerr\   sumrO   rP   r   r   r   r   r   )r   r   rV   r  r  r`   r_   r   r   r   r   r   rd   re   r   r   rW   r   rX   _laplace_rule_diffN  s&     &r  c              	      s  | j rdg}dg}t| D ]$}||r8|| q|| qt|dkrt|}t|| t  dkrt	d t
d| |f t	d t|}	t|	||dd\}
}}|
gd}ztd | }W n tk
r   d}Y nX |
tr2t d D ](}d|d  t|
||d   qn:|rl| t d D ]}td |  qN|rt fd	d
t D  }|||fS dS )a  
    This function looks for multiplications with polynoimials in `t` as they
    correspond to differentiation in the frequency domain. For example, if it
    gets ``(t*f(t), t, s)``, it will compute
    ``-Derivative(LaplaceTransform(f(t), t, s), s)``.
    rQ   r
  r  z(      rule: frequency derivative (4.1.6)Fr   r   r}   c                    s$   g | ]} | d   |  qS r   rW   )r~   r_   NZderiZpcrW   rX   r     s     z'_laplace_rule_sdiff.<locals>.<listcomp>N)is_Mulr   r   r   r   r   r   rI   r   rO   rP   r   r   
ValueErrorrZ   LaplaceTransformr   r   r   )r   r   rV   r  r  ZpfacZofacfacZpexZoexZr_Zp_Zc_Zd1r   re   rW   r  rX   _laplace_rule_sdiffl  sD    


(

r  c                 K   s   | j r
dS t| dd}|j r,t|||ddS t| }|j rJt|||ddS t| }|j rht|||ddS || krt|||ddS tt| }|j rt|||ddS dS )a  
    This function tries to expand its argument with successively stronger
    methods: first it will expand on the top level, then it will expand any
    multiplications in depth, then it will try all avilable expansion methods,
    and finally it will try to expand trigonometric functions.

    If it can expand, it will then compute the Laplace transform of the
    expanded term.
    NFdeepr   )r   r	   r   r   r   )r   r   rV   r  r  re   rW   rW   rX   _laplace_expand  s"    r  c                 C   s<   t ttttttg}|D ] }|| || }dk	r|  S qdS )zk
    This function applies all program rules and returns the result if one
    of them gives a result.
    N)r   r   r   r   r  r  r  )r   r   rV   
prog_rulesp_ruleLrW   rW   rX   _laplace_apply_prog_rules  s      
r  c              	   C   s   t  \}}}d}d}|D ]\}}	}
}}||krD|| ||i}|}||}|rz|
|}W n tk
rx   Y qY nX |tjkrtd td| f td||	f td|f |	|||i||tjf  S qdS )zj
    This function applies all simple rules and returns the result if one
    of them gives a result.
     z"_laplace_apply_simple_rules match:z      f:     %sz      rule:  %s o---o %sz      match: %sN)	r   r   r   xreplacer^   r   r]   rO   rP   )r   r   rV   Zsimple_rulesr  r   Zprep_oldZprep_ft_doms_domcheckplaneprepmar   rW   rW   rX   _laplace_apply_simple_rules  s.    


 
r%  c                    sD  t d|  |f t| }g }g }g }|D ]}|j dd\}	}
t|
 | }dk	rVnt|
 | }dk	rlnvt|
 | }dk	rn`t fdd|
t	D rt
|
 |tjdf}n.t|
 ||d }dk	rnt
|
 |tjdf}|\}}}||	|  || || q*t| }|r*|jdd	}t| }t| }|||fS )
z
    Front-end function of the Laplace transform. It tries to apply all known
    rules recursively, and if everything else fails, it tries to integrate.
    z[LT _l_t] (%s, %s, %s)FZas_AddNc                 3   s   | ]}|  V  qd S ro   r	  r~   Zundefr  rW   rX   r     s     z%_laplace_transform.<locals>.<genexpr>Tr   r  )rP   r   r   as_independentr%  r  r  anyru   r   r  r   r   r   r   r   r(   rD   )r   r  r   r   termsZterms_sr   
conditionsffr   ftre   ri_Zpi_ci_resultr"  	conditionrW   r(  rX   r     sF    
   

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  a  
    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.

    If this is called with ``.doit()``, it returns the Laplace transform as an
    expression. If it is called with ``.doit(noconds=False)``, it returns a
    tuple containing the same expression, a convergence plane, and conditions.
    Laplacec                 K   s    | dd}t||||d}|S )Nr   Fr   )getr   )selfr   r   rV   r  r=   LTrW   rW   rX   _compute_transform"  s    z#LaplaceTransform._compute_transformc                 C   s"   t |t| |  |tjtjfS ro   )r<   r"   r   r   r   )r6  r   r   rV   rW   rW   rX   _as_integral'  s    zLaplaceTransform._as_integralc                 C   sX   g }g }|D ]\}}| | | | qt| }t| }|tjkrPtdd d||fS )Nr4  zNo combined convergence.)r   rD   r(   r   r   r?   )r6  extrar   r   r"  r   rW   rW   rX   _collapse_extra*  s    

  z LaplaceTransform._collapse_extrac                 K   sd   | dd}| dd}td| j| j| jf | j}| j}| j}t||||d}|r\|d S |S dS )	j  
        Try to evaluate the transform in closed form.

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

        Standard hints are the following:
        - ``noconds``:  if True, do not return convergence conditions. The
        default setting is `True`.
        - ``simplify``: if True, it simplifies the final result. The
        default setting is `False`.
        nocondsTr   Fz[LT doit] (%s, %s, %s)r   r   N)r5  rP   functionfunction_variabletransform_variabler   )r6  r  _nocondsr=   r  r   r   re   rW   rW   rX   r  7  s    zLaplaceTransform.doitN)	__name__
__module____qualname____doc___namer8  r9  r;  r  rW   rW   rW   rX   r    s   r  c              
      s    dd}  dd}t| trt| dr  dd }|r|rd}tdd|d tt$ |  fd	d
W  5 Q R  S Q R X nb fdd| D }	|rt|	 \}
}}t	| | j
|
f }|t| t| fS t	| | j
|	f S t| jd|d}|s
|S |d S dS )a&  
    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 attempted, you can switch
    debug information on by setting ``sympy.SYMPY_DEBUG=True``. The numbers
    of the rules in the debug information (and the code) refer to Bateman's
    Tables of Integral Transforms [1].

    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 Laplace transform cannot be fully computed in closed form, this
    function returns expressions containing unevaluated
    :class:`LaplaceTransform` objects.

    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, simplify=True)
    (s/(a + s), -re(a), True)

    References
    ==========

    .. [1] Erdelyi, A. (ed.), Tables of Integral Transforms, Volume 1,
           Bateman Manuscript Prooject, McGraw-Hill (1954), available:
           https://resolver.caltech.edu/CaltechAUTHORS:20140123-101456353

    See Also
    ========

    inverse_laplace_transform, mellin_transform, fourier_transform
    hankel_transform, inverse_hankel_transform

    r=  Fr   	applyfuncz#deprecated-laplace-transform-matrixz
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.
                z1.9)Zdeprecated_since_versionZactive_deprecations_targetc                    s   t | f S ro   laplace_transform)fijr  rV   r   rW   rX   rp     rq   z#laplace_transform.<locals>.<lambda>c                    s   g | ]}t |f qS rW   rH  )r~   rJ  rK  rW   rX   r     s     z%laplace_transform.<locals>.<listcomp>)r=  r   r   N)r5  r[   rE   hasattrrL   rN   rM   rG  r   typeshaper(   rD   r  r  )r   r   rV   Zlegacy_matrixr  rA  r=   r   ZadtZelements_transelementsZavalsr-  Z	f_laplacer7  rW   rK  rX   rI  W  s6    O
rI  c                    s  ddl m}m  ddlm} tddd fdd}| rJ| } | jrt	fd	d
| j
D  }t||dfS z(|| t dtjfddd\}}	W n tk
r   d}Y nX |dkr"|| }|dkrdS |jr|j
d \}}	|trdS 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_exp)inverse_mellin_transformr   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   r}   r   rQ   )r   r+   r\   argumentr4   r   )r\   r   coeffexponente1e2)rQ  r   rW   rX   pw_simp  s    z7_inverse_laplace_transform_integration.<locals>.pw_simpc                    s   g | ]}t | qS rW   )&_inverse_laplace_transform_integration)r~   X)r"  rV   r   r   rW   rX   r     s   z:_inverse_laplace_transform_integration.<locals>.<listcomp>NF)Zneedevalr=  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   rx   )	r   r"   rZ   r4   r   ry   r   r#   Zgts)r   ZH0r`   ry   relr   )r   r[  rW   rX   simp_heaviside  s    




z>_inverse_laplace_transform_integration.<locals>.simp_heavisidec                 S   s   t t| S ro   )r
   r"   )r   rW   rW   rX   simp_exp  s    z8_inverse_laplace_transform_integration.<locals>.simp_exp)Zsympy.integrals.meijerintrP  rQ  sympy.integrals.transformsrR  r   is_rational_functionapartr   r   r\   r=   r   r"   r   r   r?   r   rZ   r<   r]   rl   r+   r   r4   )r   rV   r  r"  r   rP  rR  rX  r   r   r]  r^  rW   )rQ  r"  rV   r   r   r[  rX   rY    sL    

 

rY  c           	      C   s~   ddl m} || \}}||rv|| }t|dkrv|\}}}|||d|   d ||  |d|  d   }|| S )Nr   )fractionr   r}   )rr   rb  r   r   r   r   )	r   rV   rb  r_   r   cfr`   ri   r   rW   rW   rX   _complete_the_square_in_denom"  s    

0rd  c               	   C   sV  t d} t d}td| gd}td| gd}td| gd}td dd	 }d
d }||  |tj|df|| | |   ||d  t| |  t| |dk|dfd| d |d  d  t|| || t||   d|d   tj|dfd| |  ||d  t| tj|dfd| | | |   t	||| || t|  tj|dfg}|| |fS )z
    This is an internal helper function that returns the table of inverse
    Laplace transform rules in terms of the time variable `t` and the
    frequency variable `s`.  It is used by `_inverse_laplace_apply_rules`.
    rV   r   r`   r   ri   r   z._inverse_laplace_build_rules is building rulesc                 S   s*   z|  |W S  tk
r$   |  Y S X d S ro   )factorrG   )r   rV   rW   rW   rX   _frac<  s    z+_inverse_laplace_build_rules.<locals>._fracc                 S   s   | S ro   rW   r   rW   rW   rX   sameB  rq   z*_inverse_laplace_build_rules.<locals>.samerQ   r   r}   r   )
r   r   rO   r   r]   r"   r9   r-   r,   r:   )rV   r   r`   ri   r   rf  rg  
_ILT_rulesrW   rW   rX   _inverse_laplace_build_rules-  s.    <@  &.  ri  c              	   C   s  | dkr4t d tdd td|f t|tjfS t \}}}d}| ||i}|D ]\}}	}
}}|||fkr||| }||f}||}|rVz|
|}W n t	k
r   Y qVY nX |tjkrVt d td| f td||	f td|f t
||	|||i tjf  S qVd	S )
@
    Helper function for the class InverseLaplaceTransform.
    rQ   z*_inverse_laplace_apply_simple_rules match:      f:    %sr   z"      rule: 1 o---o DiracDelta(%s)r  z      rule: %s o---o %s      ma:   %sN)rO   rP   r3   r   r]   ri  r   r   r  r^   r4   )r   rV   r   rh  r   r  Z_prepZfsubsr   r  r!  r#  r  Z_Fr$  r   rW   rW   rX   #_inverse_laplace_apply_simple_rulesT  s2    



(rm  c                 C   s6  t d|gd}t d}| |s2| t| tjfS | t|| }|r|| jrtd t	d| f td t	d|f t|||  tjfS td t
| |||tjfS | t|| | }|r2|| jrtd t	d| f td	 t	d|f t|| ||||  |S td t
| |||tjfS d
S )rj  r`   r   r   z"_inverse_laplace_time_shift match:rk  z+      rule: exp(-a*s) o---o DiracDelta(t-a)rl  z6_inverse_laplace_time_shift match: negative time shiftz6      rule: exp(-a*s)*F(s) o---o Heaviside(t-a)*f(t-a)N)r   rZ   r3   r   r]   r   r"   r   rO   rP   InverseLaplaceTransform_inverse_laplace_transform)r   rV   r   r"  r`   r   r   rW   rW   rX   _inverse_laplace_time_shiftv  s2    

rp  c           	      C   s   t d|gd}t d}| || | }|r|| jr|| jrtd td| f td td|f t|| |||\}}|t|d}|	t
rt|||| |fS t|t||||  |fS d	S )
rj  r_   r   r   z!_inverse_laplace_time_diff match:rk  z,      rule: s**n*F(s) o---o diff(f(t), t, n)rl  rQ   N)r   r   r  rb   rO   rP   ro  rl   r4   rZ   rn  r   )	r   rV   r   r"  r_   r   r   re   r   rW   rW   rX   _inverse_laplace_time_diff  s    
rq  c                 C   s4   t tg}|D ]"}|| ||| }dk	r|  S qdS )rj  N)rp  rq  )r   rV   r   r"  r  r  re   rW   rW   rX   !_inverse_laplace_apply_prog_rules  s    
rr  c                 C   s   | j r
dS t| dd}|j r*t||||S t| }|j rFt||||S t| }|j rbt||||S | |rz| | }|j rt||||S dS )rj  NFr  )r   r	   ro  r   r`  ra  r  )r   rV   r   r"  re   rW   rW   rX   _inverse_laplace_expand  s     
rs  c              	      s  t d| ||f td}| |}t|}g }tjg}	|D ]T}
|
 \}}||	 }|d   fdd|D } fdd||	 D }t
|dkr|d t| }|| q<t
|dkr|d t|d  |  }|t||  q<t
|d	krf|d d }|d |d   }t
|dkr<tjg| }t|\}}|dkrz|| |d||    t| |  }nd
}|jr| }d}tt|d | | d }t| }|r
|t| |  t||  |||  | t| |  t||   }nH|t| |  t||  |||  | t| |  t||   }|t||  q<t| |||dd
d\}}|| |	| q<t| }|r|jd
d}t d|f |t|	 fS )rj  z[ILT _i_l_r] (%s, %s, %s)x_r   c                    s   g | ]}|  qS rW   rW   r   Zdc_leadrW   rX   r     s     z-_inverse_laplace_rational.<locals>.<listcomp>c                    s   g | ]}|  qS rW   rW   r   ru  rW   rX   r     s     rQ   r}   r   FT)r   
dorationalr)  z[ILT _i_l_r]   returns %s)rP   r   ra  r   r   r   r]   Zas_numer_denomr   r   r   r3   r   r"   r4   re  r   tupler   r   rH   r   r*   r   r$   r&   r,   r-   ro  rD   )r   rV   r   r"  r   rt  r   r,  terms_tr-  r   r_   r   r   r   re   r`   ri   lr   Zhypb2bsr/  r   r2  rW   ru  rX   _inverse_laplace_rational  st    



(&
H     

r|  c                    sZ  t | }g }g }td|  |f |D ]}	|	j dd\}
}|rf|	 rft| ||| }dk	rfnt| | }dk	r|nt| || }dk	rnzt| || }dk	rnbt	 fdd|
tD rt| ||tjf}n0t| |||d }dk	rnt| ||tjf}|\}}||
|  || q&t | }|rJ|jdd}t| }||fS )	z
    Front-end function of the inverse Laplace transform. It tries to apply all
    known rules recursively.  If everything else fails, it tries to integrate.
    z[ILT _i_l_t] (%s, %s, %s)Fr&  Nc                 3   s   | ]}|  V  qd S ro   r	  r'  r   rW   rX   r   '  s     z-_inverse_laplace_transform.<locals>.<genexpr>r   r)  )r   r   rP   r*  r`  r|  rm  rs  rr  r+  ru   r   rn  r   r]   rY  r   r   rD   )r   r   r  r"  r   rv  r,  rx  r-  r   r   r   re   r0  r1  r2  r3  rW   r}  rX   ro    sf    

        ro  c                   @   sP   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d ZdS )rn  z
    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.
    zInverse LaplaceNoner   c                 K   s$   |d krt j}tj| ||||f|S ro   )rn  _none_sentinelr>   __new__)r{   r   rV   rc   r"  optsrW   rW   rX   r  L  s    zInverseLaplaceTransform.__new__c                 C   s   | j d }|tjkrd }|S )Nr   )r\   rn  r  )r6  r"  rW   rW   rX   fundamental_planeQ  s    

z)InverseLaplaceTransform.fundamental_planec                 K   s   t |||| jf|S ro   )rY  r  )r6  r   rV   r   r  rW   rW   rX   r8  X  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 )Nr}   )	__class___cr<   r"   r   ZImaginaryUnitr   Pi)r6  r   rV   r   r   rW   rW   rX   r9  \  s     z$InverseLaplaceTransform._as_integralc           	      K   sl   | dd}| dd}td| j| j| jf | j}| j}| j}| j}t|||||d}|rd|d S |S dS )	r<  r=  Tr   Fz[ILT doit] (%s, %s, %s)r   r   N)r5  rP   r>  r?  r@  r  ro  )	r6  r  rA  r=   r   r  r   r"  re   rW   rW   rX   r  c  s    zInverseLaplaceTransform.doitN)rB  rC  rD  rE  rF  r   r  r  r  propertyr  r8  r9  r  rW   rW   rW   rX   rn  >  s   	
rn  Nc                    sB   t | tr,t| dr,|  fddS t| jf  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
    hankel_transform, inverse_hankel_transform
    rG  c                    s   t | f S ro   )inverse_laplace_transform)ZFijr  r"  rV   r   rW   rX   rp     rq   z+inverse_laplace_transform.<locals>.<lambda>)r[   rE   rL  rG  rn  r  )r   rV   r   r"  r  rW   r  rX   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, nrz   c                    sR   |  s| S | jr | S | jr*| S | jr8| S t| trJ| S td S ro   )rZ   r   r  rR   r[   rK   NotImplementedErrore)_ilt_add_ilt_mul_ilt_pow_ilt_rootsumrV   rW   rX   _ilt  s    

z#_fast_inverse_laplace.<locals>._iltc                    s   | j t | j S ro   )r   mapr\   r  r  rW   rX   r    s    z'_fast_inverse_laplace.<locals>._ilt_addc                    s$   |  \}}|jrt| | S ro   )r*  r  r  )r  rT  rs   )r  rV   rW   rX   r    s    z'_fast_inverse_laplace.<locals>._ilt_mulc                    s   |      }|d k	r| |  |   }}}|jr||dk r|| d  t||    ||  t|   S |dkrt||   | S td S r   )r   Z
is_Integerr"   r9   r  )r  r   nmamZbm)r`   ri   r_   rV   r   rW   rX   r    s    4z'_fast_inverse_laplace.<locals>._ilt_powc                    s,   | j j}| j j\}t| jt|t |S ro   )Zfunrs   	variablesrK   Zpolyr   rJ   )r  rs   variabler  rW   rX   r    s    
z+_fast_inverse_laplace.<locals>._ilt_rootsum)r   r   )r  rV   r   rW   )
r  r  r  r  r  r`   ri   r_   rV   r   rX   _fast_inverse_laplace  s    
r  )T)T)T)T)T)T)T)T)TT)N)rE  Z
sympy.corer   r   r   Zsympy.core.addr   Zsympy.core.cacher   Zsympy.core.functionr   r   r	   r
   r   r   r   r   r   Zsympy.core.mulr   r   Zsympy.core.relationalr   r   r   r   r   r   Zsympy.core.sortingr   Zsympy.core.symbolr   r   r   Z$sympy.functions.elementary.complexesr   r   r   r   r    r!   Z&sympy.functions.elementary.exponentialr"   r#   Z%sympy.functions.elementary.hyperbolicr$   r%   r&   r'   Z(sympy.functions.elementary.miscellaneousr(   r)   r*   Z$sympy.functions.elementary.piecewiser+   Z(sympy.functions.elementary.trigonometricr,   r-   r.   Zsympy.functions.special.besselr/   r0   r1   r2   Z'sympy.functions.special.delta_functionsr3   r4   Z'sympy.functions.special.error_functionsr5   r6   r7   Z'sympy.functions.special.gamma_functionsr8   r9   r:   Zsympy.integralsr;   r<   r_  r=   r>   r?   Zsympy.logic.boolalgr@   rA   rB   rC   rD   Zsympy.matrices.matricesrE   Zsympy.polys.matrices.linsolverF   Zsympy.polys.polyerrorsrG   Zsympy.polys.polyrootsrH   Zsympy.polys.polytoolsrI   Zsympy.polys.rationaltoolsrJ   Zsympy.polys.rootoftoolsrK   Zsympy.utilities.exceptionsrL   rM   rN   Zsympy.utilities.miscrO   rP   rt   rw   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r%  r   r  rI  rY  rd  ri  rm  rp  rq  rr  rs  r|  ro  rn  r  r  rW   rW   rW   rX   <module>   s   ,  Z
v
 U$&% 
&

.

+E
x
S
&"#:   
3F
3