# Revision history [back]

The variable x in SageMath is pre-defined to be a symbolic variable. That is why the right-hand side of

F1.<x> = GF(2**8, modulus=x^8 + x^6 + x^5 + x^4 + x^3 + x + 1)


is valid. This assignment statement however re-defines x to be the generator of F1. To be precise, the assignment statement above is equivalent to:

F1 = GF(2**8, modulus=x^8 + x^6 + x^5 + x^4 + x^3 + x + 1, name='x'); x = F1.gen()


Then, any future polynomial expression in x will be an element of F1; its normal form (which is automatically computed) will be written as a polynomial of degree less than 8. Hence, the right-hand side of the next statement

F2.<x> = GF(2**8, modulus=x^8 + x^4 + x^3 + x^2 + 1)


is not valid, because Sage will do its best to convert the given modulus to a polynomial over GF(2), and (because elements of F1 are written in normal form), the degree of that polynomial will be less than 8.

Your second variant works because x is not overwritten.

If you do not need a variable to hold the generator of your field, just write e.g.

 F1 = GF(2**8, modulus=x^8 + x^6 + x^5 + x^4 + x^3 + x + 1, name='a')


as above. But in general, be careful about naming your variables and not accidentally overwriting them. Also, it is better to explicitly define e.g. x = polygen(GF(2)) rather than depending on Sage to have the symbolic x.