(e, x)
Limit e(x) for x-> oo
Limit e(x) for x-> oo
Limit e ( x ) for x - > oo
def limitinf(e, x):
    """Limit e(x) for x-> oo"""
    #rewrite e in terms of tractable functions only
    e = e.rewrite('tractable', deep=True)

    if not e.has(x):
        return e  # e is a constant
    if e.has(Order):
        e = e.expand().removeO()
    if not x.is_positive:
        # We make sure that x.is_positive is True so we
        # get all the correct mathematical bechavior from the expression.
        # We need a fresh variable.
        p = Dummy('p', positive=True, bounded=True)
        e = e.subs(x, p)
        x = p
    c0, e0 = mrv_leadterm(e, x)
    sig = sign(e0, x)
    if sig == 1:
        return S.Zero  # e0>0: lim f = 0
    elif sig == -1:  # e0<0: lim f = +-oo (the sign depends on the sign of c0)
        if c0.match(I*Wild("a", exclude=[I])):
            return c0*oo
        s = sign(c0, x)
        #the leading term shouldn't be 0:
        if s == 0:
            raise ValueError("Leading term should not be 0")
        return s*oo
    elif sig == 0:
        return limitinf(c0, x)
def limitinf ( e , x ) : #rewrite e in terms of tractable functions only e = e . rewrite ( 'tractable' , deep = True ) if not e . has ( x ) : return e # e is a constant if e . has ( Order ) : e = e . expand ( ) . removeO ( ) if not x . is_positive : # We make sure that x.is_positive is True so we # get all the correct mathematical bechavior from the expression. # We need a fresh variable. p = Dummy ( 'p' , positive = True , bounded = True ) e = e . subs ( x , p ) x = p c0 , e0 = mrv_leadterm ( e , x ) sig = sign ( e0 , x ) if sig == 1 : return S . Zero # e0>0: lim f = 0 elif sig == - 1 : # e0<0: lim f = +-oo (the sign depends on the sign of c0) if c0 . match ( I * Wild ( "a" , exclude = [ I ] ) ) : return c0 * oo s = sign ( c0 , x ) #the leading term shouldn't be 0: if s == 0 : raise ValueError ( "Leading term should not be 0" ) return s * oo elif sig == 0 : return limitinf ( c0 , x )