1 | initial version |
This answer will rise an other question. I could produce an example in a small scene:
K.<b> = GF( 2^2 )
R.<w> = K[]
L = FractionField( R )
S.<x> = L[]
g = ( x + 1/w ) * ( x + 1/b )
h = x^2 + (w+b)/w/b * x + 1/w/b
print "Is g == h ?", g==h
print "g factorized is", g.factor()
print "h factorized is", h.factor()
print "Is g factorized == h factorized ?", g.factor() == h.factor()
print "g.factor().expand() is", g.factor().expand()
print "h.factor().expand() is", h.factor().expand()
And i've got this time:
Is g == h ? True
g factorized is (1/w) * (x + b + 1) * (w*x + 1)
h factorized is (1/w) * x * (w*x + 1)
Is g factorized == h factorized ? False
g.factor().expand() is x^2 + (((b + 1)*w + 1)/w)*x + (b + 1)/w
h.factor().expand() is x^2 + 1/w*x
So we immediately want to see...
sage: hf = h.factor()
sage: hf.__dict__
{'_Factorization__cr': False,
'_Factorization__unit': 1/w,
'_Factorization__universe': Univariate Polynomial Ring in x over Fraction Field
of Univariate Polynomial Ring in w
over Finite Field in b of size 2^2,
'_Factorization__x': [(x, 1), (w*x + 1, 1)]}
OK, this is strange. (As a joke... my next try was to replace w by s. Same type of error.) Of course, the straight way to so the things worked:
K.<b> = GF( 2^2 )
R.<w,x> = K[]
S = FractionField( R )
g = ( x + 1/w ) * ( x + 1/b )
h = x^2 + (w+b)/w/b * x + 1/w/b
print "Is g == h ?", g==h
print "g factorized is", g.factor()
print "h factorized is", h.factor()
print "Is g factorized == h factorized ?", g.factor() == h.factor()
print "g.factor().expand() is", g.factor().expand()
print "h.factor().expand() is", h.factor().expand()
Results:
Is g == h ? True
g factorized is w^-1 * (x + (b + 1)) * (w*x + 1)
h factorized is w^-1 * (x + (b + 1)) * (w*x + 1)
Is g factorized == h factorized ? True
g.factor().expand() is (w*x^2 + (b + 1)*w*x + x + (b + 1))/w
h.factor().expand() is (w*x^2 + (b + 1)*w*x + x + (b + 1))/w