On Dec 12, 2009, at 1:40 PM, Burcin Erocal wrote: > On Sat, 12 Dec 2009 19:12:38 +0100 > Burcin Erocal <bur...@erocal.org> wrote: > >> I can also reproduce this, on a 32-bit Debian Lenny box, after >> setting >> SAGE_FORTRAN to /usr/bin/gfortran and rebuilding from scratch. > > > On a build without the problem: > > sage: Q.<i> = NumberField(x^2+1) > sage: complex(i) > 0.99999999999999967j > sage: p = Q.defining_polynomial() > sage: cp = CDF['x'](p) > sage: cp.roots() > [(1.56125112838e-17 - 1.0*I, 1), (1.0*I, 1)] > sage: sorted(cp.roots()) > [(1.0*I, 1), (1.56125112838e-17 - 1.0*I, 1)] > > > Now with the problem: > > sage: Q.<i> = NumberField(x^2+1) > sage: complex(i) > (-2.8866882842426556e-18-0.99999999999999989j) > sage: p = Q.defining_polynomial() > sage: cp = CDF['x'](p) > sage: cp.roots() > [(-2.88668828424e-18 - 1.0*I, 1), (1.0*I, 1)] > sage: sorted(cp.roots()) > [(-2.88668828424e-18 - 1.0*I, 1), (1.0*I, 1)] > > > The default embedding just takes the first root in the sorted list. > AFAICT, we use numpy to compute the roots and that must be the > gfortran > connection. Though I still couldn't manage to break an existing build > just by reinstalling packages.
As these roots come in complex conjugate pairs, and we are sorting them in lexicographical order (real component first), it's always going to be extremely sensitive to numerical noise. Perhaps they should be sorted in some other way (e.g. by argument, or by always putting the roots in the upper half plane first) to choose a canonical "first" one. > Specifying an embedding while constructing the number field doesn't > seem to work. That's because complex() ignores the coercion machinery (which it probably shouldn't). The embeddings() sometimes puts the more "natural" embedding first in some cases, maybe we should do the same for real/complex embeddings when one is specified. sage: Q.<i> = NumberField(x^2+1, embedding=-CDF.0) sage: i + 1.0 1.00000000000000 - 1.00000000000000*I sage: complex(i) 0.99999999999999967j - Robert -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org