Hi, without exploring deeply, it looks like an unlucky collision with the shift by the particular QQbar_hash_offset=1/987654321*I+1/123456789 (which aims to avoid collisions for more usual algebraic numbers like 1 or 2).
sage: from sage.rings.qqbar import QQbar_hash_offset sage: QQbar_hash_offset += 1/987654321*QQbar(i) sage: %time (rho+QQbar_hash_offset).complex_exact(CIF) <very short> 0.02879966172165114? - 0.00795292895973858?*I sage: from sage.rings.qqbar import QQbar_hash_offset sage: %time (rho+QQbar_hash_offset).complex_exact(CIF) <very long> 0.02879966172165114? - 0.00795292997223858?*I Could you reproduce your issue with sufficiently enough other polynomials or is it just that one ? Ciao, Thierry On Tue, Oct 04, 2016 at 07:57:37PM +0800, Clemens Heuberger wrote: > Hashing of QQbar elements seems to be quite inefficient: > > sage: R.<x> = AA[] > sage: rho = QQbar.polynomial_root( > ....: x^5 - 1/3*x^4 + 1/30*x^3 - 1/600*x^2 + 1/24000*x - 1/2400000, > ....: CIF(RIF(0.02, 0.03), RIF(-0.009, -0.007))) > sage: %time hash(rho) > CPU times: user 14 s, sys: 36 ms, total: 14.1 s > Wall time: 14 s > -382033038487191199 > sage: %time hash(rho) > CPU times: user 9.18 s, sys: 32 ms, total: 9.21 s > Wall time: 9.12 s > -382033038487191199 > > It seems that the hashing code at some stage exactifies the rho.imag() (which > is > an algebraic number of degree 20). > > In qqbar.py, we have the comment > > # All of this effort to avoid exact computation is probably wasted, > # anyway... in almost all uses of hash codes, if the hash codes > # match, the next step is to compare for equality; and comparing > # for equality often requires exact computation. (If a==b, > > However, IMHO, the unfortunate thing is that rho.real() and rho.imag() are > exactified instead of rho itself (so involving higher degree numbers) and that > these results are then lost. > > Any thoughts? > > Regards, > > Clemens > > -- > 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. -- 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.