(e, z, z0, dir="+")
return r.rewrite('intractable', deep=True)
Compute the limit of e(z) at the point z0 using the Gruntz algorithm.

    z0 can be any expression, including oo and -oo.

    For dir="+" (default) it calculates the limit from the right
    (z->z0+) and for dir="-" the limit from the left (z->z0-). For infinite z0
    (oo or -oo), the dir argument doesn't matter.

    This algorithm is fully described in the module docstring in the gruntz.py
    file. It relies heavily on the series expansion. Most frequently, gruntz()
    is only used if the faster limit() function (which uses heuristics) fails.
Compute the limit of e(z) at the point z0 using the Gruntz algorithm.
Compute the limit of e ( z ) at the point z0 using the Gruntz algorithm .
def gruntz(e, z, z0, dir="+"):
    """
    Compute the limit of e(z) at the point z0 using the Gruntz algorithm.

    z0 can be any expression, including oo and -oo.

    For dir="+" (default) it calculates the limit from the right
    (z->z0+) and for dir="-" the limit from the left (z->z0-). For infinite z0
    (oo or -oo), the dir argument doesn't matter.

    This algorithm is fully described in the module docstring in the gruntz.py
    file. It relies heavily on the series expansion. Most frequently, gruntz()
    is only used if the faster limit() function (which uses heuristics) fails.
    """
    if not isinstance(z, Symbol):
        raise NotImplementedError("Second argument must be a Symbol")

    #convert all limits to the limit z->oo; sign of z is handled in limitinf
    r = None
    if z0 == oo:
        r = limitinf(e, z)
    elif z0 == -oo:
        r = limitinf(e.subs(z, -z), z)
    else:
        if dir == "-":
            e0 = e.subs(z, z0 - 1/z)
        elif dir == "+":
            e0 = e.subs(z, z0 + 1/z)
        else:
            raise NotImplementedError("dir must be '+' or '-'")
        r = limitinf(e0, z)

    # This is a bit of a heuristic for nice results... we always rewrite
    # tractable functions in terms of familiar intractable ones.
    # It might be nicer to rewrite the exactly to what they were initially,
    # but that would take some work to implement.
    return r.rewrite('intractable', deep=True)
def gruntz ( e , z , z0 , dir = "+" ) : if not isinstance ( z , Symbol ) : raise NotImplementedError ( "Second argument must be a Symbol" ) #convert all limits to the limit z->oo; sign of z is handled in limitinf r = None if z0 == oo : r = limitinf ( e , z ) elif z0 == - oo : r = limitinf ( e . subs ( z , - z ) , z ) else : if dir == "-" : e0 = e . subs ( z , z0 - 1 / z ) elif dir == "+" : e0 = e . subs ( z , z0 + 1 / z ) else : raise NotImplementedError ( "dir must be '+' or '-'" ) r = limitinf ( e0 , z ) # This is a bit of a heuristic for nice results... we always rewrite # tractable functions in terms of familiar intractable ones. # It might be nicer to rewrite the exactly to what they were initially, # but that would take some work to implement. return r . rewrite ( 'intractable' , deep = True )