9.2 Polynomial rings

How do you construct a polynomial ring over a finite field in Sage? Here's an example:

sage: R = PolynomialRing(GF(97),'x')
sage: x = R.gen()
sage: f = x^2+7
sage: f in R
True

Here's an example using the Singular interface:

sage: R = singular.ring(97, '(a,b,c,d)', 'lp')
sage: I = singular.ideal(['a+b+c+d', 'ab+ad+bc+cd', 'abc+abd+acd+bcd', 'abcd-1'])
sage: R
//   characteristic : 97
//   number of vars : 4
//        block   1 : ordering lp
//                  : names    a b c d
//        block   2 : ordering C
sage: I
a+b+c+d,
a*b+a*d+b*c+c*d,
a*b*c+a*b*d+a*c*d+b*c*d,
a*b*c*d-1

Here is another approach using GAP:

sage: R = gap.new("PolynomialRing(GF(97), 4)"); R
PolynomialRing( GF(97), ["x_1", "x_2", "x_3", "x_4"] )
sage: I = R.IndeterminatesOfPolynomialRing(); I
[ x_1, x_2, x_3, x_4 ]
sage: vars = (I.name(), I.name(), I.name(), I.name())
sage: _ = gap.eval("x_0 := %s[1];; x_1 := %s[2];; x_2 := %s[3];;\ 
...   x_3 := %s[4];;"%vars)
sage: f = gap.new("x_1*x_2+x_3"); f
x_2*x_3+x_4
sage: f.Value(I,[1,1,1,1])
Z(97)^34

See About this document... for information on suggesting changes.