Skip to content

Commit

Permalink
Trac #31040: roots() method of polynomials over QQ misses roots in p-…
Browse files Browse the repository at this point in the history
…adic extension fields

In !SageMath 9.3.beta3:
{{{
sage: R.<x> = QQ[]
sage: K.<a> = Qq(3).extension(x^2 + 1)
sage: (x^2 + 1).base_extend(K).roots()
[(a + O(3^20), 1),
 (2*a + 2*a*3 + 2*a*3^2 + 2*a*3^3 + 2*a*3^4 + 2*a*3^5 + 2*a*3^6 +
2*a*3^7 + 2*a*3^8 + 2*a*3^9 + 2*a*3^10 + 2*a*3^11 + 2*a*3^12 + 2*a*3^13
+ 2*a*3^14 + 2*a*3^15 + 2*a*3^16 + 2*a*3^17 + 2*a*3^18 + 2*a*3^19 +
O(3^20),
  1)]
sage: (x^2 + 1).roots(K)  # should return the same as above
[]
}}}
This can be fixed by only using the `factor_padic()` method when we are
looking for roots in '''Z''',,''p'',, or '''Q''',,''p'',,.

URL: https://trac.sagemath.org/31040
Reported by: pbruin
Ticket author(s): Peter Bruin
Reviewer(s): Marc Mezzarobba
  • Loading branch information
Release Manager committed Jan 10, 2021
2 parents be43d1f + 3dfbe69 commit f795800
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/sage/rings/polynomial/polynomial_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -7752,6 +7752,15 @@ cdef class Polynomial(CommutativeAlgebraElement):
sage: p = x^4 + (-5 - 2*t)*x^3 + (-2 + 10*t)*x^2 + (10 + 4*t)*x - 20*t
sage: p.roots()
[(5, 1), (2*t, 1)]
Check that :trac:`31040` is fixed::
sage: R.<x> = QQ[]
sage: K.<a> = Qq(3).extension(x^2 + 1)
sage: (x^2 + 1).roots(K)
[(a + O(3^20), 1),
(2*a + 2*a*3 + 2*a*3^2 + 2*a*3^3 + 2*a*3^4 + 2*a*3^5 + 2*a*3^6 + 2*a*3^7 + 2*a*3^8 + 2*a*3^9 + 2*a*3^10 + 2*a*3^11 + 2*a*3^12 + 2*a*3^13 + 2*a*3^14 + 2*a*3^15 + 2*a*3^16 + 2*a*3^17 + 2*a*3^18 + 2*a*3^19 + O(3^20),
1)]
"""
from sage.rings.finite_rings.finite_field_constructor import GF
K = self._parent.base_ring()
Expand Down Expand Up @@ -7950,7 +7959,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
real_field = RealField(L.prec())

return self.change_ring(real_field).roots(ring=L, multiplicities=multiplicities, algorithm=algorithm)
elif is_pAdicRing(L) or is_pAdicField(L):
elif (is_pAdicRing(L) or is_pAdicField(L)) and L.absolute_degree() == 1:
p = L.prime()
n = L.precision_cap()
try:
Expand Down

0 comments on commit f795800

Please sign in to comment.