1 | initial version |
A classical trick is not to work in the symbolic ring, but to see your variables as polynomial indeterminates:
sage: R.<a,b,c,d,e,f> = PolynomialRing(GF(2)) ; R
Multivariate Polynomial Ring in a, b, c, d, e, f over Finite Field of size 2
sage: m = matrix(R, [[a,b], [e,f]]) ; m
[a b]
[e f]
sage: m^3
[ a^3 + b*e*f a^2*b + b^2*e + a*b*f + b*f^2]
[a^2*e + b*e^2 + a*e*f + e*f^2 a*b*e + f^3]
2 | No.2 Revision |
A classical trick is not to work in the symbolic ring, but to see your variables as polynomial indeterminates:
sage: R.<a,b,c,d,e,f> = PolynomialRing(GF(2)) ; R
Multivariate Polynomial Ring in a, b, c, d, e, f over Finite Field of size 2
sage: m = matrix(R, [[a,b], [e,f]]) ; m
[a b]
[e f]
sage: m^3
[ a^3 + b*e*f a^2*b + b^2*e + a*b*f + b*f^2]
[a^2*e + b*e^2 + a*e*f + e*f^2 a*b*e + f^3]
Alternatively, if you want not only to have 2=0
as before, but also x^2=x
for your indeterminates:
sage: R.<a,b,c,d,e,f> = BooleanPolynomialRing() ; R
Boolean PolynomialRing in a, b, c, d, e, f
sage: m = matrix(R, [[a,b], [e,f]]) ; m
[a b]
[e f]
sage: m^3
[ a + b*e*f a*b*f + a*b + b*e + b*f]
[a*e*f + a*e + b*e + e*f a*b*e + f]