
    MZd                     J   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  Znd! ZodEd"Zpd# Zqed$        Zrd% Zsd& Ztd' Zud( Zvd) Zwd* Zxd+ ZydEd,ZzdEd-Z{dEd.Z|dEd/Z}d0 Z~d1 ZdEd2Z G d3 d4eQ      ZdEd5ZdEd6Zd7 Zed8        Zd9 Zd: Zd; Zd< Zd= Zd> Z	 dFd?Z G d@ dAeQ      ZdGdCZdD ZyB)Hz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                     fdfdfdfd}d }ddl m}  ||       }  || t              }  || t        f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                 `    | k(  ry| j                   r| j                  k(  r| j                  S y )N   )is_Powbaser#   )exss    9/usr/lib/python3/dist-packages/sympy/integrals/laplace.pypowerz_simplifyconds.<locals>.powerH   s*    799A66M    c                    | j                        r|j                        ryt        | t              r| j                  d   } t        |t              r|j                  d   }| j                        r d|z  d| z        S  |      }|y	 |dkD  r,t        |       t              |z  k  t        j
                  k(  ry|dk  r-t        |       t              |z  k\  t        j
                  k(  ryyy# t        $ r Y yw xY w)z_ Return True only if |ex1| > |ex2|, False only if |ex1| < |ex2|.
            Else return None. Nr   rT   FT)has
isinstancer    argsr   true	TypeError)ex1ex2nabiggerrZ   rX   s      rY   rf   z_simplifyconds.<locals>.biggerO   s     771:#''!*c3((1+Cc3((1+C771:!C%3''#J9	1u#c(c!fai/AFF:1u#c(c!fai/AFF: ;u 		s   0C3  0C3 3	C?>C?c                     | j                   st        | t              r|j                   st        |t              s| |k  S  | |      }|| S | |k  S )z simplify x < y )is_positiver^   r    )xyrrf   s      rY   repliez_simplifyconds.<locals>.repliee   sL    *Q"4As);EN1aL=5LAr[   c                 8     | |      }|dv ryt        | |      S )NTFT)r   )ri   rj   brf   s      rY   repluez_simplifyconds.<locals>.replueo   s&    1aL!Qr[   c                 >    | dv rt        |       S  | j                  | S )Nrn   )boolreplace)rW   r_   s     rY   replz_simplifyconds.<locals>.replu   s$    8Orzz4  r[   r   )collect_absc                      ||       S N )ri   rj   rl   s     rY   <lambda>z _simplifyconds.<locals>.<lambda>|   s    va| r[   )sympy.simplify.radsimpru   r   r   r   r   )	exprrX   re   rp   rt   ru   rf   rZ   rl   s	    ``   @@@rY   _simplifycondsr|   '   s`    B, ! 3tDb&!Db34Dj&)DT7Nr[   c                 @    t        | | j                  t                    S )zs
    Expand an expression involving DiractDelta to get it as a linear
    combination of DiracDelta functions.
    )rG   atomsr4   r{   s    rY   expand_dirac_deltar      s    
 djj455r[   c                    t        d      t        d| f       t        d|f       | j                  t              ryt	        | t         z        z  t        j                  t        j                  f      }t        d|f       |j                  t              s;t        |j                        |      t        j                  t        j                  fS |j                  st        d       y|j                   d   \  }}|j                  t              rt        d       yfd	}t#        |      D cg c]
  } ||       }}|D 	cg c]0  }	|	d
   t        j$                  k7  s|	d   t        j                  ur|	2 }
}	|
s&|D 	cg c]  }	|	d
   t        j$                  k7  s|	 }
}	t'        t)        |
            }d |j+                  fd       |st        d       y|d   \  }}fd}|rt-        ||      }t-        ||      }t        |j                        |       ||      t/         ||            fS c c}w c c}	w c c}	w )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.
    rX   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                    ddl m} t        j                  }t        j                  }t        t        |             } t        dt        g      \  }}}}}}	}
|t        t        |z   |z              z  |k  |t        t        |z   |z              z  |k  t        t        |z   |z  |z  |            |k  t        t        |z   |z  |z  |            |k  t        t        t        |z         |z  |z  |            |k  t        t        t        |z         |z  |z  |            |k  f}| D ]  }t        j                  }g }t        |      D ]  }|j                  r$|j                   j"                  v r|j$                  }|j                  r"t'        |t(        t*        f      r|j,                  }|D ]  }|j/                  |      s n r9|   j0                  r*|   |   z  t2        dz  k(  rt5        |   z          dk  }|j/                  |t7        |t        t        |
z              z  |z        t        |z        |	z  z  z
  dk        sN|j/                  t7        |t        t        |z  |
z  |            |z  z
        t        |z        |	z  z  dk        sW|j/                  |t7        t        t        t              |z  |
z  |            |z        t        |z        |	z  z  z
  dk        r*t9        fd||||	|
fD              rt5              |   kD  }|j;                  t4        d       j=                  t5                    }|j                  r0|j>                  dv s"|jA                        s|jA                        s||gz  }O ||      }|j                  r|j>                  dv r||gz  }z|jB                  k(  rtE        d	         y
tG        |jB                  |      } |t        j                  urtI        ||      }tK        |tM        |       } ||j                  r|jN                  fS |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   <   K   | ]  }|   j                     y wrw   )rh   ).0wildms     rY   	<genexpr>zH_laplace_transform_integration.<locals>.process_conds.<locals>.<genexpr>   s      -TQtW00 -s   c                 D    | j                         j                         d   S )Nr   )r
   as_real_imag)ri   s    rY   ry   zG_laplace_transform_integration.<locals>.process_conds.<locals>.<lambda>   s    !((*"9"9";A"> r[   )z==z!=z/[LT _l_t_i ]     convergence not in half-plane.N)(sympy.solvers.inequalitiesr   r   NegativeInfinityr`   rB   rA   r   r   r    r   r"   r!   InfinityrC   is_Relationalrhsfree_symbolsreversedr^   r   r   reversedsignmatchrh   r   r   r-   allrs   subsrel_opr]   ltsrP   r*   r)   rE   rD   	canonical)condsr   re   auxpqw1w2w3w4w5patternsca_aux_dpatd_solnr   rX   ts                      @rY   process_condsz5_laplace_transform_integration.<locals>.process_conds   s%   @ff&-(#* dQC$9 1b"b"b c#q2vqj/""R'c#q2vqj/""b(!1r6A+a-45:!1r6A+a-45;!:a"f#5"9!";R@ABF!:a"f#5"9!";R@ARGI  .	*ABDq\ '+??qAEE,>,>'>

A??z!b"X'>A# CA 1))aeAaDjBqD.@A"I*AGGABs3qt9~$5b$8 9#ae*b. HH1LMA$5aeBh$B CB FFGArE
B')*+,A C 1*Q-2CB2F JKBN!!R%j"n- -/012A  -BB>, - -1!AYY>@@DRUA  OOqxx</G66!9BFF1IQCKD(Q/))T[[L-HQCKD88q=KLTXXr*BO'+P #AJ#r4y)].	*^ 3#4#4#--==#==r[   rT   c                 ,    | dv ry| j                         S )Nrn   r   )	count_opsr   s    rY   cntz+_laplace_transform_integration.<locals>.cnt   s    = ~~r[   c                 &    | d     | d         fS Nr   rT   rx   )ri   r   s    rY   ry   z0_laplace_transform_integration.<locals>.<lambda>   s    qteS1Y/ r[   )keyz&[LT _l_t_i ]     no convergence found.c                 (    | j                        S rw   )r   )r{   rX   s_s    rY   sbsz+_laplace_transform_integration.<locals>.sbs   s    yyBr[   )r   rQ   r]   r4   r<   r#   r   Zeror   r=   r>   r   r   r`   is_PiecewiserP   r_   rC   falselistr   sortr|   r   )fr   r   simplifyFcondr   r   r   ri   conds2re   r   r   r   rX   s    ``           @@rY   _laplace_transform_integrationr      s    	c
A
3aAY?
-|<uuZ!C1I+1661::67A
,qe455?2113E3EqvvMM>>/0ffQiGAtuuX=>>>@ (17!]17E7 :A!A$gg#A$a&8&88  :F :"6adaggo!66!E  
JJ/J0671XFAs 1a#S!Q'QVVAr]H-s1vz#c(7KKK/ 8: 7s   8II	)I	
I&Ic                     | j                   }t        | j                        }t        | j                        dk(  r| S |D cg c]  }t	        ||       }}|j
                  r || j                  |      S  || S c c}w )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   )funcr   r_   len_laplace_deep_collectis_Addcollect)r   r   r   r_   r   s        rY   r   r      su     66D<D
166{a9=>#%c1->>;;;&&q));	 ?s    A:c                  C   t        d      t        d      } t        dg      }t        dg      }t        dg      }t        dg      }t        dg      }fd	}t        d
       g ||| z  t        j                  t        j
                  |ft        |z  |z
        t        |  |z  |z        t        |      z  t        t        |dkD  |dk\        t        |dk  |dk              t        j                  |ft        |z  |z
        t        d      t        t        |dk  |dk\        t        |dkD  |dk              t        j                  |ft        |z  |z
        t        |  |z  |z        | z  t        |dkD  |dkD        t        j
                  |ft        |z  |z
        dt        |  |z  |z        z
  | z  t        |dk  |dk        t        j
                  |ft        |z  |z
        d| z  t        |dkD  |dk        t        j
                  |ft        |z  |z
        dt        |dk  |dkD        t        j
                  |fd| dz  z  t        j                  t        j
                  |fd|z  |z   z  t        | |z  | z         t        | |z  | z        z  |z  t        t        ||z              t        k  t        j
                  |fdt!        |z  |z         z  t!        |t        z  | z        t        ||z  | z        z  t#        t!        ||z  | z              z  |z  t        t        ||z              t        k  t        j
                  |f|z  |z   t        d       dz  z  d|t        d       dz  z  z  dt        | z  |z  t        d      dz  z  z  t        ||z  | z        z  t#        t!        ||z  | z              z  |z  z
  t        t        ||z              t        k  t        j
                  |ft!              |z   z  t!        t        | z        t        t!        |      z  t        || z        z  t#        t!        || z              z  z
  t        t        |            t        k  t        j
                  |fd|t!              z  dz  z   z  t        |t        d      dz  z  z  t        || z        z  t#        t!        || z              z  t        j                  t        j
                  |f|z  t%        |dz         | |dz   z  z  |dkD  t        j
                  |f|z  |z   |z  t'        |dz   ||z  | z        t        | |z  | z        z  | |dz   z  z  |z  t        |dkD  t        t        ||z              t        k        t        j
                  |f|z  |z   z  ||z  t%        |dz         z  t'        | || z        z  t        |dkD  t        t        |            t        k        t        j
                  |ft        |z  |z
        t        |       | |z
  z  t        j                  t)        |      |ft        |z  |z
        z  t        |       | |z
  dz  z  t        j                  t)        |      |f|z  t        |z        z  t%        |dz         | |z
  |dz   z  z  t)        |      dkD  t)        |      |ft        | dz  z        t!        t        dz  |z        t        | dz  dz  |z        z  t#        | t!        d|z        z        z  t)        |      dkD  t        j
                  |ft        | dz  z        z  dd|z  z  dt!        t              z  d|z  t        d      dz  z  z  | z  t#        | t!        d|z        z        z  z
  t)        |      dkD  t        j
                  |ft        | z        dt!        || z        z  t+        ddt!        || z        z        z  t)        |      dk\  t        j
                  |ft!              t        | z        z  t        d      dz  t!        t        | dz  z        z  ddt!        || z        z  z   z  t        dt!        || z        z        z  t)        |      dk\  t        j
                  |ft        | z        t!              z  t!        t        | z        t        dt!        || z        z        z  t)        |      dk\  t        j
                  |ft        | z        t!              z  z  t!        t        |z        t        dt!        || z        z        z  t)        |      dkD  t        j
                  |f|z  t        | z        z  d|| z  |dz   dz  z  z  t+        |dz   dt!        || z        z        z  t)        |      dkD  t        j
                  |ft        dt!        |z        z        | dz  t!        t        |z        | t        d       dz  z  z  t        || z        z  t#        t!        || z              z  z
  t        t        |            t        k  t        j
                  |ft        dt!        |z        z        t!              z  t        | z  t        d      dz  z  t        || z        z  t#        t!        || z              z  t        t        |            t        k  t        j
                  |ft-        |z        t-        t        t        j.                        | z  |z         | z  |dkD  t        j
                  |ft-        d|z  z         t        | |z         | z  t        |  |z        z  t        t        |            t        k  t        j
                  |ft-        |z  |z         t-        |      t        | |z  |z        | z  |z  t        |  |z        z  z
  | z  |z  t        |dkD  t        t        |            t        k        t        j
                  |ft-              t!              z  t!        t        | z         t-        d| z  t        t        j.                        z        z  t        j                  t        j
                  |f|z  t-              z  t%        |dz         | | dz
  z  z  t1        |dz         t-        |       z
  z  t)        |      dkD  t        j
                  |ft-        |z        dz  t-        t        t        j.                        | z  |z        dz  t        dz  dz  z   | z  |dkD  t        j
                  |ft3        |z        || dz  |dz  z   z  t        j                  t        t5        |            |ft        t3        |z              || dz  |dz  z   z  t7        t        | z  dz  |z        z  |dkD  t        j
                  |ft3        |z        z  t9        || z        t        j                  t        t5        |            |ft3        |z        dz  z  t-        dd|dz  z  | dz  z  z         dz  t        j                  dt        t5        |            z  |ft3        |z        dz  dz  z  |t9        d|z  | z        z  | t-        dd|dz  z  | dz  z  z         z  dz  z
  t        j                  dt        t5        |            z  |ft3        dt!        |z        z        t!        t        |z        | z  t!        |       z  t        | | z        z  t        j                  t        j
                  |ft3        dt!        |z        z        z  t        t;        t!        || z              z  t        j                  t        j
                  |ft=        |z        | | dz  |dz  z   z  t        j                  t        t5        |            |ft=        |z        dz  | dz  d|dz  z  z   | dz  d|dz  z  z   z  | z  t        j                  dt        t5        |            z  |ft!              t=        dt!        |z        z        z  t!        t              dz  | t        d       dz  z  z  | d|z  z
  z  t        | | z        z  t        j                  t        j
                  |ft=        dt!        |z        z        t!              z  t!        t        | z        t        | | z        z  t        j                  t        j
                  |ft3        |z        t3        |z        z  d|z  |z  | z  | dz  ||z   dz  z   z  | dz  ||z
  dz  z   z  t        j                  t        t5        |            t        t5        |            z   |ft=        |z        t3        |z        z  || dz  |dz  z
  |dz  z   z  | dz  ||z   dz  z   z  | dz  ||z
  dz  z   z  t        j                  t        t5        |            t        t5        |            z   |ft=        |z        t=        |z        z  | | dz  |dz  z   |dz  z   z  | dz  ||z   dz  z   z  | dz  ||z
  dz  z   z  t        j                  t        t5        |            t        t5        |            z   |ft?        |z        || dz  |dz  z
  z  t        j                  t        t)        |            |ftA        |z        | | dz  |dz  z
  z  t        j                  t        t)        |            |ft?        |z        dz  d|dz  z  | dz  d|dz  z  | z  z
  z  t        j                  dt        t)        |            z  |ftA        |z        dz  | dz  d|dz  z  z
  | dz  d|dz  z  | z  z
  z  t        j                  dt        t)        |            z  |ft?        |z        z  t-        | |z   | |z
  z        dz  t        j                  t        t)        |            |f|z  t?        |z        z  t%        |dz         dz  | |z
  | dz
  z  | |z   | dz
  z  z
  z  |dkD  t        |      |f|z  tA        |z        z  t%        |dz         dz  | |z
  | dz
  z  | |z   | dz
  z  z   z  |dkD  t        |      |ft?        dt!        |z        z        t!        t        |z        | z  t!        |       z  t        || z        z  t        j                  t        j
                  |ftA        dt!        |z        z        d| z  t!        t        |z        | z  t!        |       z  t        || z        z  t;        t!        || z              z  z   t        j                  t        j
                  |ft!              t?        dt!        |z        z        z  t        t        d      dz  z  | t        d       dz  z  z  | dz  |z   z  t        || z        z  t;        t!        || z              z  |t        d      dz  z  | dz  z  z
  t        j                  t        j
                  |ft!              tA        dt!        |z        z        z  t        t        d      dz  z  | t        d       dz  z  z  | dz  |z   z  t        || z        z  t        j                  t        j
                  |ft?        dt!        |z        z        t!              z  t        t        d      dz  z  | t        d       dz  z  z  t        || z        z  t;        t!        || z              z  t        j                  t        j
                  |ftA        dt!        |z        z        t!              z  t        t        d      dz  z  | t        d       dz  z  z  t        || z        z  t        j                  t        j
                  |ft?        t!        |z              dz  t!              z  t        t        d      dz  z  dz  | t        d       dz  z  z  t        || z        dz
  z  t        j                  t        j
                  |ftA        t!        |z              dz  t!              z  t        t        d      dz  z  dz  | t        d       dz  z  z  t        || z        dz   z  t        j                  t        j
                  |ft;        |z        t        | dz  d|z  dz  z        t#        | d|z  z        z  | z  dt        t        |            z  t        k  t        j
                  |ft;        t!        |z              t!        |      t!        | |z         z  | z  t        j                  tC        t        j
                  t)        |             |ft        |z        t;        t!        |z              z  t!        |      t!        |       z  | |z
  z  t        j                  tC        t        j
                  t)        |            |ft;        t!        |z        dz        dt        t!        || z               z
  | z  t)        |      dkD  t        j
                  |ft#        t!        |z              t!        | |z         t!        |      z
  t!        | |z         z  | z  t        j                  t)        |       |ft        |z        t#        t!        |z              z  d| t!        || z        z   z  t        j                  t        j
                  |ft#        t!        |z        dz        t        t!        || z               | z  t)        |      dkD  t        j
                  |ftE        ||z        ||z  t!        | dz  |dz  z         | t!        | dz  |dz  z         z   |z  z  z  t)        |      dkD  t        t5        |            |f|z  tE        ||z        z  d|z  t!        t              z  t%        |t        jF                  z         z  ||z  z  | dz  |dz  z   | t        jF                  z
  z  z  t        t)        |      t        jF                   kD  tI        ||            t        t5        |            |f|z  tE        ||z        z  d|dz   z  t!        t              z  t%        |t        d      dz  z         z  ||z  z  | z  | dz  |dz  z   | t        d      dz  z
  z  z  t        t)        |      dkD  tI        ||dz               t        t5        |            |ftE        ddt!        |z        z        t        | | z        | z  t        j                  t        j
                  |f|z  tE        |dt!        |z        z        z  ||dz  z  | | dz
  z  z  t        | | z        z  t        t)        |      dkD  tI        ||t        jF                  z              t        j
                  |ftE        d|t!        dz  |z  z         z        t        || z  |t!        | dz  |dz  z         z  z
        t!        | dz  |dz  z         z  t        t        |            t        k  t        t5        |            |ftK        ||z        ||z  t!        | dz  |dz  z
        | t!        | dz  |dz  z
        z   |z  z  z  t)        |      dkD  t        t)        |            |f|z  tK        ||z        z  d|z  t!        t              z  t%        |t        jF                  z         z  ||z  z  | dz  |dz  z
  | t        jF                  z
  z  z  t        t)        |      t        jF                   kD  tI        ||            t        t)        |            |f|z  tK        ||z        z  d|dz   z  t!        t              z  t%        |t        d      dz  z         z  ||z  z  | z  | dz  |dz  z
  | t        d      dz  z
  z  z  t        t)        |      dkD  tI        ||dz               t        t)        |            |f|z  tK        |dt!        |z        z        z  ||dz  z  | | dz
  z  z  t        || z        z  t        t)        |      dkD  tI        ||t        jF                  z              t        j
                  |ftM        d|z        dt        z  tO        | |z        z  t!        | dz  |dz  z         z  t        j                  t        t5        |            |ft+        d|z        t-        | t!        | dz  |dz  z
        z   |z        t!        | dz  |dz  z
        z  t        j                  t)        |       |f}|| 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   rX   re   r   ro   rd   tauomegac                     t        |       S rw   )r   )r   r   s    rY   dcoz!_laplace_build_rules.<locals>.dco+  s    ,Q22r[   z&_laplace_build_rules is building rulesr   rT   r      g      ?         )(r   r   rP   r   r`   r   r4   r#   r    rD   rE   r   r5   r8   r   r   r+   r7   r:   r;   r   r2   r$   
EulerGammar9   r.   r   r&   r/   r6   r-   r'   r%   r)   r1   Halfr   r0   r3   r(   )	rX   re   ro   rd   r   r   r   laplace_transform_rulesr   s	           @rY   _laplace_build_rulesr     s=    $ 	c
Ac
AS1#AS1#AS1#A
uqc
"C1#&E2	
23u	
AaC	
	u 
AaCE	C1QKA.	CAqAvAE16 2	3	
		S	"u 
AaCE	AaD	CAqAvAE16 2	3	
		S	"u 
1Q3q5	3r!tAv;q=	QUAE	AFFC	)u 
1Q3q5	Ac1"Q$q&kM1,	QUAE	AFFC	)u 
1Q3q5	1Q3	QUAF	QVVS	*u 
1Q3q5	1	QUAE	AFFC	)u" 
AadF	
	#u& 
AaCES!Aa[LQBqDF+A-	S1X	QVVS	*'u* 
4!A;QrT!VS1QZ/T!A#a%[0AA!C	S1X	QVVS	*+u. A#a%AaD57		
1!uQw<2a46QqT!V,,S1QZ7$tAaCE{:KKAM	M	S1X	QVVS	*/u4 
a!A#RT
2d1g:c!A#h#6tD1I#FF	SVr	1663	(5u8 
Ad1gIC 	!2a!A$q&k>#ac(#:4QqS	?#J	
	9u< 
AuQqSz!ac("	
R	=u@ A#a%!Z!QqSU+C1QK7AaC@B	QVSQqS]R'	(!&&#	7AuD 
AqsQT%!*_ZAaC%88	QVSQ[2%	&	5EuH 
QqSWsC4y!A#	
A	IuL 
3qs3w<cTAaC!8+	
A	MuP 
Ac!A#hac
AaC1Q3</	ARUC	!QuT 
aR1WtBqDF|C1QqM1$qac{2CC	AAFFC	!UuX 
3r!Q$w<	
AaC48QqSAaDFO+A-d1T!A#Y;.??	?	AAFFC	!Yu^ 
aRTAd1Q3iK1T!A#Y; 77	A!QVVS	"_ub 
aaRT		
1aR1W	q4!9}	-c"T!A#Y,.?	?	A!QVVS	"cuh 
aRT47	DAJs2d1Q3i<'88	A!QVVS	"iul 
aRTAd1gI	RT
3r$qs)|+< <	AAFFC	!mup 
Ac1"Q$iAaCAaC7++GAaC4!9,EE	AAFFC	!qut 
RQqS	\		
RbdA1aL(QqS1DacOC	C	SVr	1663	(uuz 
RQqS	\	47	"RTQqT!V$4S1X$=d4!9o$M	SVr	1663	({u~ 
QqSCALL)!+A-..q0	
Q	uB 
QqsUc!A#hYq[QBqD)	SVr	1663	(CuF 
QqSUc!fS1QZ\!^Br!tH44a79	QUCAK"$	%qvvs	4GuJ 
QQ$r!t*S1S->)>%??	
	KuN 
Ac!feAaCjaRT*GAaCLQ,?@	AQVVS	"OuR 
QqS1s3q||,Q.q0114RU1W<a?	
Q	SuV 
U1Wuad5!8m,	
RY	&WuZ 
Sq\	E1a4q=1$r!tAve|2DD	AFFC	![u^ 
U1WaeAg	
RY	&_ub 
U1Wq	C!E1H*QT/ 1214	
3r%y>!3	(cuf 
U1WqA		tAeGAI	qQqz!Q$%6!779	9	
3r%y>!3	(gul 
QtAaCy[	41:a<Q/QBqD	9	
	mup 
QtAaCy[	!	RD1I.	
	qut 
U1Wq!Q$uax-(	
RY	&uux 
U1Wq1a4%(
?QT!E1H*_=a?	
3r%y>!3	(yu| 
aQtAaCy[!	!48A:a1Q4%'l#:AacE#B3r!t9#L	
	}u@ 
QtAaCy[	$q'	!41:c1"Q$i#7	
	AuD 
QqS#ac(	AaCE!GQT1Q3(]3QT1Q3(]C	
RUC1J&	-EuH 
QqS#ac(	Aq!tAqDyA~.1acAX>1acAXN	
RUC1J&	-IuL 
QqS#ac(	Aq!tAqDyA~.1acAX>1acAXN	
RUC1J&	-MuP 
acAq!tAqDyM	
RUS	"QuT 
acAq!tAqDyM	
RUS	"UuX 
acAqAvq!tAadF1H}-	
3r!u:s	$Yu\ 
acA1Qq!tVad1QT6!8m4	
3r!u:s	$]u` 
ac1c1Q31+&q(	
RUS	"aud 
Ad1Q3iqsA!r!t}acaRT]'BC	
RQ	euh 
Ad1Q3iqsA!r!t}acaRT]'BC	
RQ	iul 
aQqS	k	DAJqLa0QqS9	
	mup 
aQqS	k	AaCRT
1T!W 4S1X =c$qs)n LL	
	quv GD4!9%%1aLadU1W%qs1u-!Hac^$$%!QKB$78FFAFFC		!uu~ 
aaQqS	k"	"B1aLadU1W$=qs1u$Ec!A#h$N	
	uB 
aQqS	k	47	"	ad1fa1Q4%'l	"3qs8	+c$qs)n	<FFAFFC	!CuH 
aQqS	k	47	"B1aLadU1W$=c!A#h$F	
	IuL 
d1Q3i!	DG	#R!A$q&\!^A1aL%@#ac(1*%M	
	MuP 
d1Q3i!	DG	#R!A$q&\!^A1aL%@#ac(1*%M	
	QuT 
QqS3q!tQqS1H}%d1ac7m3A5	
3s1v;	QVVS	*UuX 
T!A#Yaac*1,	
QVVbeV$c	+Yu\ 
QqS#d1Q3i.	 $q'$q'/1Q3"7	
QVVRU#S	*]u` 
T!A#Yq[	Ac4!9*o-q0	AAFFC	!aud 
d1Q3i4!9T!W,d1Q3i79	
"Q%	euh 
QqS$tAaCy/	!1aQqS	k?	
	iul 
d1Q3ik	Cac
OA-	AAFFC	!mup 
AaC!Q$QT!Q$Y41QT	?1BQ0F FG	ASAZ	&qut 
Aga1o		
Ad2huQqvvX	&q!t	+QT!Q$Y1"QVV),D	D	RUaffW_bAh	'RUS	:uuz 
Aga1o		
QqS$r(	51Q46?	*1a4	/	11a4191Q46	2J	J	RURZAqs	$c"Q%j#	7{u@ 
Ad1Q3iK	 #qbd)A+	
	AuD 
Q1T!A#Y;'	'QqS!qbd));C1I)E	RURZAqx	)1663	8EuH 
Ad1a4!8n$	%	QqS41QT	?""	#DAadO	3	SVr	3r!u:s	,IuN 
AaC!Q$QT!Q$Y41QT	?1BQ0F FG	ASAZ	&OuR 
Aga1o		
Ad2huQqvvX	&q!t	+QT!Q$Y1"QVV),D	D	RUaffW_bAh	'RUS	:SuX 
Aga1o		
QqS$r(	51Q46?	*1a4	/	11a4191Q46	2J	J	RURZAqs	$c"Q%j#	7Yu^ 
Q1T!A#Y;'	'QqS!qbd));C!H)D	RURZAqx	)1663	8_ub 
AaC"R%ac
*41QT	?:	
RUS	"cuf 
AaC#q41QT	?2A56QT!Q$YH	
"Q%	gul #Aq((r[   c                    t        d|g      }t        dd      }| j                  |      }|r||   j                  d   j	                  |      } |j                  ||z        }|ru||   j
                  rf||   dk7  r^t        d       t        d| ||f       t        d	       t        d||   z  ||   j                  |      z  ||||   z  d
      \  }}	}
||	|
fS y)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``.
    re   r   grT   )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   rh   rP   rQ   _laplace_transformr   )r   r   rX   re   r   ma1r   ma2rk   prcrs              rY   _laplace_rule_timescaler     s     	S1#AS"A
''!*C
!fkk!n$$Q'cii!n3q6%%#a&A+45.C>45*1SV8CFKKN+B+,aAhHIAr2r2;r[   c                 N   t        d|g      }t        d      }t        d      }| j                  t        |      |z        }|r||   j                  ||z
        }|rx||   j                  rit	        d       t        d| ||f       t	        d       t        ||   j                  ||||   z         ||d	      \  }}	}
t        ||    |z        |z  |	|
fS |rO||   j                  r@t	        d       t        d| ||f       t	        d
       t        ||   ||d	      \  }}	}
||	|
fS y)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.
    re   r   rj   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   r5   rh   rP   rQ   r   r   r#   is_negative)r   r   rX   re   rj   r   r   r   rk   r   r   s              rY   _laplace_rule_heavisider     s0    	S1#AS	AS	A
'')A,q.
!C
!fll1Q33q6%%45.C>23*3q6;;q!CF(+CQ49;IAr2Q	N1$b"--3q6%%45.C>MN*3q61a%HIAr2r2;r[   c                    t        d|g      }t        d      }t        d      }| j                  t        |      |z        }|r}||   j                  |      j                  ||z        }|rUt	        d       t        d| ||f       t	        d       t        ||   ||||   z
  d	      \  }}	}
||	t        ||         z   |
fS y
)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)``.
    re   r   rj   zr   r   z%      rule: multiply with exp (4.1.5)Fr   N)r   r   r#   r   rP   rQ   r   r   )r   r   rX   re   rj   r   r   r   rk   r   r   s              rY   _laplace_rule_expr   "  s     	S1#AS	AS	A
''#a&(
C
!fnnQ%%ac*45.C>9:*3q61aAh49;IAr2r"SV*}b))r[   c           
         t        d|g      }t        d|g      }t        d      }t        d      }| j                  t        |      |z        }|r||   j                  t              s||   j	                  |      j                  ||z  |z
        }|rt        d       t        d| ||f       t        d       ||   ||   z  }	t        |	      d	k\  rlt        |	      d	k(  r^t        ||    ||   z  |z        ||   j                  |||   ||   z        z  ||   z  }
|
t        j                  t        j                  fS d	t        j                  t        j                  fS ||   j                  |      rt        ||   |      }t        i urt!        |j#                               d
hk(  rt%        ||   |      }t'        t)        |j+                               D cg c]V  }t        |      d	k(  rFt        |      d	k\  r8t        | |z        ||   j                  ||      z  |j                  ||      z  X c} }
|
t        j                  t        j                  fS yc c}w )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)``.
    re   r   ro   rj   r   r   r   z$      rule: multiply with DiracDeltar   rT   N)r   r   r4   r]   r   rP   rQ   r   r   r#   r   r   r   r`   is_polynomialrI   setvaluesr   r   r   keys)r   r   rX   re   ro   rj   r   r   r   locrk   rosloperi   s                 rY   _laplace_rule_deltar   :  s    	S1#AS1#AS	AS	A
''*Q-/
"C
3q6::j)!fnnQ%%ac!e,45.C>89a&Q-C#w!|31QAq()#a&++aQA*GGAN1--qvv661--qvv66q6"s1vq!BB3ryy{#3s#:SVQ#BGGIM"Q%1*A! 1"Q$iAAq 11%**Q2BB MN 1--qvv66Ms   AIc                 :   t         j                  g}t         j                  g}t        j                  |       D ]N  }|j	                  t
        t        t        t        t              r|j                  |       >|j                  |       P 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_argsr]   r.   r-   r'   r%   r#   append)fntrigsothertermr   r   s         rY   _laplace_trig_splitr   `  s{     UUGEUUGEb! 88CdD#.LLLL	
 	UAUAa4Kr[   c                    t        d      }t        d|g      }g }g }| j                  t              j                         }t	        j
                  |      D ]   }|j                  |      s"|j                  d|ddt        dt        di       7|j                  d      }|j                  |t        |      z        x}||   j                  |      x}	|	j                         }
t        |
      d	k(  rO|j                  d||   t        |
d
         z  d|
d   t        t        |
d         t        t        |
d         i       |j                  |       |j                  |       |j                  |       # ||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   kre   r   r#   )combiner   rT   )r   rewriter#   r
   r   r   r]   r   r   r   powsimpr   as_poly
all_coeffsr   )r   r   r   r   xmxnx1r   rk   mpmcs              rY   _laplace_trig_expsumr  r  sL    	S	AS1#A	B	B	
3			 Bb! xx{IIsD#q"aQ78||E|*Ac!fH%%A2dll1o%2]]_r7a<IIQqT#be*_c2a5Br!uIr2be96 7 IIdO		$IIdO#$ r6Mr[   c           	         g }g }d fd}fd}fd}fd}d }	t        |       dkD  r| j                         }
d}d}d}t        t        |             D ]  }|
t           | |   t           k(  }|
t           | |   t            k(  }|
t           | |   t           k(  }|
t           | |   t            k(  }|r|r|
t           dk7  r|
t           dk7  r|}||r|r|
t           dk7  r|}|s|s|
t           dk7  s|} ||||j                   ||
| |   d	   | |   d	   | |   d	   |             |j                  t        t        |
d
                      |||g}|j                  d       |D ]  }| j                  |        n#|I|j                   ||
| |   d	   |             |j                  |
t                  | j                  |       n|R|j                   ||
| |   d	   |             |j                  t        |
t                        | j                  |       n|R|j                   ||
| |   d	   |             |j                  t        |
t                        | j                  |       n0|j                   |	|
|             |j                  |
t                  t        |       dkD  rt        | 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                 6   | j                         }t        t        |            D ]q  }||   j                         }|d   j	                  t
              r||   j                  t              ||<   J|d   t        |d   z  z   j                  t              ||<   s |S r   )	copyranger   r   r]   r   r  r-   r   )coeffsncr   ris       rY   _simpcz"_laplace_trig_ltex.<locals>._simpc  s    [[]s2w 	7AA##%B!uyy}1c*1A2a511#61	7 	r[   c           
      6   | d   | d   | t            | t           f\  }}}}||z   |z   |z   |||z   |z
  |z
  z  dt        z  |z  |z  z
  dt        z  |z  |z  z   |dz  | |z
  |z
  |z
  z  |dt        z  |z  |z  dt        z  |z  |z  z   z  z   d|dz  z  |z  z   d|dz  z  |z  z   |dz  | |z
  |z   |z   z  |dz  dt        z  |z  |z  dt        z  |z  |z  z   dt        z  |z  |z  z
  dt        z  |z  |z  z
  z  z   |d|dz  z  |z  d|dz  z  |z  z
  z  z   g}	t        j                  t        j
                  d|dz  z  d|dz  z  z
  t        j
                  |dz  d|dz  z  |dz  z  z   |dz  z   g}
t        t         |	      t        t        |	            d d d         D cg c]  \  }}|||z  z   c}} }t        t        |
t        t        |
            d d d         D cg c]  \  }}|||z  z   c}} }t        d||f       ||z  S c c}}w c c}}w )Nre   r   r   r   r   r   z        quadpole: (%s) / (%s))r   r   r   r   r   r   r   zipr  r   rQ   )t1k1k2k3rX   re   k0a_ra_ir  dcri   rj   rd   r   r  s                  rY   	_quadpolez%_laplace_trig_ltex.<locals>._quadpole  su   S'2c7BrFBrF:2sCGbL2rBw|b !AaCGBJ.1S;1rcBhmb()1Q3s72:!C
*+,#q&Qhrk* 1rcBhmb()1ac#gbj1Q3s72:-!C
:QqSWRZGHI1S!V8B;36",-.
 EE1661S!V8aQh.FFCFQsAvXc1f_,sAv57 !$VBZs2w"1E!FGAa1fGI!$Rs2w")=!>?Aa1f?A.A7s
	 H?s   "H
%H
c           
         | d   | d   | t            | t           f\  }}}}||z   | |z  ||z  z
  dt        z  |z  |z  z   g}t        j                  d|z  |dz  |dz  z   g}t        t         |      t        t        |            d d d         D 	
cg c]  \  }	}
|	||
z  z   c}
}	 }t        t        |t        t        |            d d d         D 	
cg c]  \  }	}
|	||
z  z   c}
}	 }t        d||f       ||z  S c c}
}	w c c}
}	w )Nre   r   r   r   r   z        ccpole: (%s) / (%s)
r   r   r   r   r   r   r  r  r   rQ   )r  r  rX   re   r  r  r  r  r  ri   rj   rd   r   r  s                rY   _ccpolez#_laplace_trig_ltex.<locals>._ccpole  s   S'2c7BrFBrF:2sC2gr"uqt|ac#gbj01eeRVS!Vc1f_-!$VBZs2w"1E!FGAa1fGI!$Rs2w")=!>?Aa1f?A,q!f5s
	 H?s   D 
D
c           
      &   | d   | d   | t            | t           f\  }}}}||z   ||z  ||z  z
  dt        z  |z  |z  z
  g}t        j                  dt        z  |z  |dz   |dz  z
  g}t        t         |      t        t        |            d d d         D 	
cg c]  \  }	}
|	||
z  z   c}
}	 }t        t        |t        t        |            d d d         D 	
cg c]  \  }	}
|	||
z  z   c}
}	 }t        d||f       ||z  S c c}
}	w c c}
}	w )Nre   r   r   r   r   z        rspole: (%s) / (%s)r   )r  r  rX   re   r  r  r  r  r  ri   rj   rd   r   r  s                rY   _rspolez#_laplace_trig_ltex.<locals>._rspole  s   S'2c7BrFBrF:2sC2gqtad{QqSWRZ/0eeRT#XQwa/0!$VBZs2w"1E!FGAa1fGI!$Rs2w")=!>?Aa1f?A,q!f5s
	 H?s   D
D
c           
         | d   | d   }}||z   |||z
  z  g}t         j                  t         j                  |dz   g}t        t	         |      t        t        |            d d d         D cg c]  \  }}|||z  z   c}} }	t        t	        |t        t        |            d d d         D cg c]  \  }}|||z  z   c}} }
t        d|	|
f       |	|
z  S c c}}w c c}}w )Nre   r   r   r   z        sypole: (%s) / (%s))r   r   r   r   r  r  r   rQ   )r  r  rX   re   r  r  r  ri   rj   rd   r   r  s              rY   _sypolez#_laplace_trig_ltex.<locals>._sypole  s    3C22gq"r'{#eeQVVadU#!$VBZs2w"1E!FGAa1fGI!$Rs2w")=!>?Aa1f?A,q!f5s
	 H?s   0C
3C#
c                 J    | d   | d   }}|}||z
  }t        d||f       ||z  S )Nre   r   z        simplepole: (%s) / (%s))rQ   )r  rX   re   r  rd   r   s         rY   _simplepolez'_laplace_trig_ltex.<locals>._simplepole  s9    3C2E01a&9s
r[   r   Nr   re   T)reverse)
r   popr  r   r   r   r    r   r   r)   )r  r   rX   resultsplanesr  r!  r#  r%  r'  r  	i_imagsym	i_realsym
i_pointsymireal_eqrealsymimag_eqimagsymindices_to_popr  s                       @rY   _laplace_trig_ltexr5    s    GF0			 b'A+VVX		

 s2w 
	Af1b	)GfAr
*Gf1b	)GfAr
*G7r"v{r"v{
WB1	WB1	
	( %)*?*NN"Y-,bmC.@Z.-q23 MM#bCk*+ (J?N-# q	"NN72r)}S'91=>MM"R&!FF9"NN72r)}S'91=>MM#bf+&FF9#NN72r*~c':A>?MM#bf+&FF:NN;r1-.MM"R&!q b'A+t =#v,&&r[   c           
         t        dd      }| j                  t        t        t        t
              syt        d| ||f       t        | j                  ||            \  }}t        d||f       t        ||      \  }}	t        d||	f       t        |	      dkD  rt        d	       y|j                  |      s&t        |||      \  }
}||
z  |t        j                  fS g }g }t        |||      \  }}}|D ]O  }|j!                  |d
   |j                  |||d   z
        z         |j!                  |t#        |d         z          Q t%        | j                  ||      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   re   )r   r]   r.   r-   r'   r%   rQ   r   r   r  r   rP   r5  r   r`   r   r   r   r   r)   )r   t_rX   doithintsr   r   r   r  r  rk   r   r+  r*  GG_planeG_condr  s                     rY   _laplace_rule_trigr?  (  sY    	cA66#sD$'
-B{;rwwr1~.DAq
#aV,!!Q'FB
%Bx0
2w{34558!"a+1sAqvv~ /1a87F 	/BNN2c7166!Qr#wY#778MM'"RW+-.	/ =a$c6lF::r[   c                    t        d|g      }t        d|g      }t        d      }| j                  |t        |||f      z        }|r||   j                  r||   j
                  D 	cg c]  }	|	j                  |       }
}	t        |
      dk(  rt        d       t        d| ||   f       t        d       g }t        ||         D ]^  }|d	k(  r||   j                  |d	      }n!t        ||   ||f      j                  |d	      }|j                  |||   |z
  dz
  z  |z         ` t        ||   ||d
      \  }}}||   |||   z  |z  t        | z
  z  ||fS yc c}	w )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)``.
    re   r   rd   r   rT   _laplace_apply_rules match:      f, n: %s, %sz#      rule: time derivative (4.1.8)r   Fr   N)r   r   r   r	   
is_integerr_   r]   sumrP   rQ   r  r   r   r   r   )r   r   rX   r:  r;  re   rd   r   r   r   r   r   r   rj   rk   r   r   s                    rY   _laplace_rule_diffrE  N  sr    	S1#AS1#ASA
''!Jq1a&))
*C
s1v  "1v{{+!QUU1X++q6Q;/0'!SV578A3q6] ,6AAq)A"3q6Aq62771=ASVAXaZ*+, +3q61a%HIAr2FAs1vIaK#q'12R<< ,s   ,E c           
         | j                   rdg}dg}t        j                  |       D ]6  }|j                  |      r|j	                  |       &|j	                  |       8 t        |      dkD  rYt        |      }t        ||      j                         }	t        |	      }
|
dkD  r#t        d       t        d| |f       t        d       t        |      }t        |||d      \  }}}|g}d}	 t        |d   |       }|j                  t              r<t!        |
dz
        D ]*  }|j	                  d|dz   z  t#        |||dz         z         , nE|rC|j	                  |       t!        |
dz
        D ]!  }|j	                  t        |d   |              # |r3t%        t!        |
      D cg c]  }|	|
|z
  dz
     ||   z   c} }|||fS y	# t        $ r d}Y w xY wc c}w )
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)``.
    rT   rA  rB  z(      rule: frequency derivative (4.1.6)Fr   r   r   N)is_Mulr   r   r   r   r   r   rJ   r  rP   rQ   r   r   
ValueErrorr]   LaplaceTransformr  r	   r   )r   r   rX   r:  r;  pfacofacfacpexpcNoexr_p_c_derid1r   rd   rk   s                       rY   _laplace_rule_sdiffrV  l  s    	xxss==# 	!C  #C C 		!
 t9q=t*Cc1((*BBA1u34+aY7@A4j/QEJ
BttBx++B 66*+"1Q3Z HR1Q3K
2q!A#0F$FGH B!&qs <A KKd2h):(:;<qBAb1QiQ/BCAr2;& " B Cs   /G )GGGc                    | j                   ryt        | d      }|j                   rt        |||d      S t        |       }|j                   rt        |||d      S t        |       }|j                   rt        |||d      S || k7  rt        |||d      S t        t	        |             }|j                   rt        |||d      S y)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   rX   r:  r;  rk   s         rY   _laplace_expandrZ    s     	xxquAxx!!QE::1Axx!!QE::q	Axx!!QE::Av!!QE::{1~Axx!!QE::r[   c                 |    t         t        t        t        t        t
        t        g}|D ]  } || ||      x}|c S  y)zk
    This function applies all program rules and returns the result if one
    of them gives a result.
    N)r   r   r   r   r?  rE  rV  )r   r   rX   
prog_rulesp_ruleLs         rY   _laplace_apply_prog_rulesr_    sN     *+>)+<$$&9;J
  1a A-H r[   c                     t               \  }}}d}d}|D ]  \  }}	}
}}||k7  r || j                  ||i            }|}|j                  |      }|s=	 |
j                  |      }|t
        j                  k(  sct        d       t        d| f       t        d||	f       t        d|f       |	j                  |      j                  ||i      |j                  |      t
        j                  fc S  y# t        $ r Y w xY w)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   xreplacera   r   r`   rP   rQ   )r   r   rX   simple_rulesr9  r   prep_oldprep_ft_doms_domcheckplaneprepmar   s                  rY   _laplace_apply_simple_rulesrl    s   
 01L"bHF,8 4(ueUDt!&&!R/*FH\\% NN2&
 AFF{:;(1$/1E5>B(2&1r*//Q8r*AFF4 4#4&    s   C11	C=<C=c                    t        d| |f       t        j                  |       }g }g }g }|D ]  }|j                  d      \  }	}
t	        |
|      x}nt        |
|      x}nt        |
|      x}nwt        fd|
j                  t              D              rt        |
|      t        j                  df}n1t        |
||      x}	 nt        |
|      t        j                  df}|\  }}}|j                  |	|z         |j                  |       |j                  |        t        | }|r|j                  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as_Addc              3   @   K   | ]  }|j                          y wrw   r]   )r   undefr9  s     rY   r   z%_laplace_transform.<locals>.<genexpr>  s     C52C   Tr   r:  )rQ   r   r   as_independentrl  r_  rZ  anyr~   r   rI  r   r   r   r   r   r)   rE   )r   r9  r   r   termsterms_sr+  
conditionsffr   ftrk   ri_pi_ci_resultri  	conditions    `                rY   r   r     s   
 #b"b\2MM"EGFJ !!"U!32,RR88AE,RR88aE"2r2..a;CBHH\,BCC ""b"-q/A/A4HA1BX/ /a7;<!"b"-q/A/A4HAc3quc#+. ']Fe,LEZ I5)##r[   c                   ,    e Zd ZdZdZd Zd Zd Zd Zy)rI  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                 H    |j                  dd      }t        ||||      }|S )Nr   Fr   )getr   )selfr   r   rX   r;  r>   LTs          rY   _compute_transformz#LaplaceTransform._compute_transform"  s'    IIj%0	+Aq!iH	r[   c                 x    t        |t        | |z        z  |t        j                  t        j                  f      S rw   )r=   r#   r   r   r   )r  r   r   rX   s       rY   _as_integralzLaplaceTransform._as_integral'  s,    #qbd)a%<==r[   c                     g }g }|D ]'  \  }}|j                  |       |j                  |       ) t        | }t        | }|t        j                  k(  rt        dd d      ||fS )Nr  zNo combined convergence.)r   rE   r)   r   r   r@   )r  extrar   r+  ri  r   s         rY   _collapse_extraz LaplaceTransform._collapse_extra*  su      	!KE4LLMM% 	! E{V177?(4!;= =d{r[   c                    |j                  dd      }|j                  dd      }t        d| j                  | j                  | j                  f       | j                  }| j                  }| j                  }t        ||||      }|r|d   S |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   )r  rQ   functionfunction_variabletransform_variabler   )r  r;  _nocondsr>   r9  r   r   rk   s           rY   r:  zLaplaceTransform.doit7  s     99Y-IIj%0	'$--*.*@*@*.*A*A*C 	D ##$$]]r2rI>Q4KHr[   N)	__name__
__module____qualname____doc___namer  r  r  r:  rx   r[   rY   rI  rI    s"     E
>r[   rI  c                    j                  dd      }j                  dd      }t        | t              rt        | d      rʉj                  dd       }|rA|r?d}t	        dd|       t        t              5  | j                  fd	      cd
d
d
       S | D 	cg c]  }	t        |	fi  }
}	|r:t        |
 \  }}} t        |       g | j                  | }|t        | t        | fS  t        |       g | j                  |
 S t        |       j                  d|      }|s|S |d   S # 1 sw Y   0xY wc c}	w )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)deprecated_since_versionactive_deprecations_targetc                      t        | fi S rw   )laplace_transform)fijr;  rX   r   s    rY   ry   z#laplace_transform.<locals>.<lambda>  s     1#q! Eu E r[   N)r  r   r   )r  r^   rF   hasattrrM   rO   rN   r  r  r  typeshaper)   rE   rI  r:  )r   r   rX   legacy_matrixr;  r  r>   r   adtr  elements_transelementsavalsry  	f_laplacer  s    `` `           rY   r  r  W  sn   ^ yyE*H		*e,I!Z WQ%<IIi//]7C%
 */+. !!89 G{{EGG G
 012(+ 0Q$"$ 2N 2.1>.B+%#DG7QWW7h7	 #u+sJ/???tAw8888	!Q	"	'	'		'	JB	!u%G G2s   :D5E5D>c                    ddl m}m ddlm} t        dd      fd}| j                  |      r| j                  |      } | j                  rKt        | j                  D cg c]  }t        ||||       c} }	t        |	j                  |      |      dfS 	  || |t               dt        j                   fdd	
      \  }	}
|	g || |      }	|	y|	j$                  r(|	j                  d   \  }	}
|	j'                  t(              ryt        j*                  }
|	j-                  t.        |      }	|	j$                  r|	j                  |      
fS t        d      t        j0                  ffd	}|	j-                  t2        |      }	d }|	j-                  t        |      }	t        |	j                  |      |      
fS c c}w # t"        $ r d}	Y 
w xY w)z6 The backend function for inverse Laplace transforms. r   )meijerint_inversion_get_coeff_exp)inverse_mellin_transformr   Tr7  c                  J   t        |       dk7  rt        |  S | d   j                  d   j                  } |      \  }}| d   j                  d   }| d   j                  d   }t	        dt        |      z  |z  z
        |z  t	        |z  dt        |      z  z
        |z  z   S )z3 Simplify a piecewise expression from hyperexpand. r   r   r   rT   )r   r,   r_   argumentr5   r    )r_   r   coeffexponente1e2r  r   s         rY   pw_simpz7_inverse_laplace_transform_integration.<locals>.pw_simp  s     t9>d##1gll1o&&(a0x!W\\!_!W\\!_aE
lQ[01"4akAc%jL01"45	6r[   NF)needevalr  uc                 L    | j                   t                     }|j                        rt        | |      S ddlm}  ||dkD        }|j                  k(  r$t        |j                        }t        |z   |      S t        |j                        }t        |z    |      S )Nr   r   )	r   r#   r]   r5   r   r   r   r$   gts)r   H0re   r   relr   r   r  s         rY   simp_heavisidez>_inverse_laplace_transform_integration.<locals>.simp_heaviside  s    CHHS!Wa 558S"%%@Aq)77a<CGGAQUB''CGGAq1uXr**r[   c                 *    t        t        |             S rw   )r   r#   )r   s    rY   simp_expz8_inverse_laplace_transform_integration.<locals>.simp_exp  s    c#h''r[   )sympy.integrals.meijerintr  r  sympy.integrals.transformsr  r   is_rational_functionapartr   r   r_   &_inverse_laplace_transform_integrationr>   r   r#   r   r   r@   r   r]   r=   r`   rs   r,   r   r5   )r   rX   r9  ri  r   r  r  r  Xr   r   r  r  r  r   r  s                @@@rY   r  r    s   MC 	cA6 	a GGAJxxvv 5Q1eXN   21477*1aaR4:L48%I4 	y1a(9>>ffQiGAtuuX66DIIi)~~ vva}d""c
A vv + 	
		)^,A( 	
		#x A
 QVVAr]H-t33g " s   &G+G GGc                     ddl m}  ||       \  }}|j                  |      rV|j                  |      j	                         }t        |      dk(  r)|\  }}}|||d|z  z  z   dz  ||z  z   |d|z  z  dz  z
  z  }||z  S )Nr   )fractionr   r   )rz   r  r   r  r  r   )	r   rX   r  rd   r   cfre   ro   r   s	            rY   _complete_the_square_in_denomr  "  s    /a[FQqYYq\$$&r7a<GAq!Aa1gI>!A#%q!A#wl23AQ3Jr[   c            
         t        d      } t        d      }t        d| g      }t        d| g      }t        d| g      }t        d       d }d	 }|| z  |t        j                  |d
f|| |z   | z  z  ||d
z
  z  t        | |z        z  t        |      z  |dkD  |d
fd
| dz  |dz  z   dz  z  t        ||z        ||z  t        ||z        z  z
  d|dz  z  z  t        j                  |d
fd
| |z  z  ||d
z
  z  t        |      z  t        j                  |d
fd
| | |z   |z  z  z  t        |||z        ||z  t        |      z  z  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`.
    rX   r   re   r   ro   r   z._inverse_laplace_build_rules is building rulesc                 H    	 | j                  |      S # t        $ r | cY S w xY wrw   )factorrH   )r   rX   s     rY   _fracz+_inverse_laplace_build_rules.<locals>._frac<  s)    	88A; 	H	s    !!c                     | S rw   rx   )r   s    rY   samez*_inverse_laplace_build_rules.<locals>.sameB  s    r[   rT   r   r   r   )
r   r   rP   r   r`   r#   r:   r.   r-   r;   )rX   r   re   ro   r   r  r  
_ILT_ruless           rY   _inverse_laplace_build_rulesr  -  s    	c
Ac
AS1#AS1#AS1#A	
:;  
1aq!	
AaCA2;AaCaRT*583QUD!D	
AqDAI>	C!Hqs3qs8|3a1f=	
q	 
AqD1q1u:eAh&a8	
AqsQhJAqs+QT%(];	
q	J q!r[   c                    | dk(  r?t        d       t        dd       t        d|f       t        |      t        j                  fS t               \  }}}d}| j                  ||i      }|D ]  \  }}	}
}}|||fk7  r |||z        }||f}j                  |      }|s3	 |
j                  |      }|t        j                  k(  sYt        d       t        d| f       t        d||	f       t        d|f       t        |      |	j                  |      j                  ||i      z  t        j                  fc S  y	# t        $ r Y w xY w)
@
    Helper function for the class InverseLaplaceTransform.
    rT   z*_inverse_laplace_apply_simple_rules match:      f:    %s)rT   z"      rule: 1 o---o DiracDelta(%s)ra  z      rule: %s o---o %s      ma:   %sN)rP   rQ   r4   r   r`   r  r   r   rb  ra   r5   )r   rX   r   r  r   r9  _prepfsubsrg  rf  rh  rj  rL  _Frk  r   s                   rY   #_inverse_laplace_apply_simple_rulesr  T  sM    	Av:;&3aT:!}aff$$57JBEFFAr7OE*4 M&ueT3T3KeCiB3KEXXe_NN2& AFF{BC'!.05%.A'"/ |ENN2$6$;$;RG$DDaffLLM"   s   D88	EEc                 &   t        d|g      }t        d      }| j                  |      s| t        |      z  t        j                  fS | j                  t        ||z              }|r||   j                  rQt        d       t        d| f       t        d       t        d|f       t        |||   z         t        j                  fS t        d       t        | |||      t        j                  fS | j                  t        ||z        |z        }|r||   j                  rGt        d       t        d| f       t        d	       t        d|f       t        ||   ||||   z   |      S t        d       t        | |||      t        j                  fS y
)r  re   r   r   z"_inverse_laplace_time_shift match:r  z+      rule: exp(-a*s) o---o DiracDelta(t-a)r  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   r]   r4   r   r`   r   r#   r   rP   rQ   InverseLaplaceTransform_inverse_laplace_transform)r   rX   r   ri  re   r   r   s          rY   _inverse_laplace_time_shiftr  v  sg    	S1#AS	A558A&&
''#ac(
C
q667#aT*?@#cV,aAh'//JK*1aE:AFFBB
''#ac(1*
C
q667#aT*JK#cV,-c!fa3q65IIJK*1aE:AFFBBr[   c                    t        d|g      }t        d      }| j                  ||z  |z        }|r||   j                  r||   j                  rt	        d       t        d| f       t	        d       t        d|f       t        ||   |||      \  }}|j                  t        |      d      }|j                  t              rt        ||||         |fS t        |      t        ||||         z  |fS y	)
r  rd   r   r   z!_inverse_laplace_time_diff match:r  z,      rule: s**n*F(s) o---o diff(f(t), t, n)r  rT   N)r   r   rC  rh   rP   rQ   r  rs   r5   r]   r  r   )	r   rX   r   ri  rd   r   r   rk   r   s	            rY   _inverse_laplace_time_diffr    s     	S1#AS	A
''!Q$q&/C
s1v  SV%7%712!&<=#()#a&!Q>1IIilA&55()1c!f%q((Q<Q3q6 22A55r[   c                 L    t         t        g}|D ]  } || |||      x}|c S  y)r  N)r  r  )r   rX   r   ri  r\  r]  rk   s          rY   !_inverse_laplace_apply_prog_rulesr    sB     .,.J  1a''A4H r[   c                    | j                   ryt        | d      }|j                   rt        ||||      S t        |       }|j                   rt        ||||      S t        |       }|j                   rt        ||||      S | j	                  |      r| j                  |      j                         }|j                   rt        ||||      S y)r  NFrX  )r   r
   r  r   r  r  r:  )r   rX   r   ri  rk   s        rY   _inverse_laplace_expandr    s     
yyrAxx)!Q5992Axx)!Q599r
Axx)!Q599	q!HHQKxx)!Q599r[   c           	         t        d| ||f       t        d      }| j                  |      }t        j                  |      }g }t
        j                  g}	|D ]  }
|
j                         \  }}|j                  |      j                         }|d   }|D cg c]  }||z  	 }}|j                  |      j                         D cg c]  }||z  	 }}t        |      dk(  r#|d   t        |      z  }|j                  |       t        |      dk(  r6|d   t        |d    |z        z  }|j                  t        |      |z         t        |      dk(  r|d   dz  }|d   |dz  z
  j                         }t        |      dk(  rt
        j                   g|z   }t#        |      \  }}|dk(  r"||z  |d||z  z
  z  z   t        | |z        z  }nd}|j$                  r| }d}t'        t)        |dz  |z
  |      j+                               d   }t-        |      j/                         }|rM|t        | |z        z  t1        ||z        z  |||z  z
  |z  t        | |z        z  t3        ||z        z  z   }nL|t        | |z        z  t5        ||z        z  |||z  z
  |z  t        | |z        z  t7        ||z        z  z   }|j                  t        |      |z         t9        | |||dd	      \  }}|j                  |       |	j                  |        t        | }|r|j/                  d
      }t        d|f       |t;        |	 fS c c}w c c}w )r  z[ILT _i_l_r] (%s, %s, %s)x_r   rT   r   r   FT)r   
dorationalrt  z[ILT _i_l_r]   returns %s)rQ   r   r  r   r   r   r`   as_numer_denomr  r  r   r4   r   r#   r5   r  r   tupler   r   rI   r   r+   r   r%   r'   r-   r.   r  rE   )r   rX   r   ri  r   r  r   rw  terms_try  r   rd   r   r  dc_leadri   r  rk   re   ro   lr   hypb2bsr{  r   r  s                               rY   _inverse_laplace_rationalr    sC    &Q
3	B
AMM!EG&&J &$$$&AYYq\$$&Q%!#$Aai$$!"1!8!8!:;Aai;;r7a<1jm#ANN1W\1c2a5&(m#ANN9Q<>*W\1aAAq!t##%A2w!|ffX]9DAqAvqSAacE]C1I-==AC%Aa,1134Q7!W%%'#qbd)DAJ.!AaC%2r!t92%%)"Q$Z20 0  #qbd)C1I-1Q3
3r!t90DSAY0NNANN9Q<>*1Aq%$5BHBNN2d#M&$P ']Fe,
&	23
###Q %;s   MMc                    t        j                  |       }g }g }t        d| |f       |D ]  }	|	j                  d      \  }
}|r$|	j	                        rt        ||||      x}	 nt        ||      x}nt        |||      x}nt        |||      x}	 nxt        fd|j                  t              D              rt        |||      t        j                  f}n2t        ||||      x}	 nt        |||      t        j                  f}|\  }}|j!                  |
|z         |j!                  |        t        | }|r|j#                  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)Frn  c              3   @   K   | ]  }|j                          y wrw   rq  )r   rr  r   s     rY   r   z-_inverse_laplace_transform.<locals>.<genexpr>'  s     B52Brs  r   rt  )r   r   rQ   ru  r  r  r  r  r  rv  r~   r   r  r   r`   r  r   r   rE   )r   r   r9  ri  r   r  rw  r  ry  r   r   r   rk   r|  r~  r  r  s    `               rY   r  r    s    MM"EGJ
&R5 ""2e"41t88<22r5(4 4A<@A 6q"bAAaN*1b"e<<aI72r5IIBAGGL,ABB )BE:AFFCA;r2ux9 9AEF (BE:AFFCA
cqu#;> ']Fe,Z I9r[   c                   \    e Zd ZdZdZ ed      Z ed      Zd Ze	d        Z
d Zd Zd	 Zy
)r  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                 Z    |t         j                  }t        j                  | ||||fi |S rw   )r  _none_sentinelr?   __new__)r   r   rX   ri   ri  optss         rY   r  zInverseLaplaceTransform.__new__L  s0    =+::E ((aAuEEEr[   c                 L    | j                   d   }|t        j                  u rd }|S )Nr   )r_   r  r  )r  ri  s     rY   fundamental_planez)InverseLaplaceTransform.fundamental_planeQ  s(    		!+:::Er[   c                 4    t        |||| j                  fi |S rw   )r  r  )r  r   rX   r   r;  s        rY   r  z*InverseLaplaceTransform._compute_transformX  s&    5q!T++6/46 	6r[   c                 <   | j                   j                  }t        t        ||z        |z  ||t        j
                  t        j                  z  z
  |t        j
                  t        j                  z  z   f      dt        j                  z  t        j
                  z  z  S )Nr   )	__class___cr=   r#   r   ImaginaryUnitr   Pi)r  r   rX   r   r   s        rY   r  z$InverseLaplaceTransform._as_integral\  sw    NNS1XaZ!Q)C%C"#aooajj&@"@"B CqttVAOO#%	&r[   c                 6   |j                  dd      }|j                  dd      }t        d| j                  | j                  | j                  f       | j                  }| j                  }| j                  }| j
                  }t        |||||      }|r|d   S |S )r  r  Tr   Fz[ILT doit] (%s, %s, %s)r   r   )r  rQ   r  r  r  r  r  )	r  r;  r  r>   r   r9  r   ri  rk   s	            rY   r:  zInverseLaplaceTransform.doitc  s     99Y-IIj%0	(4==+/+A+A+/+B+B+D 	E ##$$]]&&&r2r59MQ4KHr[   N)r  r  r  r  r  r   r  r  r  propertyr  r  r  r:  rx   r[   rY   r  r  >  sI     E6]N	sBF
  6&r[   r  Nc                     t        | t              r#t        | d      r| j                  fd      S  t	        |       j
                  di S )a  
    Compute the inverse Laplace transform of `F(s)`, defined as

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

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

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

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

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

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

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

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

    Examples
    ========

    >>> from sympy 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
    r  c                 "    t        | fi S rw   )inverse_laplace_transform)Fijr;  ri  rX   r   s    rY   ry   z+inverse_laplace_transform.<locals>.<lambda>  s    1#q!ULeL r[   rx   )r^   rF   r  r  r  r:  )r   rX   r   ri  r;  s    ````rY   r  r    sQ    Z !Z WQ%<{{LN 	N7"1aE277@%@@r[   c                    	
 t        dt        g      \  	
fdfdfd	
fdfd |       S )zEFast inverse Laplace transform of rational function including RootSumza, b, nr   c                     | j                        s| S | j                  r |       S | j                  r |       S | j                  r |       S t	        | t
              r |       S t        rw   )r]   r   rG  rU   r^   rL   NotImplementedError)e_ilt_add_ilt_mul_ilt_pow_ilt_rootsumrX   s    rY   _iltz#_fast_inverse_laplace.<locals>._ilt  s`    uuQxHXXA;XXA;XXA;7#?"%%r[   c                 J     | j                   t        | j                         S rw   )r   mapr_   )r  r  s    rY   r  z'_fast_inverse_laplace.<locals>._ilt_add  s    qvvs4())r[   c                 f    | j                        \  }}|j                  rt        | |      z  S rw   )ru  rG  r  )r  r  r{   r  rX   s      rY   r  z'_fast_inverse_laplace.<locals>._ilt_mul  s3    &&q)t;;%%tDz!!r[   c                    | j                  z  z   z        }|j|   |   |   }}}|j                  r5|dk  r0	| dz
  z  t        ||z   	z        z  || z  t        |       z  z  S |dk(  rt        ||z   	z        |z  S t        r   )r   
is_Integerr#   r:   r  )
r  r   nmambmre   ro   rd   rX   r   s
        rY   r	  z'_fast_inverse_laplace.<locals>._ilt_pow  s    1q1%q58U1XBB}}aB3q5z#2hqj/12s75":3EFFQwRU8A:++!!r[   c                     | j                   j                  }| j                   j                  \  }t        | j                  t        |t         |                        S rw   )funr{   	variablesrL   polyr   rK   )r  r{   variabler  s      rY   r
  z+_fast_inverse_laplace.<locals>._ilt_rootsum  s@    uuzzUU__
qvvvhd0DEFFr[   )r   r   )r  rX   r   r  r  r  r	  r
  re   ro   rd   s    ``@@@@@@@@rY   _fast_inverse_laplacer    sI    iTA37GAq!& &*"" "G
 7Nr[   )T)TTrw   )r  
sympy.corer   r   r   sympy.core.addr   sympy.core.cacher   sympy.core.functionr   r	   r
   r   r   r   r   r   r   sympy.core.mulr   r   sympy.core.relationalr   r   r   r   r   r   sympy.core.sortingr   sympy.core.symbolr   r   r   $sympy.functions.elementary.complexesr   r   r   r    r!   r"   &sympy.functions.elementary.exponentialr#   r$   %sympy.functions.elementary.hyperbolicr%   r&   r'   r(   (sympy.functions.elementary.miscellaneousr)   r*   r+   $sympy.functions.elementary.piecewiser,   (sympy.functions.elementary.trigonometricr-   r.   r/   sympy.functions.special.besselr0   r1   r2   r3   'sympy.functions.special.delta_functionsr4   r5   'sympy.functions.special.error_functionsr6   r7   r8   'sympy.functions.special.gamma_functionsr9   r:   r;   sympy.integralsr<   r=   r  r>   r?   r@   sympy.logic.boolalgrA   rB   rC   rD   rE   sympy.matrices.matricesrF   sympy.polys.matrices.linsolverG   sympy.polys.polyerrorsrH   sympy.polys.polyrootsrI   sympy.polys.polytoolsrJ   sympy.polys.rationaltoolsrK   sympy.polys.rootoftoolsrL   sympy.utilities.exceptionsrM   rN   rO   sympy.utilities.miscrP   rQ   r|   r   r   r   r   r   r   r   r   r   r  r5  r?  rE  rV  rZ  r_  rl  r   rI  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rx   r[   rY   <module>r7     s       $      % H H & 2 25 5 ; I I C C : C C M M I A A N N /: : E E . 6 2 ' & . +I I .Wt6sLl& 	Q) 	Q)h.!H0#L$"JN'b#;L<+\<"<($VB( BJupP4f 	# 	#LD F,
,6$t 6:0fC/ CL0Af*r[   