def _invert_monoms(p1):
 terms = list(p1.items())
 terms.sort()
 deg = p1.degree()
 R = p1.ring
 p = R.zero
 cv = p1.listcoeffs()
 mv = p1.listmonoms()
 for i in range(len(mv)):
  p[((deg - mv[i][0]),)] = cv[i]
 return p

def _invert_monoms ( p1 ) : terms = list ( p1 . items ( ) ) terms . sort ( ) deg = p1 . degree ( ) R = p1 . ring p = R . zero cv = p1 . listcoeffs ( ) mv = p1 . listmonoms ( ) for i in range ( len ( mv ) ) : p [ ( ( deg - mv [ i ] [ 0 ] ) , ) ] = cv [ i ] return p
compute x**n * p1 for a univariate polynomial p1 in x .