Skip to content

Commit

Permalink
Trac #18942: Weird bug in roots of a polynomial in relative number fi…
Browse files Browse the repository at this point in the history
…eld extension

I have no idea what is going on.

{{{
sage: F.<omega> = NumberField(x^2+x+1)
sage: xx = polygen(F)
sage: ABs = []
sage: ps = [p for p, _ in F(7).factor()]
sage: for mu in ps:
    K = F.extension(xx^3 - mu, 'alpha')
    print K.defining_polynomial().roots(K)
sage: for mu in ps:
    K = F.extension(xx^3 - mu, 'alpha')
    print K.defining_polynomial().roots(K)

[(alpha, 1), ((-omega - 1)*alpha, 1), (omega*alpha, 1)]
[(alpha, 1), (omega*alpha, 1), ((-omega - 1)*alpha, 1)]
[]
[(alpha, 1), (omega*alpha, 1), ((-omega - 1)*alpha, 1)]
}}}

So, that's weird. But it gets worse! First do this

{{{
sage: fbar = xx^3 - ps[0]
sage: Kbar = F.extension(fbar, 'alpha')
sage: fbar.roots(Kbar)
[]
}}}

Okay, but then do fbar.roots?? to see the source code, then press 'q' to
exit that, then

{{{
sage: fbar.roots(Kbar)
[(alpha, 1), ((-omega - 1)*alpha, 1), (omega*alpha, 1)]
}}}

Huh?

(I'm doing this is sage 6.7 on the cloud.)

URL: http://trac.sagemath.org/18942
Reported by: robharron
Ticket author(s): Kiran Kedlaya
Reviewer(s): Peter Bruin
  • Loading branch information
Release Manager authored and vbraun committed May 16, 2016
2 parents 7caa929 + 4c52f08 commit fcba86e
Showing 1 changed file with 57 additions and 3 deletions.
60 changes: 57 additions & 3 deletions src/sage/rings/number_field/number_field.py
Expand Up @@ -25,6 +25,8 @@
- Vincent Delecroix (2015-02): comparisons/floor/ceil using embeddings
- Kiran Kedlaya (2016-05): relative number fields hash based on relative polynomials
.. note::
Unlike in PARI/GP, class group computations *in Sage* do *not* by default
Expand Down Expand Up @@ -2719,6 +2721,19 @@ def __cmp__(self, other):
sage: M['x'] == L['x']
False
Similarly, two relative number fields which are isomorphic as absolute
fields, but which are not presented the same way, should not be equal (see
:trac:`18942`)::
sage: F.<omega> = NumberField(x^2 + x + 1)
sage: y = polygen(F)
sage: K = F.extension(y^3 + 3*omega + 2, 'alpha')
sage: L = F.extension(y^3 - 3*omega - 1, 'alpha')
sage: K == L
False
sage: K.is_isomorphic(L)
True
"""
if self is other:
Expand All @@ -2730,7 +2745,7 @@ def __cmp__(self, other):
c = cmp(self.variable_name(), other.variable_name())
if c: return c
# compare coefficients so that the polynomial variable does not count
c = cmp(list(self.__polynomial), list(other.__polynomial))
c = cmp(list(self.relative_polynomial()), list(other.relative_polynomial()))
if c: return c
# Now we compare the embeddings (if any).
f, g = self.coerce_embedding(), other.coerce_embedding()
Expand Down Expand Up @@ -2763,8 +2778,47 @@ def __hash__(self):
sage: hash(K) == hash(L)
True
"""
return hash((self.variable_name(), self.base_field(), tuple(self.__polynomial)))
The number fields ``K`` and ``L`` in the following example used to have
the same hash prior to :trac:`18942`::
sage: F.<omega> = NumberField(x^2 + x + 1)
sage: y = polygen(F)
sage: K = F.extension(y^3 + 3*omega + 2, 'alpha')
sage: L = F.extension(y^3 - 3*omega - 1, 'alpha')
sage: K == L
False
sage: K.is_isomorphic(L)
True
sage: hash(K) == hash(L)
False
This example illustrates the issue resolved in :trac:`18942`::
sage: F.<omega> = NumberField(x^2+x+1)
sage: xx = polygen(F)
sage: ps = [p for p, _ in F(7).factor()]
sage: for mu in ps:
....: K = F.extension(xx^3 - mu, 'alpha')
....: print(K.defining_polynomial().roots(K))
[(alpha, 1), ((-omega - 1)*alpha, 1), (omega*alpha, 1)]
[(alpha, 1), (omega*alpha, 1), ((-omega - 1)*alpha, 1)]
sage: for mu in ps:
....: K = F.extension(xx^3 - mu, 'alpha')
....: print(K.defining_polynomial().roots(K))
[(alpha, 1), ((-omega - 1)*alpha, 1), (omega*alpha, 1)]
[(alpha, 1), (omega*alpha, 1), ((-omega - 1)*alpha, 1)]
This example was suggested on sage-nt; see :trac:`18942`::
sage: G=DirichletGroup(80);
sage: for chi in G:
....: D=ModularSymbols(chi,2,-1).cuspidal_subspace().new_subspace().decomposition()
....: for f in D:
....: elt=f.q_eigenform(10,'alpha')[3];
....: assert(elt.is_integral())
"""
return hash((self.variable_name(), self.base_field(), tuple(self.relative_polynomial())))

def _ideal_class_(self, n=0):
"""
Expand Down

0 comments on commit fcba86e

Please sign in to comment.