#18836: Make refine_embedding into a method of number fields instead of 
stand-alone
-------------------------------------+-------------------------------------
       Reporter:  cremona            |        Owner:
           Type:  enhancement        |       Status:  needs_work
       Priority:  minor              |    Milestone:  sage-6.8
      Component:  number fields      |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  John Cremona       |    Reviewers:  Vincent Delecroix
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/cremona/18836-refine_embedding   |  ee94ab4b6da7a2bdf20b6fc50eefb2dba9190494
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by cremona):

 This code was written while debugging the above.  It runs fine unless you
 comment out the two lines near the end.  I would say that this is a bug in
 QQbar.sqrt!
 {{{
 K.<i> = QuadraticField(-1)

 # define a low-precision embedding from K to CC:

 emb = K.embeddings(CC)[1]

 # extend this to the closest embedding into QQbar:

 old_gen = emb(K.gen())
 rr = K.defining_polynomial().roots(QQbar, multiplicities=False)
 diffs = [(CC(r)-old_gen).abs() for r in rr]
 new_gen = rr[diffs.index(min(diffs))]
 emb0 = K.hom([new_gen], check=False)

 # Take a polynomial with 3 roots in K:

 e1 = -4+i
 e2 = 1+i
 e3 = 3-2*i
 print("Original ei: %s with parent %s" % ([e1,e2,e3],parent(e1)))
 x = polygen(K)
 pol = (x-e1)*(x-e2)*(x-e3)

 # Find the roots again in QQbar:

 pol0 = PolynomialRing(QQbar,'x')([emb0(c) for c in list(pol)])
 e1, e2, e3 = pol0.roots(QQbar,multiplicities=False)
 print("Roots ei: %s with parent %s" % ([e1,e2,e3],parent(e1)))

 # Attempt to compute sqrt(e1-e2) from these:

 d = e1-e2
 print("d=%s with parent %s" % (d,d.parent()))
 # If the next 2 lines are commented out, an error is raised in the sqrt!
 s = d.imag().is_zero()
 print("d.imag().is_zero()=%s" % s)
 print("d=%s with parent %s" % (d,d.parent()))
 d = d.sqrt()
 print("d=%s" % d)
 }}}

--
Ticket URL: <http://trac.sagemath.org/ticket/18836#comment:8>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

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

Reply via email to