def _minpoly_pow(ex, pw, x, dom, mp=None):
 pw = sympify(pw)
 if (not mp):
  mp = _minpoly_compose(ex, x, dom)
 if (not pw.is_rational):
  raise NotAlgebraic(("%s doesn't seem to be an algebraic element" % ex))
 if (pw < 0):
  if (mp == x):
   raise ZeroDivisionError(('%s is zero' % ex))
  mp = _invertx(mp, x)
  if (pw == (-1)):
   return mp
  pw = (- pw)
  ex = (1 / ex)
 y = Dummy(str(x))
 mp = mp.subs({x: y})
 (n, d) = pw.as_numer_denom()
 res = Poly(resultant(mp, ((x ** d) - (y ** n)), gens=[y]), x, domain=dom)
 (_, factors) = res.factor_list()
 res = _choose_factor(factors, x, (ex ** pw), dom)
 return res.as_expr()

def _minpoly_pow ( ex , pw , x , dom , mp = None ) : pw = sympify ( pw ) if ( not mp ) : mp = _minpoly_compose ( ex , x , dom ) if ( not pw . is_rational ) : raise NotAlgebraic ( ( "%s doesn't seem to be an algebraic element" % ex ) ) if ( pw < 0 ) : if ( mp == x ) : raise ZeroDivisionError ( ( '%s is zero' % ex ) ) mp = _invertx ( mp , x ) if ( pw == ( - 1 ) ) : return mp pw = ( - pw ) ex = ( 1 / ex ) y = Dummy ( str ( x ) ) mp = mp . subs ( { x : y } ) ( n , d ) = pw . as_numer_denom ( ) res = Poly ( resultant ( mp , ( ( x ** d ) - ( y ** n ) ) , gens = [ y ] ) , x , domain = dom ) ( _ , factors ) = res . factor_list ( ) res = _choose_factor ( factors , x , ( ex ** pw ) , dom ) return res . as_expr ( )
returns minpoly parameters ex : algebraic element pw : rational number x : indeterminate of the polynomial dom: ground domain mp : minimal polynomial of p examples .