(f, x, rewrite=False, hints=None, mappings=None, retries=3,
                     degree_offset=0, unnecessary_permutations=None)
return Piecewise(*pairs)
A wrapper around the heurisch integration algorithm.

    This method takes the result from heurisch and checks for poles in the
    denominator. For each of these poles, the integral is reevaluated, and
    the final integration result is given in terms of a Piecewise.

    Examples
    ========

    >>> from sympy.core import symbols
    >>> from sympy.functions import cos
    >>> from sympy.integrals.heurisch import heurisch, heurisch_wrapper
    >>> n, x = symbols('n x')
    >>> heurisch(cos(n*x), x)
    sin(n*x)/n
    >>> heurisch_wrapper(cos(n*x), x)
    Piecewise((x, n == 0), (sin(n*x)/n, True))

    See Also
    ========

    heurisch
A wrapper around the heurisch integration algorithm.
A wrapper around the heurisch integration algorithm .
def heurisch_wrapper(f, x, rewrite=False, hints=None, mappings=None, retries=3,
                     degree_offset=0, unnecessary_permutations=None):
    """
    A wrapper around the heurisch integration algorithm.

    This method takes the result from heurisch and checks for poles in the
    denominator. For each of these poles, the integral is reevaluated, and
    the final integration result is given in terms of a Piecewise.

    Examples
    ========

    >>> from sympy.core import symbols
    >>> from sympy.functions import cos
    >>> from sympy.integrals.heurisch import heurisch, heurisch_wrapper
    >>> n, x = symbols('n x')
    >>> heurisch(cos(n*x), x)
    sin(n*x)/n
    >>> heurisch_wrapper(cos(n*x), x)
    Piecewise((x, n == 0), (sin(n*x)/n, True))

    See Also
    ========

    heurisch
    """
    f = sympify(f)
    if x not in f.free_symbols:
        return f*x

    res = heurisch(f, x, rewrite, hints, mappings, retries, degree_offset,
                   unnecessary_permutations)
    if not isinstance(res, Basic):
        return res
    # We consider each denominator in the expression, and try to find
    # cases where one or more symbolic denominator might be zero. The
    # conditions for these cases are stored in the list slns.
    slns = []
    for d in denoms(res):
        try:
            slns += solve(d, dict=True, exclude=(x,))
        except NotImplementedError:
            pass
    if not slns:
        return res
    slns = list(uniq(slns))
    # Remove the solutions corresponding to poles in the original expression.
    slns0 = []
    for d in denoms(f):
        try:
            slns0 += solve(d, dict=True, exclude=(x,))
        except NotImplementedError:
            pass
    slns = [s for s in slns if s not in slns0]
    if not slns:
        return res
    if len(slns) > 1:
        eqs = []
        for sub_dict in slns:
            eqs.extend([Eq(key, value) for key, value in sub_dict.items()])
        slns = solve(eqs, dict=True, exclude=(x,)) + slns
    # For each case listed in the list slns, we reevaluate the integral.
    pairs = []
    for sub_dict in slns:
        expr = heurisch(f.subs(sub_dict), x, rewrite, hints, mappings, retries,
                        degree_offset, unnecessary_permutations)
        cond = And(*[Eq(key, value) for key, value in sub_dict.items()])
        pairs.append((expr, cond))
    pairs.append((heurisch(f, x, rewrite, hints, mappings, retries,
                           degree_offset, unnecessary_permutations), True))
    return Piecewise(*pairs)
def heurisch_wrapper ( f , x , rewrite = False , hints = None , mappings = None , retries = 3 , degree_offset = 0 , unnecessary_permutations = None ) : f = sympify ( f ) if x not in f . free_symbols : return f * x res = heurisch ( f , x , rewrite , hints , mappings , retries , degree_offset , unnecessary_permutations ) if not isinstance ( res , Basic ) : return res # We consider each denominator in the expression, and try to find # cases where one or more symbolic denominator might be zero. The # conditions for these cases are stored in the list slns. slns = [ ] for d in denoms ( res ) : try : slns += solve ( d , dict = True , exclude = ( x , ) ) except NotImplementedError : pass if not slns : return res slns = list ( uniq ( slns ) ) # Remove the solutions corresponding to poles in the original expression. slns0 = [ ] for d in denoms ( f ) : try : slns0 += solve ( d , dict = True , exclude = ( x , ) ) except NotImplementedError : pass slns = [ s for s in slns if s not in slns0 ] if not slns : return res if len ( slns ) > 1 : eqs = [ ] for sub_dict in slns : eqs . extend ( [ Eq ( key , value ) for key , value in sub_dict . items ( ) ] ) slns = solve ( eqs , dict = True , exclude = ( x , ) ) + slns # For each case listed in the list slns, we reevaluate the integral. pairs = [ ] for sub_dict in slns : expr = heurisch ( f . subs ( sub_dict ) , x , rewrite , hints , mappings , retries , degree_offset , unnecessary_permutations ) cond = And ( * [ Eq ( key , value ) for key , value in sub_dict . items ( ) ] ) pairs . append ( ( expr , cond ) ) pairs . append ( ( heurisch ( f , x , rewrite , hints , mappings , retries , degree_offset , unnecessary_permutations ) , True ) ) return Piecewise ( * pairs )