On Sun, Dec 19, 2010 at 9:39 PM, John H Palmieri <jhpalmier...@gmail.com> wrote: > On Dec 19, 7:01 pm, Alex Raichev <tortoise.s...@gmail.com> wrote: >> Hi all: >> >> I get differently formatted answers using factor() multiple times on >> the same polynomial. I wouldn't call it a bug, but it sure is >> annoying when doctesting. >> >> Alex >> >> ---------------------------------------------------------------------- >> | Sage Version 4.6, Release Date: 2010-10-30 | >> | Type notebook() for the GUI, and license() for information. | >> ---------------------------------------------------------------------- >> sage: R.<x,y>= PolynomialRing(QQ) >> sage: H= x^2*y^4 +y^6 +2*x^3*y^2 +2*x*y^4 -7*x^4 +7*x^2*y^2 +14*y^4 >> +6*x^3 +6*x*y^2 +47*x^2 +47*y^2 >> sage: for k in range(20): >> ....: print H.factor() >> ....: >> (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47) >> (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47) >> (x^2 + y^2) * (y^4 + 2*x*y^2 - 7*x^2 + 14*y^2 + 6*x + 47) >> (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47) >> (x^2 + y^2) * (y^4 + 2*x*y^2 - 7*x^2 + 14*y^2 + 6*x + 47) >> (x^2 + y^2) * (y^4 + 2*x*y^2 - 7*x^2 + 14*y^2 + 6*x + 47) >> (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47) >> (x^2 + y^2) * (y^4 + 2*x*y^2 - 7*x^2 + 14*y^2 + 6*x + 47) >> (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47) >> (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47) >> (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47) >> (x^2 + y^2) * (y^4 + 2*x*y^2 - 7*x^2 + 14*y^2 + 6*x + 47) >> (x^2 + y^2) * (y^4 + 2*x*y^2 - 7*x^2 + 14*y^2 + 6*x + 47) >> (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47) >> (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47) >> (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47) >> (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47) >> (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47) >> (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47) >> (x^2 + y^2) * (y^4 + 2*x*y^2 - 7*x^2 + 14*y^2 + 6*x + 47) > > Well, you could do > > sage: all([H==H.factor().prod() for k in range(20)]) > True > > to doctest it. (I'm assuming that the "prod" method just does basic > multiplication, and so its implementation has nothing to do with that > of "factor", so "H==H.factor().prod()" actually tests something > meaningful.)
+1 Probably worth noting the number of factors as well, e.g. sage: factorization = H.factor() sage: len(factorization) 2 sage: prod(factorization) == H True - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org