def rs_integrate(p, x):
 R = p.ring
 p1 = R.zero
 n = R.gens.index(x)
 mn = ([0] * R.ngens)
 mn[n] = 1
 mn = tuple(mn)
 for expv in p:
  e = monomial_mul(expv, mn)
  p1[e] = (p[expv] / (expv[n] + 1))
 return p1

def rs_integrate ( p , x ) : R = p . ring p1 = R . zero n = R . gens . index ( x ) mn = ( [ 0 ] * R . ngens ) mn [ n ] = 1 mn = tuple ( mn ) for expv in p : e = monomial_mul ( expv , mn ) p1 [ e ] = ( p [ expv ] / ( expv [ n ] + 1 ) ) return p1
integrate p with respect to x .