# Polynomial Ring bug?

I would like to ask, why following code ends with error:

R = PolynomialRing(GF(3),'x3,x5,x4,x7,x6')

U = PolynomialRing(GF(3), 'x2, x5, x4, x1, x0, x6')

f = U.gens() + U.gens()

g = R(f)

because when I remove x0 from the generators, it works fine.

R = PolynomialRing(GF(3),'x3,x5,x4,x7,x6')

U = PolynomialRing(GF(3), 'x2, x5, x4, x1, x6')

f = U.gens() + U.gens()

g = R(f)

Thanks for the answer, but there is still an open question. I have been working with this for a few days, and up untill this case, I had no trouble getting the same polynomial in a ring with fewer genarators, if the original polynomial contained only those. I tried and the followng code works fine, and it also fits your last case which according to you should raise an error, because U has more generators than R.

R = PolynomialRing(GF(3),'x5,x4,x7,x6')

U = PolynomialRing(GF(3), 'x2, x5, x4, x1, x6')

f = U.gens() + U.gens()

g = R(f)

edit retag close merge delete

Sort by » oldest newest most voted Executing g=R(f) calls the __call__ method for the ring R. You should read the documentation for this (by executing R.__call__?). In summary: given two polynomial rings U and R, if every generator of U is a generator for R, then R(f) does the obvious thing, mapping each generator of U to the generator of R with the same name. Otherwise, if U has at most as many generators as R, then map the ith generator of U to the ith generator of R. Otherwise, U must have more generators, so raise an error. Your case fits into this last situation.

more

I edited the question. There is a case that fits your last situation, and it does not raise an error. I would like to know the difference.

Your question is answered in R.__call__? docstring, did you read it?

I did, but I don't see it. Could you point me to the sentence that answers my question?