(e, x)
return sign(c0, x)
Returns a sign of an expression e(x) for x->oo.

    ::

        e >  0 for x sufficiently large ...  1
        e == 0 for x sufficiently large ...  0
        e <  0 for x sufficiently large ... -1

    The result of this function is currently undefined if e changes sign
    arbitarily often for arbitrarily large x (e.g. sin(x)).

    Note that this returns zero only if e is *constantly* zero
    for x sufficiently large. [If e is constant, of course, this is just
    the same thing as the sign of e.]
Returns a sign of an expression e(x) for x->oo.
Returns a sign of an expression e ( x ) for x - > oo .
def sign(e, x):
    """
    Returns a sign of an expression e(x) for x->oo.

    ::

        e >  0 for x sufficiently large ...  1
        e == 0 for x sufficiently large ...  0
        e <  0 for x sufficiently large ... -1

    The result of this function is currently undefined if e changes sign
    arbitarily often for arbitrarily large x (e.g. sin(x)).

    Note that this returns zero only if e is *constantly* zero
    for x sufficiently large. [If e is constant, of course, this is just
    the same thing as the sign of e.]
    """
    from sympy import sign as _sign
    if not isinstance(e, Basic):
        raise TypeError("e should be an instance of Basic")

    if e.is_positive:
        return 1
    elif e.is_negative:
        return -1
    elif e.is_zero:
        return 0

    elif not e.has(x):
        return _sign(e)
    elif e == x:
        return 1
    elif e.is_Mul:
        a, b = e.as_two_terms()
        sa = sign(a, x)
        if not sa:
            return 0
        return sa * sign(b, x)
    elif e.func is exp:
        return 1
    elif e.is_Pow:
        s = sign(e.base, x)
        if s == 1:
            return 1
        if e.exp.is_Integer:
            return s**e.exp
    elif e.func is log:
        return sign(e.args[0] - 1, x)

    # if all else fails, do it the hard way
    c0, e0 = mrv_leadterm(e, x)
    return sign(c0, x)
def sign ( e , x ) : from sympy import sign as _sign if not isinstance ( e , Basic ) : raise TypeError ( "e should be an instance of Basic" ) if e . is_positive : return 1 elif e . is_negative : return - 1 elif e . is_zero : return 0 elif not e . has ( x ) : return _sign ( e ) elif e == x : return 1 elif e . is_Mul : a , b = e . as_two_terms ( ) sa = sign ( a , x ) if not sa : return 0 return sa * sign ( b , x ) elif e . func is exp : return 1 elif e . is_Pow : s = sign ( e . base , x ) if s == 1 : return 1 if e . exp . is_Integer : return s ** e . exp elif e . func is log : return sign ( e . args [ 0 ] - 1 , x ) # if all else fails, do it the hard way c0 , e0 = mrv_leadterm ( e , x ) return sign ( c0 , x )