
    \hS                       S r SSKrSSKrSSKJrJrJr  SSKJr  SSK	J
r
  SSKJr  SSKJrJrJrJrJrJrJrJrJrJr  SSKJrJr  SS	KJrJrJrJrJ r J!r!J"r"J#r#  SS
K$J%r%  SSK&J'r'J(r(J)r)  SSK*J+r+J,r,J-r-J.r.J/r/J0r0  SSK1J2r2J3r3  SSK4J5r5J6r6J7r7J8r8  SSK9J:r:J;r;J<r<  SSK=J>r>J?r?  SSK@JArAJBrBJCrCJDrD  SSKEJFrFJGrGJHrHJIrI  SSKJJKrKJLrL  SSKMJNrNJOrOJPrP  SSKQJRrRJSrSJTrTJUrU  SSKVJWrW  SSKXJYrYJZrZ  SSK[J\r\J]r]J^r^  SSK_J`r`JaraJbrbJcrcJdrd  SSKeJfrf  SSKgJhrh  SSKiJjrj  SSKkJlrl  SSKmJnrn  SSKoJprp  SS KqJrrr  SS!KsJtrtJuruJvrv  SS"KwJxrx  SqyS# rzS$ r{S% r|\zS& 5       r}\zS' 5       r~\zS( 5       r\
S) 5       r\zS* 5       r\zS+ 5       r\zS, 5       r\zS- 5       r\zS. 5       r\zS/ 5       r\zS0 5       r\zS1 5       r\zS2 5       r\zS3 5       r\zS4 5       r\zS5 5       r\zS6 5       r\zS7 5       rS8 rS9 r\zS: 5       r " S; S<\]5      rSPS= jr\zS> 5       r\zS? 5       r\
S@ 5       r\zSA 5       r\zSB 5       r\zSC 5       r\zSD 5       r\zSE 5       r\zSF 5       r\zSG 5       r\zSH 5       r\zSI 5       r\zSJ 5       r\zSK 5       r " SL SM\]5      rSQSN jrSO rg)RzLaplace Transforms    N)SpiI)Add)cacheit)Expr)
AppliedUndef
Derivativeexpandexpand_complex
expand_mulexpand_trigLambdaWildFunctiondiffSubs)Mulprod)
_canonicalGeGtLt
UnequalityEqNe
Relational)ordered)DummysymbolsWild)reimargAbs
polar_liftperiodic_argument)explog)coshcothsinhasinh)MaxMinsqrt)	Piecewisepiecewise_exclusive)cossinatansinc)besselibesseljbesselkbessely)
DiracDelta	Heaviside)erferfcEi)digammagamma
lowergamma
uppergamma)SingularityFunction)	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)debugfc                    ^  U 4S jnU$ )Nc                  d  > SSK Jn  U(       d  T" U 0 UD6$ [        S:X  a  [        S[        R
                  S9  [        SS[        -  < TR                  < U < 3[        R
                  S9  [        S-  qTR                  S:X  d  TR                  S	:X  aA  S
[         l        [        SS[        -  -  [        R
                  S9  T" U 0 UD6nS[         l        OT" U 0 UD6n[        S-  q[        SS[        -  < SU< 3[        R
                  S9  [        S:X  a  [        S[        R
                  S9  U$ )Nr   SYMPY_DEBUGzO
------------------------------------------------------------------------------file-LT-      _laplace_transform_integration&_inverse_laplace_transform_integrationFz**** %sIntegrating ...Tz---> zO------------------------------------------------------------------------------
)sympyr\   	_LT_levelprintsysstderr__name__)argskwargsr\   resultfuncs       O/var/www/auris/envauris/lib/python3.13/site-packages/sympy/integrals/laplace.pywrapDEBUG_WRAP.<locals>.wrap1   s    % (((>-cjj1tI~t}}dC::	Q	!AA!II %E*d9n=CJJO4*6*F $E4*6*FQ	$y.&9

K>-cjj1     )rm   ro   s   ` rn   
DEBUG_WRAPrs   0   s    4 Krq   c                 l    SSK Jn  U(       a'  [        SS[        -  < U < 3[        R
                  S9  g g )Nr   r[   r_   r`   r]   )rd   r\   rf   re   rg   rh   )textr\   s     rn   _debugrv   N   s$    !T)^T2D rq   c                    ^^^^^ U4S jmUUUU4S jmU4S jmU4S jnS nSSK Jn  U" U 5      n U" U [        T5      n U" U [        U4S j5      n U" U [        U5      n [        U 5      $ )	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                 n   > U T:X  a  gU R                   (       a  U R                  T:X  a  U R                  $ g )Nra   )is_Powbaser'   )exss    rn   power_simplifyconds.<locals>.powerv   s*    799A66Mrq   c                 B  > U R                  T5      (       a  UR                  T5      (       a  g[        U [        5      (       a  U R                  S   n [        U[        5      (       a  UR                  S   nU R                  T5      (       a  T" SU-  SU -  5      $ T" U5      nUc  g US:  a-  [        U 5      [        T5      U-  :*  [        R
                  :X  a  gUS:  a.  [        U 5      [        T5      U-  :  [        R
                  :X  a  ggg! [         a     gf = f)zRReturn True only if |ex1| > |ex2|, False only if |ex1| < |ex2|.
Else return None. Nr   ra   FT)has
isinstancer$   rj   r   true	TypeError)ex1ex2nabiggerr}   r|   s      rn   r   _simplifyconds.<locals>.bigger}   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   )2D 2D 
DDc                    > U R                   (       d  [        U [        5      (       a&  UR                   (       d  [        U[        5      (       d  X:  $ T" X5      nUb  U(       + $ X:  $ )zsimplify x < y )is_positiver   r$   )xyrr   s      rn   replie_simplifyconds.<locals>.replie   sL    *Q"4"4As););EN1L=5Lrq   c                 8   > T" X5      nUS;   a  g[        X5      $ )NTFT)r   )r   r   br   s      rn   replue_simplifyconds.<locals>.replue   s"    1L!rq   c                 B    U S;   a  [        U 5      $ U R                  " U6 $ )Nr   )boolreplace)r{   rj   s     rn   repl_simplifyconds.<locals>.repl   s"    8Ozz4  rq   r   )collect_absc                    > T" X5      $ Nrr   )r   r   r   s     rn   <lambda> _simplifyconds.<locals>.<lambda>   s	    va|rq   )sympy.simplify.radsimpr   r   r   r   r   )	exprr|   r   r   r   r   r   r}   r   s	    ``   @@@rn   _simplifycondsr   U   se    B , !
 3tDb&!Db34Dj&)DT7Nrq   c                 >    [        X R                  [        5      5      $ )zg
Expand an expression involving DiractDelta to get it as a linear
combination of DiracDelta functions.
)rO   atomsr:   r   s    rn   expand_dirac_deltar      s     jj455rq   c                n  ^^^^ [        S5      mU R                  [        5      (       a  g[        U [	        T* T-  5      -  T[
        R                  [
        R                  45      nUR                  [        5      (       d;  [        UR                  TT5      U5      [
        R                  [
        R                  4$ UR                  (       d  gUR                  S   u  pEUR                  [        5      (       a  gUU4S jn[        U5       Vs/ s H
  ov" U5      PM     nnU V	s/ s H5  oS   [
        R                   :w  d  M  U	S   [
        R                  Ld  M3  U	PM7     n
n	U
(       d*  U V	s/ s H  oS   [
        R                   :w  d  M  U	PM     n
n	[#        [%        U
5      5      nS mUR'                  U4S jS9  U(       d  gUS   u  pUU4S	 jnU(       a  [)        UTU5      n[)        UTU5      n[        UR                  TT5      U5      U" U5      [+        U" U5      5      4$ s  snf s  sn	f s  sn	f )
zThe 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.
r|   Nr   c                 ,	  >^ SSK Jn  [        R                  n[        R                  n[        [        U 5      5      n [        S[        T/S9u  pEpgpn
U[        [        TU-   U-  5      5      -  U:  U[        [        TU-   U-  5      5      -  U:*  [        [        TU-   U-  U-  U5      5      U:  [        [        TU-   U-  U-  U5      5      U:*  [        [        [        TU-   5      U-  U-  U5      5      U:  [        [        [        TU-   5      U-  U-  U5      5      U:*  4nU  GHJ  n[        R                  n/ n[        U5       GH  nUR                  (       a&  TUR                   R"                  ;   a  UR$                  nUR                  (       a'  ['        U[(        [*        45      (       a  UR,                  nU H  nUR/                  U5      mT(       d  M    O   T(       a?  TU   R0                  (       a+  TU   TU   -  [2        S-  :X  a  [5        TTU   -   5      * S:  nUR/                  U[7        U[        [        TU
-  5      5      -  U-  5      [        TU-  5      U	-  -  -
  S:  5      mT(       dN  UR/                  [7        U[        [        TU-  U
-  U5      5      U-  -
  5      [        TU-  5      U	-  -  S:  5      mT(       dW  UR/                  U[7        [        [        [        T5      U-  U
-  U5      5      U-  5      [        TU-  5      U	-  -  -
  S:  5      mT(       a.  [9        U4S jXgXU
4 5       5      (       a  [5        T5      TU   :  nUR;                  [4        S 5      R=                  [5        T5      T5      nUR                  (       a<  UR>                  S;   d,  URA                  T5      (       d  URA                  T5      (       d  X/-  nGM  U" UT5      nUR                  (       a  UR>                  S;   a  X/-  nGM  URB                  T:X  a      g	[E        URB                  U5      nGM     U[        R                  La  [G        X5      nGM8  [I        U[K        U6 5      nGMM     X#R                  (       a  URL                  4$ U4$ )
z6Turn ``conds`` into a strip and auxiliary conditions. r   _solve_inequalityzp q w1 w2 w3 w4 w5clsexclude   c              3   B   >#    U  H  nTU   R                   v   M     g 7fr   )r   ).0wildms     rn   	<genexpr>H_laplace_transform_integration.<locals>.process_conds.<locals>.<genexpr>   s#      - >,TQtW00 >,s   c                 D    U R                  5       R                  5       S   $ Nr   )r   as_real_imag)r   s    rn   r   G_laplace_transform_integration.<locals>.process_conds.<locals>.<lambda>   s    !((*"9"9";A">rq   )z==z!=N)'sympy.solvers.inequalitiesr   r   NegativeInfinityr   rJ   rI   r   r    r$   r#   r&   r%   InfinityrK   is_Relationalrhsfree_symbolsreversedr   r   r   reversedsignmatchr   r   r!   r2   allr   subsrel_opr   ltsr.   r-   rM   rL   	canonical)condsr   r   auxpqw1w2w3w4w5patternsca_aux_dpatd_solnr   r|   ts                      @rn   process_conds5_laplace_transform_integration.<locals>.process_conds   s	   @ff&-(#* dQC$9 bbb 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q $ 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  ->, - - -1!AYY>@@DRUA  OOqxx</G66!99BFF1IICKD(Q/))T[[L-HCKD88q=TXXr*BM "N #J#r4y)[ \ #4#4#--==#==rq   ra   c                 0    U S;   a  gU R                  5       $ )Nr   r   )	count_opsr   s    rn   cnt+_laplace_transform_integration.<locals>.cnt  s    = ~~rq   c                 &   > U S   * T" U S   5      4$ Nr   ra   rr   )r   r   s    rn   r   0_laplace_transform_integration.<locals>.<lambda>  s    qteS1Y/rq   keyc                 (   > U R                  TT5      $ r   )r   )r   r|   s_s    rn   sbs+_laplace_transform_integration.<locals>.sbs!  s    yyBrq   )r   r   r:   rD   r'   r   Zeror   rE   rF   r   r   r   is_Piecewiserj   rK   falselistr   sortr   r   )fr   r   simplifyFcondr   r   r   r   conds2r   r   r   r   r|   s    ``           @@rn   rb   rb      s    	c
AuuZ!C1I+1661::67A55??2113E3EqvvMM>>ffQiGAuuX=>~ (17!]1E7 :AA$gg#aA$a&8&88 F :"6Udaggo!U6!E  
JJ/J01XFA 1a#S!Q'QVVAr]H-s1vz#c(7KKK- 8: 7s$   H($H-H-H--H2H2c                     [        U [        5      (       d  U $ U R                  U5      =nb  UR                  5       $ U R                  nU R
                   Vs/ s H  n[        XA5      PM     nnU" U6 $ s  snf )z
This is an internal helper function that traverses through the expression
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   r   as_polyas_exprrm   rj   _laplace_deep_collect)r   r   r   rm   r#   rj   s         rn   r   r   )  sk     aYYq\&yy{66D56VV<Vc!#)VD<; =s   A2c                  /  ^ [        S5      m[        S5      n [        ST/S9n[        ST/S9n[        ST/S9n[        ST/S9n[        ST/S9nU4S	 jn[        S
5        / XU -  [        R                  [        R
                  U4P[        UT-  U-
  5      [        U * U-  U-  5      [        U5      -  [        [        US:  US:  5      [        US:  US:*  5      5      [        R                  U4P[        UT-  U-
  5      [        S5      [        [        US:  US:  5      [        US:  US:*  5      5      [        R                  U4P[        UT-  U-
  5      [        U * U-  U-  5      U -  [        US:  US:  5      [        R
                  U4P[        UT-  U-
  5      S[        U * U-  U-  5      -
  U -  [        US:  US:  5      [        R
                  U4P[        UT-  U-
  5      SU -  [        US:  US:*  5      [        R
                  U4P[        UT-  U-
  5      S[        US:  US:  5      [        R
                  U4PTSU S-  -  [        R                  [        R
                  U4PSUT-  U-   -  [        U* U-  U -  5      * [        U* U-  U -  5      -  U-  [        [        X!-  5      5      [        :  [        R
                  U4PS[!        UT-  U-   5      -  [!        U[        -  U -  5      [        X!-  U -  5      -  [#        [!        X!-  U -  5      5      -  U-  [        [        X!-  5      5      [        :  [        R
                  U4PUT-  U-   [        S5      * S-  -  SU[        S5      * S-  -  -  S[        U -  U-  [        S5      S-  -  -  [        X!-  U -  5      -  [#        [!        X!-  U -  5      5      -  U-  -
  [        [        X!-  5      5      [        :  [        R
                  U4P[!        T5      TU-   -  [!        [        U -  5      [        [!        U5      -  [        X -  5      -  [#        [!        X -  5      5      -  -
  [        [        U5      5      [        :  [        R
                  U4PSU[!        T5      -  TS-  -   -  [        U[        S5      S-  -  -  [        X-  5      -  [#        [!        X-  5      5      -  [        R                  [        R
                  U4PTU-  [%        US-   5      XS-   -  -  US:  [        R
                  U4PUT-  U-   U-  ['        US-   X!-  U -  5      [        U* U-  U -  5      -  XS-   -  -  U-  [        US:  [        [        X!-  5      5      [        :  5      [        R
                  U4PTU-  TU-   -  X-  [%        US-   5      -  ['        U* X-  5      -  [        US:  [        [        U5      5      [        :  5      [        R
                  U4P[        UT-  U-
  5      [        U* 5      X-
  -  [        R                  [)        U5      U4PT[        UT-  U-
  5      -  [        U* 5      X-
  S-  -  [        R                  [)        U5      U4PTU-  [        UT-  5      -  [%        US-   5      X-
  US-   -  -  [)        U5      S:  [)        U5      U4P[        U* TS-  -  5      [!        [        S-  U-  5      [        U S-  S-  U-  5      -  [#        U [!        SU-  5      -  5      -  [)        U5      S:  [        R
                  U4PT[        U* TS-  -  5      -  SSU-  -  S[!        [        5      -  SU-  [        S5      S-  -  -  U -  [#        U [!        SU-  5      -  5      -  -
  [)        U5      S:  [        R
                  U4P[        U* T-  5      S[!        X-  5      -  [+        SS[!        X-  5      -  5      -  [)        U5      S:  [        R
                  U4P[!        T5      [        U* T-  5      -  [        S5      S-  [!        [        U S-  -  5      -  SS[!        X-  5      -  -   -  [        S[!        X-  5      -  5      -  [)        U5      S:  [        R
                  U4P[        U* T-  5      [!        T5      -  [!        [        U -  5      [        S[!        X-  5      -  5      -  [)        U5      S:  [        R
                  U4P[        U* T-  5      T[!        T5      -  -  [!        [        U-  5      [        S[!        X-  5      -  5      -  [)        U5      S:  [        R
                  U4PTU-  [        U* T-  5      -  SX-  US-   S-  -  -  [+        US-   S[!        X-  5      -  5      -  [)        U5      S:  [        R
                  U4P[        U* [        T* 5      -  5      X* -  [-        X5      -  [        R                  [        R
                  U4P[        U* [        T5      -  5      X-  ['        U * U5      -  [)        U5      S:  [        R
                  U4P[/        UT-  5      [/        [        [        R0                  5      U -  U-  5      * U -  US:  [        R
                  U4P[/        SUT-  -   5      [        X-  5      * U -  [        U * U-  5      -  [        [        U5      5      [        :  [        R
                  U4P[/        UT-  U-   5      [/        U5      [        X-  U-  5      U -  U-  [        U * U-  5      -  -
  U -  U-  [        US:  [        [        U5      5      [        :  5      [        R
                  U4P[/        T5      [!        T5      -  [!        [        U -  5      * [/        SU -  [        [        R0                  5      -  5      -  [        R                  [        R
                  U4PTU-  [/        T5      -  [%        US-   5      X* S-
  -  -  [3        US-   5      [/        U 5      -
  -  [)        U5      S:  [        R
                  U4P[/        UT-  5      S-  [/        [        [        R0                  5      U -  U-  5      S-  [        S-  S-  -   U -  US:  [        R
                  U4P[5        UT-  5      XPS-  US-  -   -  [        R                  [        [7        U5      5      U4P[        [5        UT-  5      5      XPS-  US-  -   -  [9        [        U -  S-  U-  5      -  US:  [        R
                  U4P[5        UT-  5      T-  [;        XP-  5      [        R                  [        [7        U5      5      U4P[5        UT-  5      S-  T-  [/        SSUS-  -  U S-  -  -   5      S-  [        R                  S[        [7        U5      5      -  U4P[5        UT-  5      S-  TS-  -  U[;        SU-  U -  5      -  U [/        SSUS-  -  U S-  -  -   5      -  S-  -
  [        R                  S[        [7        U5      5      -  U4P[=        UT-  5      X S-  US-  -   -  [        R                  [        [7        U5      5      U4P[=        UT-  5      S-  U S-  SUS-  -  -   U S-  SUS-  -  -   -  U -  [        R                  S[        [7        U5      5      -  U4P[5        UT-  5      [5        UT-  5      -  SU-  U-  U -  U S-  X-   S-  -   -  U S-  X-
  S-  -   -  [        R                  [        [7        U5      5      [        [7        U5      5      -   U4P[=        UT-  5      [5        UT-  5      -  X S-  US-  -
  US-  -   -  U S-  X-   S-  -   -  U S-  X-
  S-  -   -  [        R                  [        [7        U5      5      [        [7        U5      5      -   U4P[=        UT-  5      [=        UT-  5      -  X S-  US-  -   US-  -   -  U S-  X-   S-  -   -  U S-  X-
  S-  -   -  [        R                  [        [7        U5      5      [        [7        U5      5      -   U4P[?        UT-  5      XS-  US-  -
  -  [        R                  [        [)        U5      5      U4P[A        UT-  5      X S-  US-  -
  -  [        R                  [        [)        U5      5      U4P[?        UT-  5      S-  SUS-  -  U S-  SUS-  -  U -  -
  -  [        R                  S[        [)        U5      5      -  U4P[A        UT-  5      S-  U S-  SUS-  -  -
  U S-  SUS-  -  U -  -
  -  [        R                  S[        [)        U5      5      -  U4P[?        UT-  5      T-  [/        X-   X-
  -  5      S-  [        R                  [        [)        U5      5      U4PTU-  [?        UT-  5      -  [%        US-   5      S-  X-
  U* S-
  -  X-   U* S-
  -  -
  -  US:  [        U5      U4PTU-  [A        UT-  5      -  [%        US-   5      S-  X-
  U* S-
  -  X-   U* S-
  -  -   -  US:  [        U5      U4P[C        UT-  5      [        U S-  SU-  S-  -  5      [#        U SU-  -  5      -  U -  S[        [        U5      5      -  [        :  [        R
                  U4P[E        X1T-  5      X-  [!        U S-  US-  -   5      U [!        U S-  US-  -   5      -   U-  -  -  [)        U5      S:  [        [7        U5      5      U4PTU-  [E        X1T-  5      -  SU-  [!        [        5      -  [%        U[        RF                  -   5      -  X-  -  U S-  US-  -   U* [        RF                  -
  -  -  [        [)        U5      [        RF                  * :  [I        X#5      5      [        [7        U5      5      U4PTU-  [E        X1T-  5      -  SUS-   -  [!        [        5      -  [%        U[        S5      S-  -   5      -  X-  -  U -  U S-  US-  -   U* [        S5      S-  -
  -  -  [        [)        U5      S:  [I        X#S-   5      5      [        [7        U5      5      U4P[E        SU[!        TS-  UT-  -   5      -  5      [        X -  U[!        U S-  US-  -   5      -  -
  5      [!        U S-  US-  -   5      -  [        [        U5      5      [        :  [        [7        U5      5      U4P[K        X1T-  5      X-  [!        U S-  US-  -
  5      U [!        U S-  US-  -
  5      -   U-  -  -  [)        U5      S:  [        [)        U5      5      U4PTU-  [K        X1T-  5      -  SU-  [!        [        5      -  [%        U[        RF                  -   5      -  X-  -  U S-  US-  -
  U* [        RF                  -
  -  -  [        [)        U5      [        RF                  * :  [I        X#5      5      [        [)        U5      5      U4PTU-  [K        X1T-  5      -  SUS-   -  [!        [        5      -  [%        U[        S5      S-  -   5      -  X-  -  U -  U S-  US-  -
  U* [        S5      S-  -
  -  -  [        [)        U5      S:  [I        X#S-   5      5      [        [)        U5      5      U4P[M        SUT-  5      S[        -  [O        X-  5      -  [!        U S-  US-  -   5      -  [        R                  [        [7        U5      5      U4P[+        SUT-  5      [/        U [!        U S-  US-  -
  5      -   U-  5      [!        U S-  US-  -
  5      -  [        R                  [)        U5      * U4PnUTU 4$ )a%  
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   r|   r   r   r   r   tauomegac                    > [        U T5      $ r   )r   )r   r   s    rn   dco!_laplace_build_rules.<locals>.dcoS  s    ,Q22rq   z&_laplace_build_rules is building rulesr   ra   r      g      ?      )(r   r    rv   r   r   r   r:   r'   r$   rL   rM   r   r;   r>   r#   r   r/   r=   r@   rB   r!   r8   rA   r(   
EulerGammar?   r3   r"   r*   r4   r2   r+   r)   r<   r7   Halfr   r6   r9   r,   )	r|   r   r   r   r   r   r   laplace_transform_rulesr   s	           @rn   _laplace_build_rulesr  :  s   $ 	c
Ac
AS1#AS1#AS1#A
uqc
"C1#&E2
34|	
aC	
	| 
AaCE	C1QKA.	CAqAvAE16 2	3	
		S	"| 
AaCE	AaD	CAqAvAE16 2	3	
		S	"| 
1Q3q5	3r!tAv;q=	QUAE	AFFC	)| 
1Q3q5	Ac1"Q$q&kM1,	QUAE	AFFC	)| 
1Q3q5	1Q3	QUAF	QVVS	*| 
1Q3q5	1	QUAE	AFFC	)|" 
AadF	
	#|& 
AaCES!Aa[LQBqDF+A-	SX	QVVS	*'|* 
4!A;QrT!VSQZ/T!#a%[0AA!C	SX	QVVS	*+|. A#a%AaD57		
1!uQw<2a46QqT!V,,SQZ7$tACE{:KKAM	M	SX	QVVS	*/|4 
a!A#RT
2d1g:c!#h#6tDI#FF	SVr	1663	(5|8 
Ad1gIC 	!2a!A$q&k>#ac(#:4QS	?#J	
	9|< 
AuQqSz!c("	
R	=|@ A#a%!Z!QSU+C1QK7aC@B	QVSQS]R'	(!&&#	7A|D 
AqsQT%!*_ZAC%88	QVSQ[2%	&	5E|H 
QqSWsC4y!#	
A	I|L 
3qs3w<cTAC!8+	
A	M|P 
Ac!A#hac
AC1Q3</	ARUC	!Q|T 
aR1WtBqDF|C1QqM1$qac{2CC	AAFFC	!U|X 
3r!Q$w<	
AaC48QqSAaDFO+A-d1T!A#Y;.??	?	AAFFC	!Y|^ 
aRTAd13iK1T!#Y; 77	A!QVVS	"_|b 
aaRT		
1aR1W	q49}	-c"T!#Y,.?	?	A!QVVS	"c|h 
aRT47	DAJs2d13i<'88	A!QVVS	"i|l 
aRTAd1gI	RT
3r$qs)|+< <	AAFFC	!m|p 
Ac1"Q$iACAaC7++GAaC49,EE	AAFFC	!q|B 
aRQBZ!b'*Q"22	
	C|F 
aRAYj!Q//	AAFFC	!G|J 
QqSCALL)!+A-..q0	
Q	K|N 
QqsUc!#hYq[QBqD)	SVr	1663	(O|R 
QqSUc!fSQZ\!^Br!tH44a79	QUCAK"$	%qvvs	4S|V 
QQ$r!t*S1S->)>%??	
	W|Z 
Ac!feAaCjRT*GAaCLQ,?@	AQVVS	"[|^ 
QqS1s3q||,Q.q0114RU1W<a?	
Q	_|b 
U1Wud5!8m,	
RY	&c|f 
Sq\	Ea4q=1$r!tAve|2DD	AFFC	!g|j 
U1Waeg	
RY	&k|n 
U1Wq	C!E1H*QT/ 1214	
3r%y>!3	(o|r 
U1WqA		tAeGAI	qQqz!Q$%6!779	9	
3r%y>!3	(s|@ 
U1WqQ$uax-(	
RY	&A|D 
U1Wq1a4%(
?QT!E1H*_=a?	
3r%y>!3	(E|P 
QqS#ac(	AaCE!GQT13(]3QT13(]C	
RUC1J&	-Q|T 
QqS#ac(	A!tAqDyA~.1acAX>1acAXN	
RUC1J&	-U|X 
QqS#ac(	A!tAqDyA~.1acAX>1acAXN	
RUC1J&	-Y|\ 
acA!tAqDyM	
RUS	"]|` 
acA!tAqDyM	
RUS	"a|d 
acAqAvq!tAadF1H}-	
3r!u:s	$e|h 
acA1Qq!tVad1QT6!8m4	
3r!u:s	$i|l 
ac1c13+&q(	
RUS	"m|p 
Ad1Q3iqsAr!t}acaRT]'BC	
RQ	q|t 
Ad1Q3iqsAr!t}acaRT]'BC	
RQ	u|b 
QqS3q!tQqS1H}%d1ac7m3A5	
3s1v;	QVVS	*c|~ 
aC!$QT!Q$Y41QT	?1BQ0F FG	ASAZ	&|B 
Aga1o		
Ad2huQqvvX	&qt	+QT!Q$Y1"QVV),D	D	RUaffW_bh	'RUS	:C|H 
Aga1o		
QqS$r(	51Q46?	*14	/	11a4191Q46	2J	J	RURZAs	$c"Q%j#	7I|V 
Ad1a4!8n$	%	QS41QT	?""	#DAadO	3	SVr	3r!u:s	,W|\ 
aC!$QT!Q$Y41QT	?1BQ0F FG	ASAZ	&]|` 
Aga1o		
Ad2huQqvvX	&qt	+QT!Q$Y1"QVV),D	D	RUaffW_bh	'RUS	:a|f 
Aga1o		
QqS$r(	51Q46?	*14	/	11a4191Q46	2J	J	RURZAs	$c"Q%j#	7g|p 
AaC"R%ac
*41QT	?:	
RUS	"q|t 
AaC#q41QT	?2A56QT!Q$YH	
"Q%	u|z #Aq((rq   c                    [        SU/S9n[        SSS9nU R                  U5      nU(       a  XT   R                  S   R	                  U5      nUR                  " X1-  5      nU(       aV  Xs   R
                  (       aC  Xs   S:w  a;  [        S5        [        SXs   -  XT   R                  U5      -  XXs   -  SS	9u  pn
XU
4$ g
)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   gra   )nargsr   z     rule: time scaling (4.1.4)Fr   N)	r    r   r   rj   collectr   rv   _laplace_transformrm   )r   r   r|   r   r  ma1r#   ma2r   prcrs              rn   _laplace_rule_timescaler    s     	S1#AS"A
''!*C
fkk!n$$Q'iin36%%#&A+45*#&Q'cfHuFIA22;rq   c                    [        SU/S9n[        S5      n[        S5      nU R                  [        U5      U-  5      =n(       Ga9  Xd   R                  X-
  5      =n(       a  Xs   R                  (       aE  [	        S5        [        Xe   R                  XXs   -   5      XSS9u  pn
[        Xs   * U-  5      U-  X4$ Xs   R                  (       a  [	        S5        [        Xe   XSS9u  pn
XU
4$ Xd   R                  X1-
  5      =n(       aw  Xs   R                  (       a3  [	        S	5        [        S
[        XU   -
  5      -
  Xe   -  XSS9u  pn
XU
4$ Xs   R                  (       a  [	        S5        SS[        R                  4$ g)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   r   r  z     rule: time shift (4.1.4)Fr	  z8     rule: Heaviside factor; negative time shift (4.1.4)z      rule: Heaviside window openra   z"     rule: Heaviside window closedr   N)r    r   r;   r   rv   r  r   r'   is_negativer   r   )r   r   r|   r   r   r  r  r  r   r  r  s              rn   _laplace_rule_heavisider  ,  sp    	S1#AS	AS	AggilQ&''s'&,,qu%%3%v!!67.FKKsv:.uF	rSVGaK(1,b55v!!NP.svqeL	rr{"&,,qu%%3%v!!9:.11v:..#&8!P	rr{"v!!;<1aff~%rq   c                 H   [        SU/S9n[        S5      n[        S5      nU R                  [        U5      U-  5      nU(       a]  Xd   R                  U5      R                  X1-  5      nU(       a2  [	        S5        [        Xe   XXs   -
  SS9u  pn
X[        Xs   5      -   U
4$ g)	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   r   zz$     rule: multiply with exp (4.1.5)Fr	  N)r    r   r'   r
  rv   r  r!   )r   r   r|   r   r   r  r  r  r   r  r  s              rn   _laplace_rule_expr  V  s     	S1#AS	AS	A
''#a&(
C
fnnQ%%ac*9:*361h49;IA2"SV*}b))rq   c           
      ~   [        SU/S9n[        SU/S9n[        S5      n[        S5      nU R                  [        U5      U-  5      nU(       Gab  Xv   R                  [        5      (       GdE  Xu   R	                  U5      R                  XA-  U-
  5      nU(       Ga  [        S5        X   X   -  n	[        U	5      S:  a  [        U	5      S:X  a  [        X   * X   -  U-  5      Xv   -  n
U
R                  [        [        5      (       a#  U
R                  [        5      R                  5       n
U
R                  5        Vs/ s H  oR                  XU   X   -  5      PM     snu  pUS:w  a(  X-  X   -  [         R"                  [         R$                  4$ gS[         R"                  [         R$                  4$ Xu   R'                  U5      (       a  [)        Xu   U5      nU0 :w  a  [+        UR-                  5       5      S	1:X  a  [/        Xu   U5      n[1        [3        UR5                  5       5       Vs/ s HZ  n[        U5      S:X  d  M  [        U5      S:  d  M%  [        U* U-  5      Xv   R                  X5      -  UR                  X5      -  PM\     sn6 nU[         R"                  [         R$                  4$ gs  snf s  snf )
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   r   r   r  z#     rule: multiply with DiracDeltar   Nra   )r    r   r:   r   r
  rv   r!   r"   r'   r3   r2   rewriter5   ratsimpas_numer_denomr   r   r   r   is_polynomialrQ   setvaluesr   r   r   keys)r   r   r|   r   r   r   r  r  r  locfnr   r   r   rosloper   s                    rn   _laplace_rule_deltar#  m  sO    	S1#AS1#AS	AS	A
''*Q-/
"C
36::j))fnnQ%%ac!e,89&-C#w!|31#&)*36166#s## D)113B:<:K:K:MN:MQqa&-0:MN6CJ(:(:AFFCC1--qvv666""svq!BRxC		,3SVQ#BGGIM.!"Q%1* CACA! Cc1"Q$iA 11%**Q2BB.MN 1--qvv66 OMs   ?"J5.J:J:9J:c                 J   [         R                  /n[         R                  /n[        R                  " U 5       HU  nUR	                  [
        [        [        [        [        5      (       a  UR                  U5        MD  UR                  U5        MW     [        U6 n[        U6 nXE4$ )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   r3   r2   r+   r)   r'   append)r   trigsothertermr   r  s         rn   _laplace_trig_splitr+    sw     UUGEUUGEb!88CdD#..LLLL	 "
 	UAUA4Krq   c                 x   [        SU/S9n[        SU/S9n[        SU/S9n/ n/ nU R                  [        5      R                  5       n[        R
                  " U5       H  nUR                  U5      (       d#  UR                  SUSS[        S[        S05        M<  [        UR                  SS	9U5      nUR                  U[        X!-  U-   5      -  5      =n	bK  UR                  SX   [        X   5      -  SX   [        [        X   5      [        [        X   5      05        M  UR                  U5        M     XV4$ )
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.
c1r   c0r   kr   r   r'   )combine)r    r  r'   r   r   r&  r   r'  r!   r"   r   powsimpr   )
r   r   r-  r.  r   xmxnx1r*  r   s
             rn   _laplace_trig_expsumr5    s    
dQC	 B	dQC	 BS1#A	B	B	
3			 Bb!xx{{IIsD#q"aQ78$T\\%\%@!DAc"$r'lN++A8IIQT#ae*_c15BquIr2ae9. / IIdO " 6Mrq   c           	        ^ / n/ nS mU4S jnU4S jnU4S jnU4S jnS n	[        U 5      S:  Ga  U R                  5       n
SnSnSn[        [        U 5      5       H  nU
[           X   [           :H  nU
[           X   [           * :H  nU
[           X   [           :H  nU
[           X   [           * :H  nU(       a%  U(       a  U
[           S:w  a  U
[           S:w  a  UnM  U(       a  U(       a  U
[           S:w  a  UnM  U(       d  M  U(       d  M  U
[           S:w  d  M  UnM     Ub  Ub  Ub  UR                  U" U
X   S	   X   S	   X   S	   U5      5        UR                  [        [        U
S
   5      5      5        XU/nUR                  SS9  U H  nU R                  U5        M     GO"UbH  UR                  U" XU   S	   U5      5        UR                  U
[           5        U R                  U5        OUbQ  UR                  U" XU   S	   U5      5        UR                  [        U
[           5      5        U R                  U5        OUbQ  UR                  U" XU   S	   U5      5        UR                  [        U
[           5      5        U R                  U5        O/UR                  U	" X5      5        UR                  U
[           5        [        U 5      S:  a  GM  [        U6 [        U6 4$ )z
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                 >   U R                  5       n[        [        U5      5       Ht  nX   R                  5       nUS   R	                  [
        5      (       a  X   R                  [        5      X'   MM  US   [        US   -  -   R                  [        5      X'   Mv     U$ r   )	copyrangelenr   r   r"   r  r2   r   )coeffsncr/  ris       rn   _simpc"_laplace_trig_ltex.<locals>._simpc  s{    [[]s2wA##%B!uyy}}c*A2a511#6   	rq   c           
        > U S   U S   U [            U [           4u  pVpxXa-   U-   U-   XVU-   U-
  U-
  -  S[        -  U-  U-  -
  S[        -  U-  U-  -   US-  U* U-
  U-
  U-
  -  US[        -  U-  U-  S[        -  U-  U-  -   -  -   SUS-  -  U-  -   SUS-  -  U-  -   US-  U* U-
  U-   U-   -  US-  S[        -  U-  U-  S[        -  U-  U-  -   S[        -  U-  U-  -
  S[        -  U-  U-  -
  -  -   USUS-  -  U-  SUS-  -  U-  -
  -  -   /n	[        R                  [        R
                  SUS-  -  SUS-  -  -
  [        R
                  US-  SUS-  -  US-  -  -   US-  -   /n
[        [        T" U	5      [        [        U	5      5      S S S2   5       VVs/ s H  u  pXU-  -  PM     snn6 n[        [        U
[        [        U
5      5      S S S2   5       VVs/ s H  u  pXU-  -  PM     snn6 nX-  $ s  snnf s  snnf )Nr   r/  r   r   r   r   )
r!   r"   r   r   r%  r   r   zipr9  r:  )t1k1k2k3r|   r   k0a_ra_ir<  dcr   r   r   r   r>  s                  rn   	_quadpole%_laplace_trig_ltex.<locals>._quadpole  s`   S'2c7BrFBrF:sGbL2Bw|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!Fa1f!FGI!$Rs2w")=!>?!>a1f!>?As
 H?s   G>
"H
c           
        > U S   U S   U [            U [           4u  p4pVXA-   U* U-  X1-  -
  S[        -  U-  U-  -   /n[        R                  SU-  US-  US-  -   /n[        [        T" U5      [        [        U5      5      S S S2   5       V	V
s/ s H  u  pXU
-  -  PM     sn
n	6 n[        [        U[        [        U5      5      S S S2   5       V	V
s/ s H  u  pXU
-  -  PM     sn
n	6 nX-  $ s  sn
n	f s  sn
n	f Nr   r/  r   r   r   	r!   r"   r   r   r%  r   rA  r9  r:  )rB  rC  r|   r   rF  rG  rH  r<  rI  r   r   r   r   r>  s                rn   _ccpole#_laplace_trig_ltex.<locals>._ccpole  s    S'2c7BrFBrF:sgr"uqt|ac#gbj01eeRVS!Vc1f_-!$VBZs2w"1E!FG!Fa1f!FGI!$Rs2w")=!>?!>a1f!>?As
 H?s   C/
C5
c           
        > U S   U S   U [            U [           4u  p4pVXA-   X4-  X1-  -
  S[        -  U-  U-  -
  /n[        R                  S[        -  U-  US-  * US-  -
  /n[        [        T" U5      [        [        U5      5      S S S2   5       V	V
s/ s H  u  pXU
-  -  PM     sn
n	6 n[        [        U[        [        U5      5      S S S2   5       V	V
s/ s H  u  pXU
-  -  PM     sn
n	6 nX-  $ s  sn
n	f s  sn
n	f rM  rN  )rB  rD  r|   r   rF  rG  rH  r<  rI  r   r   r   r   r>  s                rn   _rspole#_laplace_trig_ltex.<locals>._rspole  s   S'2c7BrFBrF:sgqtad{QqSWRZ/0eeRT#XQwa/0!$VBZs2w"1E!FG!Fa1f!FGI!$Rs2w")=!>?!>a1f!>?As
 H?s   C5
C;
c           
        > U S   U S   pCXA-   X4U-
  -  /n[         R                  [         R                  US-  * /n[        [	        T" U5      [        [        U5      5      S S S2   5       VVs/ s H  u  pxXrU-  -  PM     snn6 n	[        [	        U[        [        U5      5      S S S2   5       VVs/ s H  u  pxXrU-  -  PM     snn6 n
X-  $ s  snnf s  snnf )Nr   r/  r   r   )r   r%  r   r   rA  r9  r:  )rB  rE  r|   r   rF  r<  rI  r   r   r   r   r>  s              rn   _sypole#_laplace_trig_ltex.<locals>._sypole  s    3C2gqr'{#eeQVVadU#!$VBZs2w"1E!FG!Fa1f!FGI!$Rs2w")=!>?!>a1f!>?As
 H?s   -C
1C
c                 (    U S   U S   p2UnX-
  nXE-  $ )Nr   r/  rr   )rB  r|   r   rF  r   r   s         rn   _simplepole'_laplace_trig_ltex.<locals>._simplepole  s$    3C2Es
rq   r   Nr/  r   T)reverse)
r:  popr9  r!   r"   r'  r$   r   r   r-   )r2  r   r|   resultsplanesrJ  rO  rR  rU  rX  rB  	i_imagsym	i_realsym
i_pointsymireal_eqrealsymimag_eqimagsymindices_to_popr>  s                       @rn   _laplace_trig_ltexrg    s    GF. b'A+VVX		

 s2wAfb	)Gfr
*Gfb	)Gfr
*G7r"v{r"v{
WB1	WWB1	  ( %)*?*NN"-,bmC.@.-q23 MM#bCk*+ (J?N-#q	 $"NN72)}S'91=>MM"R&!FF9"NN72)}S'91=>MM#bf+&FF9#NN72*~c':A>?MM#bf+&FF:NN;r-.MM"R&!q b'A+t =#v,&&rq   c           
      \   [        SSS9nU R                  [        [        [        [
        5      (       d  g[        U R                  X5      5      u  pE[        XC5      u  pg[        U5      S:  a  gUR                  U5      (       d#  [        XcU5      u  pXX-  U	[        R                  4$ / n
/ n[        XSUSS9u  pnU HO  nUR                  US   UR                  X"US	   -
  5      -  5        U
R                  U[        US	   5      -   5        MQ     [!        U6 R                  X15      [#        U
6 U4$ )
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realNr   Fr	  r/  r   )r   r   r3   r2   r+   r)   r+  r   r5  r:  rg  r   r   r  r'  r!   r   r-   )r   t_r|   r   r   r  r2  r3  r   r   r]  r\  GG_planeG_condr4  s                   rn   _laplace_rule_trigro  [  s    	cA66#sD$''rwwr~.DA!!'FB
2w{5588!"+sAqvv~ /a%HFBNN2c7166!r#wY#778MM'"RW+-.  =a$c6lF::rq   c                    [        SU/S9n[        SU/S9n[        S5      nU R                  U[        XQU45      -  5      nU(       a  Xd   R                  (       a  Xe   R
                   Vs/ s H  owR                  U5      PM     nn[        U5      S:X  a  [        S5        / n	[        Xd   5       H\  n
U
S:X  a  Xe   R                  US5      nO[        Xe   X45      R                  US5      nU	R                  X&U   U
-
  S-
  -  U-  5        M^     [        Xe   XSS	9u  pnXc   X&U   -  U-  [        U	6 -
  -  X4$ g
s  snf )z
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  ra   z"     rule: time derivative (4.1.8)r   Fr	  N)r    r   r   r
   
is_integerrj   r   sumrv   r9  r   r'  r  r   )r   r   r|   r   r   r  r  r  r   r   r/  r   r   r  r  s                  rn   _laplace_rule_diffrs  |  s4    	S1#AS1#ASA
''!Jqa&))
*C
sv  "v{{+{!UU1X{+q6Q;78A36]6Aq)A"36A62771=AVAXaZ*+ # +361%HIA2FA1vIaK#q'12R<< ,s   +D;c           
         U R                   (       Ga  S/nS/n[        R                  " U 5       H=  nUR                  U5      (       a  UR	                  U5        M,  UR	                  U5        M?     [        U5      S:  GaC  [        U5      n[        Xa5      R                  5       n[        U5      nUS:  Ga  [        U5      n	[        XUSS9u  pnU
/nSn [        US   U5      * nU
R                  [        5      (       a=  [        US-
  5       H*  nUR	                  SUS-   -  [        XUS-   5      -  5        M,     OLU(       aE  UR	                  U5        [        US-
  5       H"  nUR	                  [        US   U5      * 5        M$     U(       a4  [!        [        U5       Vs/ s H  nXxU-
  S-
     UU   -  PM     sn6 nUX4$ [#        SU/S9n[#        S5      nU R%                  UU-  U-  5      =n(       aT  UU   R&                  (       a@  UU   R(                  (       a,  [        UU   XSS9u  pnSUU   -  [        XUU   45      -  X4$ g	! [         a    Sn GNvf = fs  snf )
z
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)``.
ra   Fr	  r   r   r   r   r  N)is_Mulr   r&  r  r'  r:  r   rR   
all_coeffsr  r   
ValueErrorr   LaplaceTransformr9  r
   r   r    r   rq  r   )r   r   r|   pfacofacfacpexpcNoexr_p_c_derid1r/  r   r   r  r  s                       rn   _laplace_rule_sdiffr    s3    	xxxss==#C  ##C C 	 $
 t9q=t*Cc((*BBA1u4j/EJ
ttBx++B 66*++"1Q3ZR1Q3K
2!A#0F$FG (KKO"1Q3ZT$r(A%6$67 (qBAb1QiQ/BCAr;& 	S1#AS	Aggad1fosq6Q!3!3+CFA5IJBBQ<RSV 55r==) " B Cs   I !IIIc                 l   [        U SS9nUR                  (       a  [        X1USS9$ [        U 5      nUR                  (       a  [        X1USS9$ [        U 5      nUR                  (       a  [        X1USS9$ X0:w  a  [        X1USS9$ [        [	        U 5      5      nUR                  (       a  [        X1USS9$ g)aj  
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 available 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.
Fdeepr	  N)r   is_Addr  r   r   )r   r   r|   r   s       rn   _laplace_expandr    s     	quAxx!!E::1Axx!!E::q	Axx!!E::v!!E::{1~Axx!!E::rq   c                     [         [        [        [        [        [
        [        /nU H  nU" XU5      =nc  M  Us  $    g)z_
This function applies all program rules and returns the result if one
of them gives a result.
N)r  r#  r  r  ro  rs  r  )r   r   r|   
prog_rulesp_ruleLs         rn   _laplace_apply_prog_rulesr    sG     *+>)+<$$&9;J
 a A-H  rq   c                    [        5       u  p4nSnSnU H  u  ppnXl:w  a  U" U R                  X05      5      nUnUR                  U5      nU(       d  M@   U
R                  U5      nU[
        R                  :X  d  Mh  U	R                  U5      R                  XR05      UR                  U5      [
        R                  4s  $    g! [         a     M  f = f)z^
This function applies all simple rules and returns the result if one
of them gives a result.
 N)r  r   r   xreplacer   r   r   )r   r   r|   simple_rulesrk  r   prep_oldprep_ft_doms_domcheckplaneprepmar   s                  rn   _laplace_apply_simple_rulesr    s     01LbHF,8(eD!&&!/*FH\\% 2NN2&
 AFF{r*//8r*AFF4 4 -9    s   C
CCc                    UR                   (       d6  [        SSS9n[        U R                  X05      U5      R                  X!05      $ [	        U 5      n/ nUR
                   GH  u  pE[        U[        5      (       ad  XR
                  ;   aU  [        U[        [        45      (       a  U s  $ UR                  [        UR                  UR                  -
  5      U-  5        M  [        U[        5      (       ay  [        UR
                  5      S:X  a`  UR
                   HM  nUR                   U:X  a6  UR                  [        UR                  UR                  -
  5      U-  5        MI  U s  s  $    GM  [        U["        5      (       a  [        UR
                  5      S:X  a  UR
                  u  pxUR                   U:X  a|  UR                   U:X  al  SUR$                  ;   a  XpUR                  [        UR                  UR                  -
  5      [        UR                  UR                  -
  5      -
  U-  5        GM  U s  $ U s  $    ['        U6 $ )z
This function converts a Piecewise expression to an expression written
with Heaviside. It is not exact, but valid in the context of the Laplace
transform.
r   Tri  r   >)is_realr   _piecewise_to_heavisider  r1   rj   r   r   r   r   r'  r;   gtsr   rL   r:  lhsrM   r   r   )	r   r   r   r   r   r   c2r.  r-  s	            rn   r  r    s    99#D!&qzz1&'91=FFvNNAA
AFF dJ''AN$R))
 488dhh#67:;b!!c$))n&9ii66Q;HHYrvv7:;H	  
 c""s499~':YYFBvv{rvv{"))#rvv/rvv/01345 HA B 7Nrq   c          	         [        S5      n[        S5      n[        S5      n[        S5      n[        U [        5      (       a4  U R                  [        5      (       d  U R                  [
        5      (       d  U $ UR                  5        H}  u  pgU R                  [	        U" U5      XC5      5      =nb  X   X   :X  a  U" X   5      s  $ U R                  [        U" U5      X4U5      5      =n c  Mg  X   X   :X  d  Ms  U" X   5      s  $    U R                  n	U R                   V
s/ s H  n
[        X5      PM     nn
U	" U6 $ s  sn
f )a  
This helper function takes a function `f` that is the result of a
``laplace_transform`` or an ``inverse_laplace_transform``.  It replaces all
unevaluated ``LaplaceTransform(y(t), t, s)`` by `Y(s)` for any `s` and
all ``InverseLaplaceTransform(Y(s), s, t)`` by `y(t)` for any `t` if
``fdict`` contains a correspondence ``{y: Y}``.

Parameters
==========

f : sympy expression
    Expression containing unevaluated ``LaplaceTransform`` or
    ``LaplaceTransform`` objects.
fdict : dictionary
    Dictionary containing one or more function correspondences,
    e.g., ``{x: X, y: Y}`` meaning that ``X`` and ``Y`` are the
    Laplace transforms of ``x`` and ``y``, respectively.

Examples
========

>>> from sympy import laplace_transform, diff, Function
>>> from sympy import laplace_correspondence, inverse_laplace_transform
>>> from sympy.abc import t, s
>>> y = Function("y")
>>> Y = Function("Y")
>>> z = Function("z")
>>> Z = Function("Z")
>>> f = laplace_transform(diff(y(t), t, 1) + z(t), t, s, noconds=True)
>>> laplace_correspondence(f, {y: Y, z: Z})
s*Y(s) + Z(s) - y(0)
>>> f = inverse_laplace_transform(Y(s), s, t)
>>> laplace_correspondence(f, {y: Y})
y(t)
r   r|   r   r   )r    r   r   r   rx  InverseLaplaceTransformitemsr   rm   rj   laplace_correspondence)r   fdictr   r|   r   r   r   Yr   rm   r#   rj   s               rn   r  r  F  s   H 	S	AS	AS	AS	A1d##EE*++566gg.qtQ:;;HDADLQT7Ngg5adA!DEEDADLQT7N  66D:;&&A&3"3.&DA; Bs   #D?c                   UR                  5        H  u  p4[        [        U5      5       H  nUS:X  a  U R                  U" S5      US   5      n M&  US:X  a2  U R                  [	        [        U" U5      U5      US5      US   5      n M^  U R                  [	        [        U" U5      X45      US5      XE   5      n M     M     U $ )a  
This helper function takes a function `f` that is the result of a
``laplace_transform``.  It takes an fdict of the form ``{y: [1, 4, 2]}``,
where the values in the list are the initial value, the initial slope, the
initial second derivative, etc., of the function `y(t)`, and replaces all
unevaluated initial conditions.

Parameters
==========

f : sympy expression
    Expression containing initial conditions of unevaluated functions.
t : sympy expression
    Variable for which the initial conditions are to be applied.
fdict : dictionary
    Dictionary containing a list of initial conditions for every
    function, e.g., ``{y: [0, 1, 2], x: [3, 4, 5]}``. The order
    of derivatives is ascending, so `0`, `1`, `2` are `y(0)`, `y'(0)`,
    and `y''(0)`, respectively.

Examples
========

>>> from sympy import laplace_transform, diff, Function
>>> from sympy import laplace_correspondence, laplace_initial_conds
>>> from sympy.abc import t, s
>>> y = Function("y")
>>> Y = Function("Y")
>>> f = laplace_transform(diff(y(t), t, 3), t, s, noconds=True)
>>> g = laplace_correspondence(f, {y: Y})
>>> laplace_initial_conds(g, t, {y: [2, 4, 8, 16, 32]})
s**3*Y(s) - 2*s**2 - 4*s - 8
r   ra   )r  r9  r:  r   r   r
   )r   r   r  r   icr/  s         rn   laplace_initial_condsr    s    D s2wAAvIIadBqE*aIId:adA#61=r!uEIId:adQF#;QBBEJ    Hrq   c                  ^ [         R                  " U 5      n/ n/ n/ n/ nU GH#  n	U	R                  TSS9u  pUR                  [        5      (       a[  [         R                  " UR                  [        5      5      nU H*  nUR                  TSS9u  pUR                  X-  U45        M,     M  UR                  [        :X  ar  UR                  [        T5      5      (       dS  [         R                  " [        UT5      5      nU H*  nUR                  TSS9u  pUR                  X-  U45        M,     GM  UR                  X45        GM&     U GH  u  pUR                  [        5      (       a   [        UTU5      [        R                  S4nGOUR                  [        T5      5      (       a:  UR                  [        T5      5      (       d  UR                  [        T5      S5      n[!        UTU5      =n c!  [#        UTU5      =n c  [%        UTU5      =nb  Oz['        U4S jUR)                  [*        5       5       5      (       a  [        UTU5      [        R                  S4nO.[-        UTX#S9=n b  O[        UTU5      [        R                  S4nUu  nnnUR                  U
U-  5        UR                  U5        UR                  U5        GM     [        U6 nU(       a  UR/                  SS9n[1        U6 n[3        U6 nUUU4$ )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.
Fas_AddTra   c              3   D   >#    U  H  oR                  T5      v   M     g 7fr   r   )r   undefrk  s     rn   r   %_laplace_transform.<locals>.<genexpr>  s     G0FuYYr]]0F    r	  doit)r   r&  as_independentr   rC   r  r;   r'  rm   r0   r:   r  rx  r   r   r   r  r  r  anyr   r	   rb   r   r-   rM   )r   rk  r   r   terms_tterms_stermsr]  
conditionsffr/  ft_terms_termrC  f1r   ri_pi_ci_rl   r  	conditions    `                     rn   r  r    s    mmBGGEFJ!!"U!366%&&]]2::i#89F--b-?adBZ(   WW	!"&&B*@*@]]#:2r#BCF--b-?adBZ(   LL!!  66%&&!"b"-q/A/A4HAvvim$$RVVJrN-C-C WWYr]A.5b"bAAQ 3BB??Q )"b"55QBG0FGGG &b"b113E3EtL5B3 3!;?@%b"b113E3EtLc3quc#; > ']Fe,LEZ I5)##rq   c                   .    \ rS rSrSrSrS rS rS rSr	g)	rx  i  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                 >    UR                  SS5      n[        XX5S9nU$ )Nr   Fr	  )getrb   )selfr   r   r|   hintsrF   LTs          rn   _compute_transform#LaplaceTransform._compute_transform  s#    IIj%0	+A!H	rq   c                 x    [        U[        U* U-  5      -  U[        R                  [        R                  45      $ r   )rE   r'   r   r   r   )r  r   r   r|   s       rn   _as_integralLaplaceTransform._as_integral  s,    #qbd)a%<==rq   c                    UR                  SS5      nUR                  SS5      n[        SU R                  U R                  U R                  45        U R                  nU R                  nU R                  n[        XdXSS9nU(       a  US   $ U$ )"  
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  rX   functionfunction_variabletransform_variabler  )r  r  _nocondsrF   rk  r   r   r   s           rn   r  LaplaceTransform.doit  s     99Y-IIj%0	'$--*.*@*@*.*A*A*C 	D ##$$]]rr>Q4KHrq   rr   N)
ri   
__module____qualname____firstlineno____doc___namer  r  r  __static_attributes__rr   rq   rn   rx  rx    s     E
>rq   rx  c                   ^^^ TR                  SS5      nTR                  SS5      n[        U [        5      (       a  [        U S5      (       a  TR                  SS5      (       + nU(       aD  U(       a=  Sn[	        SSUS9  [        [        5         U R                  UUU4S	 j5      sS
S
S
5        $ U  V	s/ s H  n	[        U	TT40 TD6PM     n
n	U(       a9  [        U
6 u  pn[        U 5      " / U R                  QUP76 nU[        U6 [        U6 4$ [        U 5      " / U R                  QU
P76 $ [        U TT5      R                  SUS9u  nnnU(       d  UUU4$ U$ ! , (       d  f       N;= fs  sn	f )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)

There are also helper functions that make it easy to solve differential
equations by Laplace transform. For example, to solve

.. math :: m x''(t) + d x'(t) + k x(t) = 0

with initial value `0` and initial derivative `v`:

>>> from sympy import Function, laplace_correspondence, diff, solve
>>> from sympy import laplace_initial_conds, inverse_laplace_transform
>>> from sympy.abc import d, k, m, v
>>> x = Function('x')
>>> X = Function('X')
>>> f = m*diff(x(t), t, 2) + d*diff(x(t), t) + k*x(t)
>>> F = laplace_transform(f, t, s, noconds=True)
>>> F = laplace_correspondence(F, {x: X})
>>> F = laplace_initial_conds(F, t, {x: [0, v]})
>>> F
d*s*X(s) + k*X(s) + m*(s**2*X(s) - v)
>>> Xs = solve(F, X(s))[0]
>>> Xs
m*v/(d*s + k + m*s**2)
>>> inverse_laplace_transform(Xs, s, t)
2*v*exp(-d*t/(2*m))*sin(t*sqrt((-d**2 + 4*k*m)/m**2)/2)*Heaviside(t)/sqrt((-d**2 + 4*k*m)/m**2)

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                     > [        U TT40 TD6$ r   )laplace_transform)fijr  r|   r   s    rn   r   #laplace_transform.<locals>.<lambda>  s     1#q! Eu Erq   Nr  r   )r  r   rN   hasattrrU   rW   rV   r  r  rA  typeshaper-   rM   rx  r  )r   r   r|   legacy_matrixr  r  rF   r   adtr  elements_transelementsavalsr  	f_laplacer  r   r   s    `` `             rn   r  r  +  ss   N yyE*H		*e,I!Z  WQ%<%<IIi//]7C%
 */+. !!89{{EG :9
 012/0 0Q$"$/0  2.1>.B+ G7QWW7h7	 #u+sJ/???Aw88881a(--e7@ . BHB1 1ax	' :92s   E4E)
E&c                  ^^^ SSK JnJm  SSKJn  [        SSS9mUU4S jnU R                  U5      (       a  U R                  U5      n U R                  (       aL  [        U R                   Vs/ s H  n[        XTX45      PM     sn6 n	[        U	R                  TU5      U5      S4$  U" X[        T* 5      S[        R                   4SS	S
9u  pU	cq  U" XT5      n	U	c  gU	R$                  (       a-  U	R                  S   u  pU	R'                  [(        5      (       a  gO[        R*                  n
U	R-                  [.        U5      n	U	R$                  (       a  U	R                  TU5      W
4$ [        S5      m[        R0                  4UU4S jjnU	R-                  [2        U5      n	S nU	R-                  [        U5      n	[        U	R                  TU5      U5      W
4$ s  snf ! ["         a    Sn	 GNf = f)z5The backend function for inverse Laplace transforms. r   )meijerint_inversion_get_coeff_exp)inverse_mellin_transformr   Tri  c                  J  > [        U 5      S:w  a  [        U 6 $ U S   R                  S   R                  nT" UT5      u  p#U S   R                  S   nU S   R                  S   n[	        S[        U5      -  TU-  -
  5      U-  [	        TU-  S[        U5      -  -
  5      U-  -   $ )z2Simplify a piecewise expression from hyperexpand. r   r   r   ra   )r:  r0   rj   argumentr;   r$   )rj   r#   coeffexponente1e2r  r   s         rn   pw_simp7_inverse_laplace_transform_integration.<locals>.pw_simp  s    t9>d##1gll1o&&(a0!W\\!_!W\\!_aE
lQ[01"4akAc%jL01"45	6rq   NF)needevalr  uc                 V  > U R                   " [        T* 5      T5      nUR                  T5      (       a  [        X5      $ SSKJn  U" US:  T5      nUR                  T:X  a$  [        UR                  5      n[        TU-   U5      $ [        UR                  5      n[        TU-   * U5      $ )Nr   r   )	r   r'   r   r;   r   r   r   r(   r  )r#   H0r   r   relr/  r   r  s         rn   simp_heaviside>_inverse_laplace_transform_integration.<locals>.simp_heaviside  s    HHS!Wa 5588S%%@Aq)77a<CGGAQUB''CGGAq1uXr**rq   c                 *    [        [        U 5      5      $ r   )r   r'   )r#   s    rn   simp_exp8_inverse_laplace_transform_integration.<locals>.simp_exp  s    c#h''rq   )sympy.integrals.meijerintr  r  sympy.integrals.transformsr  r   is_rational_functionapartr  r   rj   rc   rF   r   r'   r   r   rH   r   r   rE   r   r   r0   r  r;   )r   r|   rk  r  r   r  r  r  Xr   r   r  r  r  r   r  s                @@@rn   rc   rc     s    NC 	cA
6 	a  GGAJxxvv! 5Q1eN  21477*1aR4:L48%I
 	ya(9>>ffQiGAuuX  66DIIi)~~ vva}d""c
A vv + + 	
		)^,A( 	
		#x AQVVAr]H-t33c " s   .G(&G G,+G,c                     SSK Jn  U" U 5      u  p4UR                  U5      (       aT  UR                  U5      R	                  5       n[        U5      S:X  a&  Uu  pgnXaUSU-  -  -   S-  X-  -   USU-  -  S-  -
  -  nX4-  $ )Nr   )fractionr   r   )r   r  r  r   rv  r:  )	r   r|   r  r   r   cfr   r   r   s	            rn   _complete_the_square_in_denomr    s    /a[FQqYYq\$$&r7a<GA!a1gI>!#%q!A#wl23A3Jrq   c            
         [        S5      n [        S5      n[        SU /S9n[        SU /S9n[        SU /S9n[        S5        S nS	 nX -  U[        R                  US
4X0U-   U* -  -  XS
-
  -  [        U* U-  5      -  [        U5      -  [        R                  US
4S
U S-  US-  -   S-  -  [        X!-  5      X!-  [        X!-  5      -  -
  SUS-  -  -  [        R                  US
4S
X-  -  XS
-
  -  [        U5      -  [        R                  US
4S
X U-   U-  -  -  [        X2U-  5      X#-  [        U5      -  -  [        R                  US
4/nXpU4$ )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`.
r|   r   r   r   r   r   z._inverse_laplace_build_rules is building rulesc                 J     U R                  U5      $ ! [         a    U s $ f = fr   )factorrP   )r   r|   s     rn   _frac+_inverse_laplace_build_rules.<locals>._frac(  s)    	88A; 	H	s    ""c                     U $ r   rr   )r   s    rn   same*_inverse_laplace_build_rules.<locals>.same.  s    rq   ra   r   r   )
r   r    rv   r   r   r'   r@   r3   r2   rA   )r|   r   r   r   r   r  r  
_ILT_ruless           rn   _inverse_laplace_build_rulesr    sp    	c
Ac
AS1#AS1#AS1#A
;<  
aq!sqbkM1s8C1I-eAh6FFD!	 
AqDAI>	CHqs3qs8|3a1f=	
q	 
AD11u:eAh&a8	
AsQhJAs+QT%(];	
q	J !rq   c                 F   U S:X  a&  [        S5        [        U5      [        R                  4$ [	        5       u  p4nSnU R                  X05      nU H  u  ppnXkU4:w  a  U" X|-  5      nX4nWR                  U5      nU(       d  M5  U
nU[        R                  La,  US    Vs/ s H  nUR                  U5      PM     nnUS   " U6 nU[        R                  :X  d  M  [        U5      U	R                  U5      R                  XR05      -  [        R                  4s  $    gs  snf )8
Helper function for the class InverseLaplaceTransform.
ra   z     rule: 1 o---o DiracDelta()r  r   N)	rv   r:   r   r   r  r   r   r  r;   )r   r|   r   r  r   rk  _prepfsubsr  r  r  r  r{  _Fr  r   r   rj   s                     rn   #_inverse_laplace_apply_simple_rulesr   B  s   
 	Av01!}aff$$57JBEFFA7OE*4&e33KeiBKEXXe_2A01!51

25aD$KAFF{ |ENN2$6$;$;RG$DDaffLL +5  6s   !Dc           	      
   [        SU/S9n[        SU/S9n[        S5      nU R                  U[        XaU45      -  5      nU(       a<  Xu   R                  (       a)  [	        S5        [        Xv   XUSSS9u  pU* Xu   -  U-  U	4$ g)	r  r   r   r   r  z3     rule: t**n*f(t) o---o (-1)**n*diff(F(s), s, n)Fr   
dorationalN)r    r   r
   rq  rv   _inverse_laplace_transform)
r   r|   r   r  r   r   r  r  r   r   s
             rn   _inverse_laplace_diffr%  _  s    
 	S1#AS1#AS	A	
:aQ((	)B	beDE)E15BRU{1}arq   c           	         [        SU/S9n[        S5      nU R                  U5      (       d  U [        U5      -  [        R                  4$ U R                  [
        5      (       d  gU R                  [        XA-  5      5      nU(       aZ  Xd   R                  (       a+  [        S5        [        X&U   -   5      [        R                  4$ [        XX#5      [        R                  4$ U R                  [        XA-  5      U-  5      nU(       aN  Xd   R                  (       a  [        S5        [        Xe   XXd   -   USSS	9$ [        XX#5      [        R                  4$ g)
r  r   r   r  Nz*     rule: exp(-a*s) o---o DiracDelta(t-a)z5     rule: exp(-a*s)*F(s) o---o Heaviside(t-a)*f(t-a)FTr"  )r    r   r:   r   r   r'   r   r  rv   r  r$  )r   r|   r   r  r   r  r  s          rn   _inverse_laplace_time_shiftr'  p  s   
 	S1#AS	A5588A&&55::
''#ac(
C
6?@aAh'//*1:AFFBB
''#ac(1*
C
6JK-SV8UUtM M +1:AFFBBrq   c                    U R                  U5      (       d  U [        U5      -  [        R                  4$ [	        U R
                  =n5      S:X  a  [        SU/S9nUS   R                  X-
  5      =n(       ae  [        Xe   5      R                  (       aI  [        S5        [        Xe   * U-  5      [        U R                  U5      XU5      -  [        R                  4$ g)r  ra   r   r   r   z&     rule: F(s-a) o---o exp(-a*t)*f(t)N)r   r:   r   r   r:  rj   r    r   r!   r   rv   r'   r  rm   )r   r|   r   r  rj   r   r  s          rn   _inverse_laplace_freq_shiftr)    s    
 5588A&&
166>4aqc"q'--$$B$"RU)*?*?;<RUF1H'q	1?@ABI I rq   c           	         [        SU/S9n[        S5      nU R                  X-  U-  5      nU(       a  Xd   R                  (       a  Xd   R                  (       a}  [	        S5        [        Xe   XUSSS9u  pxUR                  [        U5      S5      nUR                  [        5      (       a  [        XrXd   5      U4$ [        U5      [        XrXd   5      -  U4$ g	)
r  r   r   r  z+     rule: s**n*F(s) o---o diff(f(t), t, n)FTr"  ra   N)r    r   rq  r   rv   r$  r   r;   r   r  r   )	r   r|   r   r  r   r  r  r   r   s	            rn   _inverse_laplace_time_diffr+    s    
 	S1#AS	A
''!$q&/C
sv  SV%7%7<=)FA%%DBIIilA&55())cf%q((Q<Q36 22A55rq   c           	      @-  ^^ [        SU/S9n[        SU/S9m[        SU/S9n[        SU/S9mSn[        R                  nU R                  5       nU V	s/ s H  oR	                  XAU-  -  T-   T-  5      PM      n
n	SU
;   a  g[        R
                  n/ n/ n/ nU
 Hp  nX   S:X  a  X-  nM  UT   R                  (       a  UR                  U5        M8  UT   R                  (       a  UR                  U5        M_  UR                  U5        Mr     [        UUU4S jS	9n[        UUU4S
 jS	9n[        U5      S:w  a  g[        U5      S:X  Ga  [        U5      S:X  Ga  US   T   S:X  a  US   U   [        R                  :X  a  US   T   US   U   -  nSUS   U   -  U-  nUR                  (       aY  U[        [        5      -  [        U5      -  UU-  [        US-  U-  5      -  [        U[        U5      -  5      -  -
  n[!        S5        GOyUS   T   S:X  a  US   U   [        R                  :X  a  US   T   US   U   -  nUS-  nSUS   U   S-  -  U-  nUR                  (       az  USS[        [        5      -  [        U5      -  [        U5      -  -
  SSU-  U-  -
  [        UU-  5      -  [#        [        U5      [        U5      -  5      S-
  -  -   -  n[!        S5        GOUS   T   S:X  a  US   U   [        R                  :X  a  US   T   US   U   -  nSUS   U   S-  -  U-  nUR                  (       aw  US[        [        5      -  US-  U-  S-   -  [        U5      -  UU-  [        US-  U-  5      -  SUS-  -  U-  S-   -  [        U[        U5      -  5      -  -
  -  n[!        S5        GOUS   T   S:X  a  US   U   [        R                  :X  a  US   T   US   U   -  nSUS   U   S-  -  U-  S-  nUR                  (       a  UUSUS-  -  US-  -  SUS-  -  U-  -   S-   -  [        US-  U-  5      -  [        U[        U5      -  5      -  S[        [        5      -  US-  -  U[        S5      S-  -  -  SUS-  -  U-  S-   -  -
  -  n[!        S5        GOUS   T   [        R                  * :X  aZ  US   U   S:X  aN  [        US   T   US   U   -  5      nS[        US   U   5      -  U-  nU[%        SUU-  5      -  n[!        S5        GOf[        U5      S:X  Ga  [        U5      S:X  Ga  US   T   S:X  a  US   U   [        R                  :X  a  US   T   [        R                  :X  a  US   T   S:X  a  US   T   n[        US   U   5      US   U   -  U-  nUSUS-  -  US-  -  SUS-  -  U-  -   S-   -  [        US-  U-  5      -  [        U[        U5      -  5      -  S[        [        5      -  U-  US-  U-  S-   -  [        U5      -  -
  n[!        S5        US   T   S:X  a  US   U   S:X  a  US   T   [        R                  :X  a  US   U   S:X  a  US   T   US   U   -  nUS   T   US   U   -  n[        US   U   5      US   U   -  U-  nU[        U* U-  5      [        U5      -  [        [        5      -  [        UU-
  5      [        U* U-  5      -  [#        [        UU-
  5      [        U5      -  5      -  -   -  n[!        S5        GOW[        U5      S:X  GaL  [        U5      S:X  Ga<  US   T   S:X  a  US   U   S:X  a  US   T   [        R                  * :X  a  US   U   S:X  a  US   T   S:X  a  US   T   * US   U   -  nS[        US   U   5      -  US   U   -  U-  nUR                  (       aI  U[        U5      -  [        UU-  5      -  [#        [        U5      [        U5      -  5      -  n[!        S5        GO^US   T   S:X  a  US   U   S:X  a  US   T   S:X  a  US   T   S:X  a  US   U   [        R                  :X  ax  US   T   US   U   -  nSUS   U   -  US   U   -  U-  U-  nUR                  (       a:  US[        US-  U-  5      [        U[        U5      -  5      -  -
  -  n[!        S5        GOUS   T   S:X  a  US   U   [        R                  :X  a  US   T   [        R                  * :X  a  US   U   S:X  a  US   T   S:X  a{  US   T   US   U   -  nSUS   U   [        US   U   5      -  -  U-  nUR                  (       a7  U[        US-  U-  5      -  [        U[        U5      -  5      -  n[!        S5        GOUS   T   [        S5      * S-  :X  a  US   U   S:X  a  US   T   S:X  a  US   T   S:X  a  US   U   [        R                  :X  a  US   T   US   U   -  nSUS   U   [        S5      S-  -  US   U   -  -  US-  -  U-  nUR                  (       a\  US[        [        5      -  U-  [        U5      -  [        US-  U-  5      [        U[        U5      -  5      -  -   S-
  -  n[!        S5        GOUS   T   S:X  a  US   U   [        R                  :X  a  US   T   S:X  a  US   U   S:X  a  US   T   S:X  a  US   T   US   U   -  nUS-  nSUS   U   S-  -  US   U   -  U-  nUR                  (       az  USU-  SU-  SU-  -
  [        UU-  5      -  [        [        U5      [        U5      -  5      -  -   S[        [        5      -  [        U5      -  [        U5      -  -
  -  n[!        S 5        G
OUS   T   S:X  a  US   U   [        R                  :X  a  US   T   [        R                  * :X  a  US   U   S:X  a  US   T   S:X  a  US   T   US   U   -  nSUS   U   S-  -  [        US   U   5      -  U-  nUR                  (       a_  US[        [        5      -  [        U5      -  SU-  U-  [        US-  U-  5      -  [        U[        U5      -  5      -  -
  -  n[!        S!5        G	OUS   T   S:X  a  US   U   [        R                  :X  a  US   T   [        R                  * :X  a  US   U   S:X  a  US   T   S:X  a  US   T   nU[        US   U   5      -  US   U   -  nUSUS-  -  U-  S-   U-  [        US-  U-  5      -  [        U[        U5      -  5      -  S[        [        5      -  U-  U[        S5      S-  -  -  -
  -  n[!        S"5        GOUS   T   S:X  a  US   U   S:X  a  US   T   [        R                  * :X  a  US   U   S:X  a  US   T   US   U   -  nUS   T   US   U   -  nU[        US   U   5      -  US   U   -  nUS[        UU-
  5      -  [        U* U-  5      -  [#        [        UU-
  5      [        U5      -  5      -  -  n[!        S#5        GO[        U5      S:X  Ga  [        U5      S:X  Ga  US   T   S:X  Ga|  US   U   S:X  Gao  US   T   S:X  Gab  US   U   [        R                  :X  GaG  US   T   [        R                  :X  Ga,  US   U   S:X  Ga  US   T   S:X  Ga  US   T   US   U   -  nUS-  nUS   T   * US   U   -  n[        US   U   5      US   U   -  US   U   -  UU-
  -  U-  nUR                  (       a  UR                  (       a  UU[        UU-  5      -  [        [        U5      [        U5      -  5      -  [        U5      [        U5      -  [        UU-  5      -  [        [        U5      [        U5      -  5      -  -   U[        UU-  5      -  -
  -  n[!        S$5        GORUS   T   S:X  a  US   U   S:X  a  US   T   S:X  a  US   T   S:X  a  US   U   [        R                  :X  a  US   T   S:X  a  US   U   [        R                  :X  a  US   T   US   U   -  nUS   T   US   U   -  nUU-   S:X  aZ  US   U   US   U   -  US   U   -  U-  nUS[        US-  U-  5      -  [        U[        U5      -  5      -  S-
  -  n[!        S%5        GO[US   T   S:X  Ga  US   U   S:X  Ga  US   T   S:X  Ga  US   T   S:X  a  US   U   [        R                  :X  a  US   T   S:X  a  US   U   [        R                  :X  a  US   T   US   U   -  nUS   T   US   U   -  nUU-   S:X  a  US   U   S-  US   U   -  US   U   S-  -  U-  nUSS&US-  -  U-  [        US-  U-  5      -  [        U[        U5      -  5      -  -   S&[        [        5      -  U-  [        U5      -  -
  -  n[!        S'5        GO0US   T   S:X  GaB  US   U   S:X  Ga5  US   T   S:X  Ga(  US   T   S:X  Ga  US   U   [        R                  :X  Ga   US   T   S:X  a  US   U   [        R                  :X  a  US   T   US   U   -  nUS   T   US   U   -  nUU-   S:X  a  US   U   S-  US   U   -  US   U   S-  -  U-  nUSS&US-  -  US-  -  S&US-  -  U-  -   S-   -  [        US-  U-  5      -  [        U[        U5      -  5      -  S&[        [        5      -  U-  [        U5      -  SUS-  -  U-  S-   -  -
  S-
  -  n[!        S(5        GO[        U5      S:X  Ga  [        U5      S:X  Ga  US   T   S:X  Ga  US   T   S:X  Ga  US   U   S:X  a  US   T   S:X  a  US   U   S:X  a  US   T   [        R                  * :X  a  US   U   S:X  a  US   T   * US   U   -  nSUS   U   -  US   U   -  [        US   U   5      -  U-  nUR                  (       ar  UU[        S5      * S-  -  [        UU-  5      -  [#        [        U5      [        U5      -  5      -  SU-  [        [        5      -  [        U5      -  -
  -  n[!        S)5        GOUS   T   S:X  Ga  US   U   S:X  Ga  US   T   S:X  Gas  US   U   [        R                  :X  GaX  US   T   [        R                  * :X  Ga<  US   U   S:X  Ga/  US   T   S:X  Ga"  US   T   US   U   -  nUS-  nUS   T   * US   U   -  nSUS   U   -  US   U   -  [        US   U   5      -  [        U5      UU-
  -  -  nUR                  (       a  UR                  (       a  U[        U5      [        UU-  5      -  [        [        U5      [        U5      -  5      -  [        U5      [        UU-  5      -  [#        [        U5      [        U5      -  5      -  -   [        U5      [        UU-  5      -  -
  -  n[!        S*5        Uc  g['        U5      U-  U4$ s  sn	f )+r  r   r   r   r   r   Nr   c                 &   > U T   U T   S:g  U T   4$ r   rr   r   r   r   s    rn   r   -_inverse_laplace_irrational.<locals>.<lambda>      1qtqy!A$(?rq   r   c                 &   > U T   U T   S:g  U T   4$ r   rr   r.  s    rn   r   r/    r0  rq   ra   r   r   z     rule 5.3.4r   z     rule 5.3.10r   z     rule 5.3.13r         z     rule 5.3.16z     rule 5.3.35/44z     rule 5.3.14z     rule 5.3.22z     rule 5.3.1z     rule 5.3.5z     rule 5.3.7z     rule 5.3.8z     rule 5.3.11z     rule 5.3.12z     rule 5.3.15z     rule 5.3.23z     rule 5.3.6z     rule 5.3.17   z     rule 5.3.18z     rule 5.3.19z     rule 5.3.2z     rule 5.3.9)r    r   r   as_ordered_factorsr   r%  r   r'  r  sortedr:  r  r/   r   r'   r=   rv   r<   r7   r;   )r   r|   r   r  r   r   rl   r  far   r  	constantszerospolesrestr*  r   k_a_sqb_a_numr   r   s                        @@rn   _inverse_laplace_irrationalrB    s    	S1#AS1#AS1#AS1#AFI				 B*,	-"Q''1T6!8a-
 "B	-rzIEED7a<!I!W  LL!W  LLKK  5?@E5?@E
4yA~
5zQ3u:?8A;"q!!6q!U1Xa[(B58A;y(B~~tBxKQ'rE#b!eAg,&tBtAwJ'778  ()1Xa[B58A;!&&#88A;uQx{*DqB58A;>!)+BAd2hJtBx/Q771R463r!t9,c$r(472B.CA.EFG H  )*1Xa[B58A;!&&#8q!U1Xa[(B58A;>!)+B~~$r(
BE!GAI.tAw61SQq\)1RU719Q;7RQZ8HHI J  )*1Xa[B58A;!&&#8q!U1Xa[(B58A;>!)+A-B~~1RU71a4<2q5
2145c"a%'lBRQZ()$r(
2q5(QqT!V4aAgaikBC D  )*1Xa[QVVG#aq(8eAhqk%(1+-.B4a$$Y.B'!RT*+F()	UqSZ1_ar!eAhqkQVV&;aqvv%%(1+*: q!BeAhqk"58A;.y8BAb!eGAqDL2q5*1,-c"a%'l:RQZ !#$T"X:b="a%'!)#<T!W#DE  %&ar!eAhqkQ&6aqvv%%(1+*: q!U1Xa[(Bq!U1Xa[(BeAhqk"58A;.y8BCAJtAw&tBx/RUAJ1"42;tAw#6718 8 9  %&	UqSZ1_ar!eAhqkQ&6aw&58A;!+;aq  (1+eAhqk)B4a$$U1Xa[0:B~~T"X+c"Q$i/DHT!W4D0EE()ar!eAhqkQ&658A;!;Kar!eAhqkQVV&; q!U1Xa[(B58A;uQx{*2-i7B~~Qs2q57|DDG,<<<=()ar!eAhqkQVV&;aw&58A;!+;aq  q!U1Xa[(BE!HQKU1Xa[ 1129<B~~CAaLbaj)99()a!uQw&58A;!+;aq U1Xa[B%6aqvv%
 q!U1Xa[(BE!HQK!A$q&)%(1+56r1u<YFB~~$r(
2d1g-c"a%'l447
;K.KKAMN ()ar!eAhqkQVV&;ar!eAhqkQ&6aq  8A;uQx{*DqB58A;>!%(1+-i7B"!AbD#bd)3Db$q'9I4JJJ$r(
48+DG34 5  )*ar!eAhqkQVV&;aw&58A;!+;aq  q!U1Xa[(B58A;>!$uQx{"33I=B~~$r(
47*"Qs2q57|+DDG,<<= >  )*ar!eAhqkQVV&;aw&58A;!+;aq  q!B4a,,U1Xa[8B2q51aBE!G,T"T!W*-==$r(
2a!A$q&k)*+F %&ar!eAhqkQ&6aw&58A;!+; q!U1Xa[(Bq!U1Xa[(B4a,,U1Xa[8B$r"u+c2#a%j(T"R%[a-@)AACF%&	UqSZ1_ar!eAhqkQ&6ar!eAhqkQVV&;aqvv%%(1+*:aq  8A;uQx{*DqB(1+eAhqk)BeAhqk"58A;.uQx{:BrEB9LBBNNs2a4yLd2htAw&6!77HT"X%c"Q$i/T"Xd1g5E0FFGs2a4yL!" ()ar!eAhqkQ&6aq U1Xa[B%6aqvv%%(1+*:aqvv% !HQKa+Eq!U1Xa[(B%x1}1Xa[q!,U1Xa[8Bc"a%'lN447
#33A57)*ar!eAhqkQ&6aq U1Xa[B%6aqvv%%(1+*:aqvv% !HQKa+Eq!U1Xa[(B%x1}1Xa[!^E!HQK/aQ>yH"a%	#b!eAg,.tBtAwJ/???d2hJrM$q')*+ )*ar!eAhqkQ&6aq U1Xa[B%6aqvv%%(1+*:aqvv% !HQKa+Eq!U1Xa[(B%x1}1Xa[!^E!HQK/aQ>yHqQwq!t|Ab!eGAI-a/0RU1W=DG$%%&tBxZ]47%:Ab!eGAIaK%HIIJKL )*	UqSZ1_ar!eAhqkQ&658A;!;Kar!eAhqkQ&6aw&58A;!+; (1+eAhqk)B58A;uQx{*4a+<<YFB~~!A$qMC1I-DHT!W4D0EEbDbM$q')*+ ()ar!eAhqkQ&6ar!eAhqkQVV&;aw&58A;!+;aq  8A;uQx{*DqB(1+eAhqk)B%(1+eAhqk)$uQx{*;;b2b5!#  BNNHSAY&tDHT!W,<'==HSAY&s48DG+;'<<=HSAY&'( ()~|F"I--Q	 
.s   %AZc                 D    [         /nU H  nU" XX#5      =nc  M  Us  $    gr  N)rB  r   r|   r   r  r  r  r   s          rn   !_inverse_laplace_early_prog_rulesrF    s2    
 ..Ja''A4H  rq   c                 l    [         [        [        [        [        /nU H  nU" XX#5      =nc  M  Us  $    grD  )r'  r)  r+  r%  rB  rE  s          rn   !_inverse_laplace_apply_prog_rulesrH    sB    
 ./J,.C-/J a''A4H  rq   c           	         U R                   (       a  g[        U SS9nUR                   (       a  [        XAX#SSS9$ [        U 5      nUR                   (       a  [        XAX#SSS9$ [        U 5      nUR                   (       a  [        XAX#SSS9$ U R	                  U5      (       a  U R                  U5      R                  5       nUR                   (       a  [        XAX#SSS9$ g)r  NFr  Tr"  )r  r   r$  r   r
  r  r  )r   r|   r   r  r   s        rn   _inverse_laplace_expandrJ    s    
 
yyrAxx)!Ut= 	=2Axx)!Ut= 	=r
Axx)!Ut= 	=	q!!HHQKxx)!Ut= 	=rq   c          
         [        S5      nU R                  U5      n[        R                  " U5      n/ n[        R
                  /n	U GH  n
U
R                  5       u  pUR                  U5      R                  5       nUS   nU Vs/ s H  oU-  PM	     nnUR                  U5      R                  5        Vs/ s H  oU-  PM	     nn[        U5      S:X  aK  [        U5      S-
  n[        U5       H,  nUS   [        UUUS   -
  5      -  nUR                  U5        M.     M  [        U5      S:X  a8  US   [        US   * U-  5      -  nUR                  [        U5      U-  5        GM   [        U5      S:X  Ga  US   S-  nUS   US-  -
  R                  5       n[        U5      S:X  a  [        R                   /U-   n[#        U5      u  nnUS:X  a"  UU-  USUU-  -
  -  -   [        U* U-  5      -  nOSnUR$                  (       a  U* nSn['        [)        US-  U-
  U5      R+                  5       5      S   n[-        U5      R/                  5       nU(       aM  U[        U* U-  5      -  [1        UU-  5      -  UUU-  -
  U-  [        U* U-  5      -  [3        UU-  5      -  -   nOLU[        U* U-  5      -  [5        UU-  5      -  UUU-  -
  U-  [        U* U-  5      -  [7        UU-  5      -  -   nUR                  [        U5      U-  5        GM  [9        XX#USS9u  nnUR                  U5        U	R                  U5        GM     [        U6 nU(       a  UR/                  SS	9nU[;        U	6 4$ s  snf s  snf )
r  x_r   ra   r   r   FTr"  r  )r   r  r   r&  r   r   r  r   rv  r:  	enumerater:   r'  r'   r;   r  r   tupler  r   rQ   r  r/   r   r)   r+   r2   r3   r$  rM   )r   r|   r   r  r   rL  r   r  r  r  r*  r   r   rI  dc_leadr   r<  r~  r   r   r   r   lr   hypb2bsr  r   rl   s                                 rn   _inverse_laplace_rationalrT  (  sB   
 
B
AMM!EG&&J$$&YYq\$$&Q%!#$Ai$!"1!8!8!:;!:Ai!:;r7a<B	Ar]aDAq1v..q! # 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HHHBNN2d#Q T ']Fe,3
###S %;s   M-7M2c          	        ^ [         R                  " U 5      n/ n/ nU GHu  n	U	R                  [        5      (       a2  U	R	                  TT* 5      R                  5       R	                  TT* 5      n	U	R                  TSS9u  pU(       a&  U	R                  T5      (       a  [        UTX#US9=n cD  [        UTU5      =n c3  [        UTX#5      =n c"  [        UTX#5      =n c  [        UTX#5      =n b  Oy[        U4S jUR                  [        5       5       5      (       a  [!        UTX#5      ["        R$                  4nO.['        UTX#US9=n b  O[!        UTX#5      ["        R$                  4nUu  pUR)                  X-  5        UR)                  U5        GMx     [        U6 nU(       a  UR+                  SS9n[-        U6 nUU4$ )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.
Fr  r	  c              3   D   >#    U  H  oR                  T5      v   M     g 7fr   r  )r   r  r   s     rn   r   -_inverse_laplace_transform.<locals>.<genexpr>  s     B,A52,Ar  r  )r   r&  r   r'   r   rS   r  r
  rT  r   rF  rJ  rH  r  r   r	   r  r   r   rc   r'  r   rM   )r   r   rk  r  r   r#  r  r  r  r*  r/  r   r   r  r  rl   r  s    `               rn   r$  r$  b  s    MM"EGJ88C== 99R"%..055b2#>D""2e"4t88<</r2x9 9 :!RDD72rII-aR??72rIIBAGGL,ABBB )B:AFFCA;r2x9 9AEF (B:AFFCA
qu#K N ']Fe,Z I9rq   c                   d    \ rS rSrSrSr\" S5      r\" S5      rS r	\
S 5       rS rS	 rS
 rSrg)r  i  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    Uc  [         R                  n[        R                  " XX#U40 UD6$ r   )r  _none_sentinelrG   __new__)r   r   r|   r   r  optss         rn   r\  InverseLaplaceTransform.__new__  s,    =+::E ((uEEErq   c                 N    U R                   S   nU[        R                  L a  S nU$ )Nr   )rj   r  r[  )r  r  s     rn   fundamental_plane)InverseLaplaceTransform.fundamental_plane  s(    		!+:::Erq   c                 0    [        XX0R                  40 UD6$ r   )rc   r`  )r  r   r|   r   r  s        rn   r  *InverseLaplaceTransform._compute_transform  s"    5!++6/46 	6rq   c                 8   U R                   R                  n[        [        X#-  5      U-  X$[        R
                  [        R                  -  -
  U[        R
                  [        R                  -  -   45      S[        R                  -  [        R
                  -  -  $ )Nr   )	__class___crE   r'   r   ImaginaryUnitr   Pi)r  r   r|   r   r   s        rn   r  $InverseLaplaceTransform._as_integral  ss    NNSXaZ!)C%C"#aooajj&@"@"B CqttVAOO#%	&rq   c           	      8   UR                  SS5      nUR                  SS5      n[        SU R                  U R                  U R                  45        U R                  nU R                  nU R                  nU R
                  n[        XdXWUSS9nU(       a  US   $ U$ )r  r  Tr   Fz[ILT doit] (%s, %s, %s)r"  r   )r  rX   r  r  r  r`  r$  )	r  r  r  rF   r   rk  r   r  r   s	            rn   r  InverseLaplaceTransform.doit  s     99Y-IIj%0	(4==+/+A+A+/+B+B+D 	E ##$$]]&&&B	dD Q4KHrq   rr   N)ri   r  r  r  r  r  r   r[  rf  r\  propertyr`  r  r  r  r  rr   rq   rn   r  r    sI     E6]N	sBF
  6&rq   r  c                 "  ^^^^ TR                  SS5      nTR                  SS5      n[        U [        5      (       a)  [        U S5      (       a  U R	                  UUUU4S j5      $ [        U TTT5      R                  SUS9u  pxU(       a  U$ Xx4$ )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  Tr   Fr  c                 "   > [        U TTT40 TD6$ r   )inverse_laplace_transform)Fijr  r  r|   r   s    rn   r   +inverse_laplace_transform.<locals>.<lambda>	  s    1#q!ULeLrq   r  )r  r   rN   r  r  r  r  )	r   r|   r   r  r  r  rF   r   r   s	    ````    rn   ro  ro    s    Z yyD)H		*e,I!Z  WQ%<%<{{LN 	N #1aE277	 8 +DA trq   c                    ^^^^^^^^^	^
 [        S[        T/S9u  mm	m
UUUUU4S jmU4S jmUU4S jmUU	U
UU4S jmU4S jmT" U 5      $ )zEFast inverse Laplace transform of rational function including RootSumza, b, nr   c                   > U R                  T5      (       d  U $ U R                  (       a  T" U 5      $ U R                  (       a  T" U 5      $ U R                  (       a  T" U 5      $ [	        U [
        5      (       a  T" U 5      $ [        er   )r   r  ru  ry   r   rT   NotImplementedError)e_ilt_add_ilt_mul_ilt_pow_ilt_rootsumr|   s    rn   _ilt#_fast_inverse_laplace.<locals>._ilt#	  se    uuQxxHXXA;XXA;XXA;7##?"%%rq   c                 J   > U R                   " [        TU R                  5      6 $ r   )rm   maprj   )ru  rz  s    rn   rv  '_fast_inverse_laplace.<locals>._ilt_add1	  s    vvs4())rq   c                 n   > U R                  T5      u  pUR                  (       a  [        eUT" U5      -  $ r   )r  ru  rt  )ru  r  r   rz  r|   s      rn   rw  '_fast_inverse_laplace.<locals>._ilt_mul4	  s1    &&q);;%%tDz!!rq   c                 $  > U R                  TT-  T-   T-  5      nUbm  UT   UT   UT   pCnUR                  (       a4  US:  a.  T	U* S-
  -  [        XC-  * T	-  5      -  X2* -  [        U* 5      -  -  $ US:X  a  [        XC-  * T	-  5      U-  $ [        er   )r   
is_Integerr'   r@   rt  )
ru  r   nmambmr   r   r   r|   r   s
        rn   rx  '_fast_inverse_laplace.<locals>._ilt_pow:	  s    1q1%q58U1XBB}}aB3q5z#hqj/12s75":3EFFQwRU8A:++!!rq   c                    > U R                   R                  nU R                   R                  u  n[        U R                  [        U[        T" U5      5      5      5      $ r   )funr   	variablesrT   polyr   rS   )ru  r   variablerz  s      rn   ry  +_fast_inverse_laplace.<locals>._ilt_rootsumD	  s@    uuzzUU__
qvvvhd0DEFFrq   )r   r    )ru  r|   r   rz  rv  rw  rx  ry  r   r   r   s    ``@@@@@@@@rn   _fast_inverse_laplacer  	  sI    iTA37GAq!& &*"" "G
 7Nrq   )Tr   )r  rg   rd   
sympy.corer   r   r   sympy.core.addr   sympy.core.cacher   sympy.core.exprr   sympy.core.functionr	   r
   r   r   r   r   r   r   r   r   sympy.core.mulr   r   sympy.core.relationalr   r   r   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.piecewiser0   r1   (sympy.functions.elementary.trigonometricr2   r3   r4   r5   sympy.functions.special.besselr6   r7   r8   r9   'sympy.functions.special.delta_functionsr:   r;   'sympy.functions.special.error_functionsr<   r=   r>   'sympy.functions.special.gamma_functionsr?   r@   rA   rB   -sympy.functions.special.singularity_functionsrC   sympy.integralsrD   rE   r	  rF   rG   rH   sympy.logic.boolalgrI   rJ   rK   rL   rM   sympy.matrices.matrixbaserN   sympy.polys.matrices.linsolverO   sympy.polys.polyerrorsrP   sympy.polys.polyrootsrQ   sympy.polys.polytoolsrR   sympy.polys.rationaltoolsrS   sympy.polys.rootoftoolsrT   sympy.utilities.exceptionsrU   rV   rW   sympy.utilities.miscrX   re   rs   rv   r   r   rb   r   r  r  r  r  r#  r+  r5  rg  ro  rs  r  r  r  r  r  r  r  r  rx  r  rc   r  r  r   r%  r'  r)  r+  rB  rF  rH  rJ  rT  r$  r  ro  r  rr   rq   rn   <module>r     s    
     $  & & & %< < < & 2 25 5 ; I I C C$ I I M M I A A, , M /: : E E 0 6 2 ' & . +I I '	<EXv 6 6 lL lL^    	X) 	X)v  * & &R  , ) )X  $  @ I' I'X ; ;@  8 / /d  8  "  4 , ,^9x*Z @$ @$F5( 5pNb M4 M4`   	% 	%P  8     >     ( w. w.t	 	 	    4 6$ 6$r 5 5pD/ DN:z*rq   