Ask Your Question

Revision history [back]

What you are telling Sage with the code snippet is a polynomial whose coefficients are in Z/3Z, but you want a symbolic expression where the variable x is integer and whose values are in Z/3Z, or in other words, modulo 3.

sage: assume(x, "integer")
sage: (x^3).mod(3)
x^3

That would be the most natural way to express it but, as you see, the result is wrong. The Pari-style alternative Mod function only accepts numeric input.

Note that with noninteger x the result wold not be x but -3*floor(x^3/3)+x^3.

I have opened a ticket at trac #17417.

What you are telling Sage with the code snippet is a polynomial whose coefficients are in Z/3Z, but you want a symbolic expression where the variable x is integer and whose values are in Z/3Z, or in other words, modulo 3.

sage: assume(x, "integer")
sage: (x^3).mod(3)
x^3

That would be the most natural way to express it but, as you see, the result is wrong. The Pari-style alternative Mod function only accepts numeric input.

Note that with noninteger x the result wold not be x but -3*floor(x^3/3)+x^3.

I have opened a EDIT: There is an old ticket at trac #17417#9935. that is a prerequisite for such simplifications.