On Thu, Sep 3, 2009 at 9:15 AM, John H Palmieri <jhpalmier...@gmail.com>wrote:
> > On Sep 3, 12:36 am, William Stein <wst...@gmail.com> wrote: > > > > Sage has the Gaussian integers, and I'm sure the basic arithmetic and > > functionality is as good or better than Mathematica already. > > > > sage: R.<I> = ZZ[sqrt(-1)]; R > > Order in Number Field in I with defining polynomial x^2 + 1 > > Okay, this looks like a bug to me: > > ---------------------------------------------------------------------- > | Sage Version 4.1.1, Release Date: 2009-08-14 | > | Type notebook() for the GUI, and license() for information. | > ---------------------------------------------------------------------- > sage: I > I > sage: R.<I> = ZZ[sqrt(-1)] > sage: I > 1 > sage: I^2 > 1 > > Why is I equal to 1 all of a sudden? Same problem here: > > sage: reset() > sage: R.<a> = ZZ[sqrt(-5)] > sage: a > 1 > sage: R.1 > a > sage: R.1 == a > False > sage: (R.1)^2 > -5 > sage: R.inject_variables() > Defining a > sage: a > 1 > > > Ouch. > -- > it's actually not a bug; it's confusing (in this particular situation) documented behavior. It's clearly confusing. What is happening is that R = ZZ[blah, blahs] constructs the smallest *order* that contains blahs. These aren't in general monogenic (generated by one element), so R.gens() is just a ZZ basis for that order. So: sage: ZZ[sqrt(-5)] Order in Number Field in a with defining polynomial x^2 + 5 sage: ZZ[sqrt(-5)].gens() [1, a] sage: R.<a,b> = ZZ[sqrt(-5)] sage: b^2 -5 Obviously this is confusing in this special cases, as we were both confused. Number fields are monogenic so work as expected: sage: R.<I> = QQ[sqrt(-1)] sage: I^2 -1 sage: R.gens() (I,) William --~--~---------~--~----~------------~-------~--~----~ 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 URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---