#NEWLINE# def _minpoly_pow( ex , pw , x , dom , mp = None ) : #NEWLINE# #INDENT# '\n    Returns ``minpoly(ex**pw, x)``\n\n    Parameters\n    ==========\n\n    ex : algebraic element\n    pw : rational number\n    x : indeterminate of the polynomial\n    dom: ground domain\n    mp : minimal polynomial of ``p``\n\n    Examples\n    ========\n\n    >>> from sympy import sqrt, QQ, Rational\n    >>> from sympy.polys.numberfields import _minpoly_pow, minpoly\n    >>> from sympy.abc import x, y\n    >>> p = sqrt(1 + sqrt(2))\n    >>> _minpoly_pow(p, 2, x, QQ)\n    x**2 - 2*x - 1\n    >>> minpoly(p**2, x)\n    x**2 - 2*x - 1\n    >>> _minpoly_pow(y, Rational(1, 3), x, QQ.frac_field(y))\n    x**3 - y\n    >>> minpoly(y**Rational(1, 3), x)\n    x**3 - y\n\n    ' #NEWLINE# pw = sympify ( pw ) #NEWLINE# if ( not mp ) : #NEWLINE# #INDENT# mp = _minpoly_compose ( ex , x , dom ) #NEWLINE# #UNINDENT# if ( not pw . is_rational ) : #NEWLINE# #INDENT# raise NotAlgebraic ( ( "%s doesn't seem to be an algebraic element" % ex ) ) #NEWLINE# #UNINDENT# if ( pw < 0 ) : #NEWLINE# #INDENT# if ( mp == x ) : #NEWLINE# #INDENT# raise ZeroDivisionError ( ( '%s is zero' % ex ) ) #NEWLINE# #UNINDENT# mp = _invertx ( mp , x ) #NEWLINE# if ( pw == ( - 1 ) ) : #NEWLINE# #INDENT# return mp #NEWLINE# #UNINDENT# pw = ( - pw ) #NEWLINE# ex = ( 1 / ex ) #NEWLINE# #UNINDENT# y = Dummy ( str ( x ) ) #NEWLINE# mp = mp . subs ( { #NEWLINE# #INDENT# x : y , #NEWLINE# #UNINDENT# } ) #NEWLINE# ( n , d ) = pw . as_numer_denom ( ) #NEWLINE# res = Poly ( resultant ( mp , ( ( x ** d ) - ( y ** n ) ) , gens = [ y ] ) , x , domain = dom ) #NEWLINE# ( _ , factors ) = res . factor_list ( ) #NEWLINE# res = _choose_factor ( factors , x , ( ex ** pw ) , dom ) #NEWLINE# return res . as_expr ( )