def rs_series_inversion(p, x, prec):
 R = p.ring
 if (p == R.zero):
  raise ZeroDivisionError
 zm = R.zero_monom
 index = R.gens.index(x)
 m = min(p, key=(lambda k: k[index]))[index]
 if m:
  p = mul_xin(p, index, (- m))
  prec = (prec + m)
 if (zm not in p):
  raise NotImplementedError('No constant term in series')
 if _has_constant_term((p - p[zm]), x):
  raise NotImplementedError('p - p[0] must not have a constant term in the series variables')
 r = _series_inversion1(p, x, prec)
 if (m != 0):
  r = mul_xin(r, index, (- m))
 return r

def rs_series_inversion ( p , x , prec ) : R = p . ring if ( p == R . zero ) : raise ZeroDivisionError zm = R . zero_monom index = R . gens . index ( x ) m = min ( p , key = ( lambda k : k [ index ] ) ) [ index ] if m : p = mul_xin ( p , index , ( - m ) ) prec = ( prec + m ) if ( zm not in p ) : raise NotImplementedError ( 'No constant term in series' ) if _has_constant_term ( ( p - p [ zm ] ) , x ) : raise NotImplementedError ( 'p - p[0] must not have a constant term in the series variables' ) r = _series_inversion1 ( p , x , prec ) if ( m != 0 ) : r = mul_xin ( r , index , ( - m ) ) return r
multivariate series inversion 1/p modulo o .