(f, x, s_, integrator=_default_integrator, simplify=True)
return _simplify(F.subs(s, s_), simplify), (a, b), aux
Backend function to compute Mellin transforms.
Backend function to compute Mellin transforms.
Backend function to compute Mellin transforms .
def _mellin_transform(f, x, s_, integrator=_default_integrator, simplify=True):
    """ Backend function to compute Mellin transforms. """
    from sympy import re, Max, Min, count_ops
    # We use a fresh dummy, because assumptions on s might drop conditions on
    # convergence of the integral.
    s = _dummy('s', 'mellin-transform', f)
    F = integrator(x**(s - 1) * f, x)

    if not F.has(Integral):
        return _simplify(F.subs(s, s_), simplify), (-oo, oo), True

    if not F.is_Piecewise:
        raise IntegralTransformError('Mellin', f, 'could not compute integral')

    F, cond = F.args[0]
    if F.has(Integral):
        raise IntegralTransformError(
            'Mellin', f, 'integral in unexpected form')

    def process_conds(cond):
        """
        Turn ``cond`` into a strip (a, b), and auxiliary conditions.
        """
        a = -oo
        b = oo
        aux = True
        conds = conjuncts(to_cnf(cond))
        t = Dummy('t', real=True)
        for c in conds:
            a_ = oo
            b_ = -oo
            aux_ = []
            for d in disjuncts(c):
                d_ = d.replace(
                    re, lambda x: x.as_real_imag()[0]).subs(re(s), t)
                if not d.is_Relational or \
                    d.rel_op not in ('>', '>=', '<', '<=') \
                        or d_.has(s) or not d_.has(t):
                    aux_ += [d]
                    continue
                soln = _solve_inequality(d_, t)
                if not soln.is_Relational or \
                        soln.rel_op not in ('>', '>=', '<', '<='):
                    aux_ += [d]
                    continue
                if soln.lts == t:
                    b_ = Max(soln.gts, b_)
                else:
                    a_ = Min(soln.lts, a_)
            if a_ != oo and a_ != b:
                a = Max(a_, a)
            elif b_ != -oo and b_ != a:
                b = Min(b_, b)
            else:
                aux = And(aux, Or(*aux_))
        return a, b, aux

    conds = [process_conds(c) for c in disjuncts(cond)]
    conds = [x for x in conds if x[2] != False]
    conds.sort(key=lambda x: (x[0] - x[1], count_ops(x[2])))

    if not conds:
        raise IntegralTransformError('Mellin', f, 'no convergence found')

    a, b, aux = conds[0]
    return _simplify(F.subs(s, s_), simplify), (a, b), aux
def _mellin_transform ( f , x , s_ , integrator = _default_integrator , simplify = True ) : from sympy import re , Max , Min , count_ops # We use a fresh dummy, because assumptions on s might drop conditions on # convergence of the integral. s = _dummy ( 's' , 'mellin-transform' , f ) F = integrator ( x ** ( s - 1 ) * f , x ) if not F . has ( Integral ) : return _simplify ( F . subs ( s , s_ ) , simplify ) , ( - oo , oo ) , True if not F . is_Piecewise : raise IntegralTransformError ( 'Mellin' , f , 'could not compute integral' ) F , cond = F . args [ 0 ] if F . has ( Integral ) : raise IntegralTransformError ( 'Mellin' , f , 'integral in unexpected form' ) def process_conds ( cond ) : """
        Turn ``cond`` into a strip (a, b), and auxiliary conditions.
        """ a = - oo b = oo aux = True conds = conjuncts ( to_cnf ( cond ) ) t = Dummy ( 't' , real = True ) for c in conds : a_ = oo b_ = - oo aux_ = [ ] for d in disjuncts ( c ) : d_ = d . replace ( re , lambda x : x . as_real_imag ( ) [ 0 ] ) . subs ( re ( s ) , t ) if not d . is_Relational or d . rel_op not in ( '>' , '>=' , '<' , '<=' ) or d_ . has ( s ) or not d_ . has ( t ) : aux_ += [ d ] continue soln = _solve_inequality ( d_ , t ) if not soln . is_Relational or soln . rel_op not in ( '>' , '>=' , '<' , '<=' ) : aux_ += [ d ] continue if soln . lts == t : b_ = Max ( soln . gts , b_ ) else : a_ = Min ( soln . lts , a_ ) if a_ != oo and a_ != b : a = Max ( a_ , a ) elif b_ != - oo and b_ != a : b = Min ( b_ , b ) else : aux = And ( aux , Or ( * aux_ ) ) return a , b , aux conds = [ process_conds ( c ) for c in disjuncts ( cond ) ] conds = [ x for x in conds if x [ 2 ] != False ] conds . sort ( key = lambda x : ( x [ 0 ] - x [ 1 ] , count_ops ( x [ 2 ] ) ) ) if not conds : raise IntegralTransformError ( 'Mellin' , f , 'no convergence found' ) a , b , aux = conds [ 0 ] return _simplify ( F . subs ( s , s_ ) , simplify ) , ( a , b ) , aux