(a, p, t)
return n
Computes the order of a at p, with respect to t.

    For a, p in k[t], the order of a at p is defined as nu_p(a) = max({n
    in Z+ such that p**n|a}), where a != 0.  If a == 0, nu_p(a) = +oo.

    To compute the order at a rational function, a/b, use the fact that
    nu_p(a/b) == nu_p(a) - nu_p(b).
Computes the order of a at p, with respect to t.
Computes the order of a at p with respect to t .
def order_at(a, p, t):
    """
    Computes the order of a at p, with respect to t.

    For a, p in k[t], the order of a at p is defined as nu_p(a) = max({n
    in Z+ such that p**n|a}), where a != 0.  If a == 0, nu_p(a) = +oo.

    To compute the order at a rational function, a/b, use the fact that
    nu_p(a/b) == nu_p(a) - nu_p(b).
    """
    if a.is_zero:
        return oo
    if p == Poly(t, t):
        return a.as_poly(t).ET()[0][0]

    # Uses binary search for calculating the power. power_list collects the tuples
    # (p^k,k) where each k is some power of 2. After deciding the largest k
    # such that k is power of 2 and p^k|a the loop iteratively calculates
    # the actual power.
    power_list = []
    p1 = p
    r = a.rem(p1)
    tracks_power = 1
    while r.is_zero:
        power_list.append((p1,tracks_power))
        p1 = p1*p1
        tracks_power *= 2
        r = a.rem(p1)
    n = 0
    product = Poly(1, t)
    while len(power_list) != 0:
        final = power_list.pop()
        productf = product*final[0]
        r = a.rem(productf)
        if r.is_zero:
            n += final[1]
            product = productf
    return n
def order_at ( a , p , t ) : if a . is_zero : return oo if p == Poly ( t , t ) : return a . as_poly ( t ) . ET ( ) [ 0 ] [ 0 ] # Uses binary search for calculating the power. power_list collects the tuples # (p^k,k) where each k is some power of 2. After deciding the largest k # such that k is power of 2 and p^k|a the loop iteratively calculates # the actual power. power_list = [ ] p1 = p r = a . rem ( p1 ) tracks_power = 1 while r . is_zero : power_list . append ( ( p1 , tracks_power ) ) p1 = p1 * p1 tracks_power *= 2 r = a . rem ( p1 ) n = 0 product = Poly ( 1 , t ) while len ( power_list ) != 0 : final = power_list . pop ( ) productf = product * final [ 0 ] r = a . rem ( productf ) if r . is_zero : n += final [ 1 ] product = productf return n