1 | initial version |
Your last construction is incorrect since IntegerModRing
does not have a name
parameter. If i understand correctly, you want to construct a polynomial ring in various indeterminates whose base ring is an integer mod ring. Here is how:
sage: xs = ['f1c1','f1c2','f1c3','f1c4','f1c5','f1c6','f2c1','f2c2','f2c3','f3c1','f3c2','f4c1','f5c1','f6c1']
Define the polynomial ring:
sage: R = PolynomialRing(IntegerModRing(3^7),names=xs)
sage: R
Multivariate Polynomial Ring in f1c1, f1c2, f1c3, f1c4, f1c5, f1c6, f2c1, f2c2, f2c3, f3c1, f3c2, f4c1, f5c1, f6c1 over Ring of integers modulo 2187
To let the Python names f1c1, f1c2, ... point to the corresponding indeterminates:
sage: R.inject_variables()
Defining f1c1, f1c2, f1c3, f1c4, f1c5, f1c6, f2c1, f2c2, f2c3, f3c1, f3c2, f4c1, f5c1, f6c1
Then, you can play :
sage: f1c3 * f1c6^2 + 3^4 * f2c3 + 3^3 * f3c1
f1c3*f1c6^2 + 81*f2c3 + 27*f3c1
sage: P = f1c3 * f1c6^2 + 3^4 * f2c3 + 3^3 * f3c1
sage: P
f1c3*f1c6^2 + 81*f2c3 + 27*f3c1
sage: P^2
f1c3^2*f1c6^4 + 162*f1c3*f1c6^2*f2c3 + 54*f1c3*f1c6^2*f3c1 + 729*f3c1^2
As you can see, the monomials (3^4 * f2c3)^2
and 3^4 * f2c3 * 3^3 * f3c1
have been cancelled.