How do I compute modular polynomial powers in Sage?
To compute
in
,
we create the quotient ring
, and compute
in it. As a matter of Sage notation,
we must distinguish between the
in
and the
corresponding element (which we denote by
) in the
quotient ring
.
sage: R = PolynomialRing(GF(97),'x') sage: x = R.gen() sage: S = R.quotient(x^3 + 7, 'a') sage: a = S.gen() sage: S Univariate Quotient Polynomial Ring in a over Finite Field of size 97 with modulus x^3 + 7 sage: a^2006 4*a^2
Another approach to this:
sage: R = PolynomialRing(GF(97),'x')
sage: x = R.gen()
sage: S = R.quotient(x^3 + 7, 'a')
sage: a = S.gen()
sage: a^20062006
80*a
sage: print gap.eval("R:= PolynomialRing( GF(97))")
PolynomialRing(..., [ x_1 ])
sage: print gap.eval("i:= IndeterminatesOfPolynomialRing(R)")
[ x_1 ]
sage: gap.eval("x:= i[1];; f:= x;;")
''
sage: print gap.eval("PowerMod( R, x, 20062006, x^3+7 );")
Z(97)^41*x_1
sage: print gap.eval("PowerMod( R, x, 20062006, x^3+7 );")
Z(97)^41*x_1
sage: print gap.eval("PowerMod( R, x, 2006200620062006, x^3+7 );")
Z(97)^4*x_1^2
sage: a^2006200620062006
43*a^2
sage: print gap.eval("PowerMod( R, x, 2006200620062006, x^3+7 );")
Z(97)^4*x_1^2
sage: print gap.eval("Int(Z(97)^4)")
43
See About this document... for information on suggesting changes.