Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See #18836. This bug is holding up that (and also #20028). The following code creates an elemnt d of QQbar and tries to do d.sqrt(). It fails unless you call d.imag().is_zero() first. {{{ 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) }}} URL: http://trac.sagemath.org/20064 Reported by: cremona Ticket author(s): Nils Bruin Reviewer(s): John Cremona
- Loading branch information