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]
 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 ] 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
computes the order of a at p .