

@cacheit
@timeit
def _rewrite_single(f, x, recursive=True):
    '\n    Try to rewrite f as a sum of single G functions of the form\n    C*x**s*G(a*x**b), where b is a rational number and C is independent of x.\n    We guarantee that result.argument.as_coeff_mul(x) returns (a, (x**b,))\n    or (a, ()).\n    Returns a list of tuples (C, s, G) and a condition cond.\n    Returns None on failure.\n    '
    from sympy import polarify, unpolarify, oo, zoo, Tuple
    global _lookup_table
    if (not _lookup_table):
        _lookup_table = {
            
        }
        _create_lookup_table(_lookup_table)
    if isinstance(f, meijerg):
        from sympy import factor
        (coeff, m) = factor(f.argument, x).as_coeff_mul(x)
        if (len(m) > 1):
            return None
        m = m[0]
        if m.is_Pow:
            if ((m.base != x) or (not m.exp.is_Rational)):
                return None
        elif (m != x):
            return None
        return ([(1, 0, meijerg(f.an, f.aother, f.bm, f.bother, (coeff * m)))], True)
    f_ = f
    f = f.subs(x, z)
    t = _mytype(f, z)
    if (t in _lookup_table):
        l = _lookup_table[t]
        for (formula, terms, cond, hint) in l:
            subs = f.match(formula, old=True)
            if subs:
                subs_ = {
                    
                }
                for (fro, to) in subs.items():
                    subs_[fro] = unpolarify(polarify(to, lift=True), exponents_only=True)
                subs = subs_
                if (not isinstance(hint, bool)):
                    hint = hint.subs(subs)
                if (hint == False):
                    continue
                if (not isinstance(cond, (bool, BooleanAtom))):
                    cond = unpolarify(cond.subs(subs))
                if (_eval_cond(cond) == False):
                    continue
                if (not isinstance(terms, list)):
                    terms = terms(subs)
                res = []
                for (fac, g) in terms:
                    r1 = _get_coeff_exp(unpolarify(fac.subs(subs).subs(z, x), exponents_only=True), x)
                    g = g.subs(subs).subs(z, x)
                    if Tuple(*(r1 + (g,))).has(oo, zoo, (- oo)):
                        continue
                    g = meijerg(g.an, g.aother, g.bm, g.bother, unpolarify(g.argument, exponents_only=True))
                    res.append((r1 + (g,)))
                if res:
                    return (res, cond)
    if (not recursive):
        return None
    _debug('Trying recursive Mellin transform method.')
    from sympy.integrals.transforms import mellin_transform, inverse_mellin_transform, IntegralTransformError, MellinTransformStripError
    from sympy import oo, nan, zoo, simplify, cancel

    def my_imt(F, s, x, strip):
        ' Calling simplify() all the time is slow and not helpful, since\n            most of the time it only factors things in a way that has to be\n            un-done anyway. But sometimes it can remove apparent poles. '
        try:
            return inverse_mellin_transform(F, s, x, strip, as_meijerg=True, needeval=True)
        except MellinTransformStripError:
            return inverse_mellin_transform(simplify(cancel(expand(F))), s, x, strip, as_meijerg=True, needeval=True)
    f = f_
    s = _dummy('s', 'rewrite-single', f)

    def my_integrator(f, x):
        from sympy import Integral, hyperexpand
        r = _meijerint_definite_4(f, x, only_double=True)
        if (r is not None):
            (res, cond) = r
            res = _my_unpolarify(hyperexpand(res, rewrite='nonrepsmall'))
            return Piecewise((res, cond), (Integral(f, (x, 0, oo)), True))
        return Integral(f, (x, 0, oo))
    try:
        (F, strip, _) = mellin_transform(f, x, s, integrator=my_integrator, simplify=False, needeval=True)
        g = my_imt(F, s, x, strip)
    except IntegralTransformError:
        g = None
    if (g is None):
        a = _dummy_('a', 'rewrite-single')
        if ((a not in f.free_symbols) and _is_analytic(f, x)):
            try:
                (F, strip, _) = mellin_transform(f.subs(x, (a * x)), x, s, integrator=my_integrator, needeval=True, simplify=False)
                g = my_imt(F, s, x, strip).subs(a, 1)
            except IntegralTransformError:
                g = None
    if ((g is None) or g.has(oo, nan, zoo)):
        _debug('Recursive Mellin transform failed.')
        return None
    args = Add.make_args(g)
    res = []
    for f in args:
        (c, m) = f.as_coeff_mul(x)
        if (len(m) > 1):
            raise NotImplementedError('Unexpected form...')
        g = strip[0]
        (a, b) = _get_coeff_exp(g.argument, x)
        res += [(c, 0, meijerg(g.an, g.aother, g.bm, g.bother, (unpolarify(polarify(a, lift=True), exponents_only=True) * (x ** b))))]
    _debug('Recursive Mellin transform worked:', g)
    return (res, True)

dataset/ETHPy150Open sympy/sympy/sympy/integrals/meijerint.py _rewrite_single/VarMisuse@1084/1592 `m`->`strip`