Le 26/10/2018 à 16:04, John Cremona a écrit :
On Fri, 26 Oct 2018 at 13:07, 'Paul Mercat' via sage-devel <
sage-devel@googlegroups.com> wrote:

Hi !

I have a strange bug with NumberField: when I do

sage: pi = x^7 - 2*x^6 + x^3 - 2*x^2 + 2*x - 1
sage: b = pi.roots(ring=QQbar)[3][0]
sage: pi = b.minpoly()
sage: K = NumberField(pi, 'b', embedding=b)

it works well. But if I execute it a second time, then it never terminates!
Do you have a explanation and a correction to this problem ?


How strange.  The first 3 lines are fine the second time.  So is the number
field construction when you leave out the embedding.

When a number field is constructed it is cached so that a new construction
returns the same object, and not a copy, where possible.  In your case that
means checking that the embeddings are the same, which means checking that
two elements of QQbar are the same.  That can be expensive.

If you do
b1 = pi.roots(ring=QQbar)[3][0]
b2 = pi.roots(ring=QQbar)[3][0]

and then

b1==b2

it also takes ages.  I cannot remember the algorithm here but it does not
look optimal;   it may be working effectively in a field of degree 7*6 or
possibly 7!.  I note that

d=b1-b2
d==0

yields True immediately.

There is a shortcut for this kind of issues in qqbar.py
implemented with the function (line 2158)

  def cmp_elements_with_same_minpoly(a, b, p)

Apparently this is avoided in the present situation...

Vincent

--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to