(F, s, t_, plane, simplify=True)
return _simplify(f.subs(t, t_), simplify), cond
The backend function for inverse Laplace transforms.
The backend function for inverse Laplace transforms.
The backend function for inverse Laplace transforms .
def _inverse_laplace_transform(F, s, t_, plane, simplify=True):
    """ The backend function for inverse Laplace transforms. """
    from sympy import exp, Heaviside, log, expand_complex, Integral, Piecewise
    from sympy.integrals.meijerint import meijerint_inversion, _get_coeff_exp
    # There are two strategies we can try:
    # 1) Use inverse mellin transforms - related by a simple change of variables.
    # 2) Use the inversion integral.

    t = Dummy('t', real=True)

    def pw_simp(*args):
        """ Simplify a piecewise expression from hyperexpand. """
        # XXX we break modularity here!
        if len(args) != 3:
            return Piecewise(*args)
        arg = args[2].args[0].argument
        coeff, exponent = _get_coeff_exp(arg, t)
        e1 = args[0].args[0]
        e2 = args[1].args[0]
        return Heaviside(1/abs(coeff) - t**exponent)*e1 \
            + Heaviside(t**exponent - 1/abs(coeff))*e2

    try:
        f, cond = inverse_mellin_transform(F, s, exp(-t), (None, oo),
                                           needeval=True, noconds=False)
    except IntegralTransformError:
        f = None
    if f is None:
        f = meijerint_inversion(F, s, t)
        if f is None:
            raise IntegralTransformError('Inverse Laplace', f, '')
        if f.is_Piecewise:
            f, cond = f.args[0]
            if f.has(Integral):
                raise IntegralTransformError('Inverse Laplace', f,
                                     'inversion integral of unrecognised form.')
        else:
            cond = True
        f = f.replace(Piecewise, pw_simp)

    if f.is_Piecewise:
        # many of the functions called below can't work with piecewise
        # (b/c it has a bool in args)
        return f.subs(t, t_), cond

    u = Dummy('u')

    def simp_heaviside(arg):
        a = arg.subs(exp(-t), u)
        if a.has(t):
            return Heaviside(arg)
        rel = _solve_inequality(a > 0, u)
        if rel.lts == u:
            k = log(rel.gts)
            return Heaviside(t + k)
        else:
            k = log(rel.lts)
            return Heaviside(-(t + k))
    f = f.replace(Heaviside, simp_heaviside)

    def simp_exp(arg):
        return expand_complex(exp(arg))
    f = f.replace(exp, simp_exp)

    # TODO it would be nice to fix cosh and sinh ... simplify messes these
    #      exponentials up

    return _simplify(f.subs(t, t_), simplify), cond
def _inverse_laplace_transform ( F , s , t_ , plane , simplify = True ) : from sympy import exp , Heaviside , log , expand_complex , Integral , Piecewise from sympy . integrals . meijerint import meijerint_inversion , _get_coeff_exp # There are two strategies we can try: # 1) Use inverse mellin transforms - related by a simple change of variables. # 2) Use the inversion integral. t = Dummy ( 't' , real = True ) def pw_simp ( * args ) : """ Simplify a piecewise expression from hyperexpand. """ # XXX we break modularity here! if len ( args ) != 3 : return Piecewise ( * args ) arg = args [ 2 ] . args [ 0 ] . argument coeff , exponent = _get_coeff_exp ( arg , t ) e1 = args [ 0 ] . args [ 0 ] e2 = args [ 1 ] . args [ 0 ] return Heaviside ( 1 / abs ( coeff ) - t ** exponent ) * e1 + Heaviside ( t ** exponent - 1 / abs ( coeff ) ) * e2 try : f , cond = inverse_mellin_transform ( F , s , exp ( - t ) , ( None , oo ) , needeval = True , noconds = False ) except IntegralTransformError : f = None if f is None : f = meijerint_inversion ( F , s , t ) if f is None : raise IntegralTransformError ( 'Inverse Laplace' , f , '' ) if f . is_Piecewise : f , cond = f . args [ 0 ] if f . has ( Integral ) : raise IntegralTransformError ( 'Inverse Laplace' , f , 'inversion integral of unrecognised form.' ) else : cond = True f = f . replace ( Piecewise , pw_simp ) if f . is_Piecewise : # many of the functions called below can't work with piecewise # (b/c it has a bool in args) return f . subs ( t , t_ ) , cond u = Dummy ( 'u' ) def simp_heaviside ( arg ) : a = arg . subs ( exp ( - t ) , u ) if a . has ( t ) : return Heaviside ( arg ) rel = _solve_inequality ( a > 0 , u ) if rel . lts == u : k = log ( rel . gts ) return Heaviside ( t + k ) else : k = log ( rel . lts ) return Heaviside ( - ( t + k ) ) f = f . replace ( Heaviside , simp_heaviside ) def simp_exp ( arg ) : return expand_complex ( exp ( arg ) ) f = f . replace ( exp , simp_exp ) # TODO it would be nice to fix cosh and sinh ... simplify messes these #      exponentials up return _simplify ( f . subs ( t , t_ ) , simplify ) , cond