Polynomials and other functions

Another (major) difference with MAPLE is that GAP does not like undefined variables. For example, in MAPLE, you can type (without declaring $ x$) >f:=x^2; then >diff(f,x); (resp, >int(f,x);) and you will get the derivative (resp., anti-derivavtive) of $ x^2$. However, GAP will complain:

gap> f:=x^2;
Variable: 'x' must have a value

Instead, you must declare $ x$ first, by typing something like

gap> R:=PolynomialRing(GF(7),["x"]);
<algebra-with-one over GF(7), with 1 generators>
gap> p:=UnivariatePolynomial(GF(7),[1,2,3,4],1);
1+2*x+3*x^2+4*x^3
gap> Derivative(p);
0*x^-1+2+6*x+12*x^2
gap> Value(p,1);
10
gap> Value(p,Z(7));
Z(7)^2
gap> q:=UnivariatePolynomial(GF(7),[Z(7),2*Z(7),3*Z(7),4*Z(7)],1);
Z(7)-x+Z(7)^2*x^2+Z(7)^5*x^3
gap> q in R;                                                      
true
gap> Derivative(q);
-Z(7)^0+Z(7)^4*x+x^2
This shows how to enter a polynomial, differentiate it, and evaluate it at a number. It's odd that GAP (unlike MAGMA) doesn't automatically reduce the coefficients of p mod 7, despite the fact that it was told that its coefficients belong to $ GF(7)=\mathbb{Z}/7\mathbb{Z}$.

Exercise 7.1.1   Using the Value and UnivariatePolynomial commands, compute $ x^100+x+1$ mod 31, where $ x=17$.



David Joyner 2007-09-03