@@ -10514,27 +10514,44 @@ cdef class Polynomial(CommutativePolynomial):
10514
10514
sage: (x^3 + x^2).radical() # needs sage.rings.finite_rings
10515
10515
x^2 + x
10516
10516
10517
- TESTS::
10517
+ TESTS:
10518
+
10519
+ Check that the method is sufficiently fast::
10518
10520
10519
10521
sage: R.<x> = GF(2^13)[]
10520
10522
sage: f = R.random_element(degree=1000)
10521
- sage: g = f.radical()
10523
+ sage: g = f.radical() # < 1s
10524
+
10525
+ Check that the method works as long as either :meth:`squarefree_decomposition`
10526
+ or :meth:`factor` is implemented::
10527
+
10528
+ sage: F.<x> = FunctionField(GF(2^10))
10529
+ sage: R.<y> = F[]
10530
+ sage: f = (y+1/(x-1))^2 * (y+x)
10531
+ sage: f.factor()
10532
+ (y + x) * (y + 1/(x + 1))^2
10533
+ sage: f.squarefree_decomposition()
10534
+ Traceback (most recent call last):
10535
+ ...
10536
+ NotImplementedError: square-free decomposition not implemented for this polynomial
10522
10537
"""
10523
10538
P = self ._parent
10524
10539
R = P.base_ring()
10525
10540
p = R.characteristic()
10526
- if p == 0 or p > self .degree():
10527
- if R.is_field():
10528
- return self // self .gcd(self .derivative())
10529
- else :
10530
- # Be careful with the content: return the
10531
- # radical of the content times the radical of
10532
- # (self/content)
10533
- content = self .content_ideal().gen()
10534
- self_1 = (self // content)
10535
- return (self_1 // self_1.gcd(self_1.derivative())) * content.radical()
10536
- else : # The above method is not always correct (see Issue 8736)
10537
- return self .squarefree_decomposition().radical_value()
10541
+ if 0 < p <= self .degree():
10542
+ # The method below is not always correct (see Issue 8736)
10543
+ try :
10544
+ return self .squarefree_decomposition().radical_value()
10545
+ except NotImplementedError :
10546
+ return self .factor().radical_value()
10547
+ if R.is_field():
10548
+ return self // self .gcd(self .derivative())
10549
+ # Be careful with the content: return the
10550
+ # radical of the content times the radical of
10551
+ # (self/content)
10552
+ content = self .content_ideal().gen()
10553
+ self_1 = (self // content)
10554
+ return (self_1 // self_1.gcd(self_1.derivative())) * content.radical()
10538
10555
10539
10556
def content_ideal (self ):
10540
10557
"""
0 commit comments