def _series_inversion1(p, x, prec):
 if rs_is_puiseux(p, x):
  return rs_puiseux(_series_inversion1, p, x, prec)
 R = p.ring
 zm = R.zero_monom
 c = p[zm]
 if (prec == int(prec)):
  prec = int(prec)
 if (zm not in p):
  raise ValueError('No constant term in series')
 if _has_constant_term((p - c), x):
  raise ValueError('p cannot contain a constant term depending on parameters')
 one = R(1)
 if (R.domain is EX):
  one = 1
 if (c != one):
  p1 = (R(1) / c)
 else:
  p1 = R(1)
 for precx in _giant_steps(prec):
  t = (1 - rs_mul(p1, p, x, precx))
  p1 = (p1 + rs_mul(p1, t, x, precx))
 return p1

def _series_inversion1 ( p , x , prec ) : if rs_is_puiseux ( p , x ) : return rs_puiseux ( _series_inversion1 , p , x , prec ) R = p . ring zm = R . zero_monom c = p [ zm ] if ( prec == int ( prec ) ) : prec = int ( prec ) if ( zm not in p ) : raise ValueError ( 'No constant term in series' ) if _has_constant_term ( ( p - c ) , x ) : raise ValueError ( 'p cannot contain a constant term depending on parameters' ) one = R ( 1 ) if ( R . domain is EX ) : one = 1 if ( c != one ) : p1 = ( R ( 1 ) / c ) else : p1 = R ( 1 ) for precx in _giant_steps ( prec ) : t = ( 1 - rs_mul ( p1 , p , x , precx ) ) p1 = ( p1 + rs_mul ( p1 , t , x , precx ) ) return p1
univariate series inversion 1/p modulo o .