@@ -2295,12 +2295,8 @@ cdef class NumberFieldElement(FieldElement):
2295
2295
sage: (1+sqrt2)^-1
2296
2296
sqrt2 - 1
2297
2297
2298
- If the exponent is not integral, attempt this operation in the NumberField:
2299
-
2300
- sage: K(2)^(1/2)
2301
- sqrt2
2302
-
2303
- If this fails, perform this operation in the symbolic ring::
2298
+ If the exponent is not integral, perform this operation in
2299
+ the symbolic ring::
2304
2300
2305
2301
sage: sqrt2^(1/5)
2306
2302
2^(1/10)
@@ -2332,39 +2328,30 @@ cdef class NumberFieldElement(FieldElement):
2332
2328
"""
2333
2329
if (isinstance (base, NumberFieldElement) and
2334
2330
(isinstance (exp, Integer) or type (exp) is int or exp in ZZ)):
2335
- return generic_power_c(base, exp)
2336
-
2337
- if (isinstance (base, NumberFieldElement) and exp in QQ):
2338
- qqexp= QQ(exp)
2339
- n = qqexp.numerator()
2340
- d = qqexp.denominator()
2341
- try :
2342
- return base.nth_root(d)** n
2343
- except ValueError :
2344
- pass
2345
-
2346
- cbase, cexp = canonical_coercion(base, exp)
2347
- if not isinstance (cbase, NumberFieldElement):
2348
- return cbase ** cexp
2349
- # Return a symbolic expression.
2350
- # We use the hold=True keyword argument to prevent the
2351
- # symbolics library from trying to simplify this expression
2352
- # again. This would lead to infinite loops otherwise.
2353
- from sage.symbolic.ring import SR
2354
- try :
2355
- res = QQ(base)** QQ(exp)
2356
- except TypeError :
2357
- pass
2331
+ return generic_power(base, exp)
2358
2332
else :
2359
- if res.parent() is not SR:
2360
- return parent(cbase)(res)
2361
- return res
2362
- sbase = SR(base)
2363
- if sbase.operator() is operator.pow:
2364
- nbase, pexp = sbase.operands()
2365
- return nbase.power(pexp * exp, hold = True )
2366
- else :
2367
- return sbase.power(exp, hold = True )
2333
+ cbase, cexp = canonical_coercion(base, exp)
2334
+ if not isinstance (cbase, NumberFieldElement):
2335
+ return cbase ** cexp
2336
+ # Return a symbolic expression.
2337
+ # We use the hold=True keyword argument to prevent the
2338
+ # symbolics library from trying to simplify this expression
2339
+ # again. This would lead to infinite loops otherwise.
2340
+ from sage.symbolic.ring import SR
2341
+ try :
2342
+ res = QQ(base)** QQ(exp)
2343
+ except TypeError :
2344
+ pass
2345
+ else :
2346
+ if res.parent() is not SR:
2347
+ return parent(cbase)(res)
2348
+ return res
2349
+ sbase = SR(base)
2350
+ if sbase.operator() is operator.pow:
2351
+ nbase, pexp = sbase.operands()
2352
+ return nbase.power(pexp * exp, hold = True )
2353
+ else :
2354
+ return sbase.power(exp, hold = True )
2368
2355
2369
2356
cdef void _reduce_c_(self ):
2370
2357
"""
0 commit comments