10.1 Polynomial powers

How do I compute modular polynomial powers in Sage?

To compute $ x^{2006} \pmod {x^3 + 7}$ in $ GF(97)[x]$ , we create the quotient ring $ GF(97)[x]/(x^3+7)$ , and compute $ x^{2006}$ in it. As a matter of Sage notation, we must distinguish between the $ x$ in $ GF(97)[x]$ and the corresponding element (which we denote by $ a$ ) in the quotient ring $ GF(97)[x]/(x^3+7)$ .

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.