Q:

How do I substitute a value into a polynomial in GAP?

Question:  How do I substitute a value into a polynomial in GAP?

So, if I start off with the following:
x:=Indeterminate(Integers,"x");
f:=x^2+3;

I have $f$ as the polynomial $x^2+3$ over the integers.  How can I find, say, $f(100)$?
There should be a simple one line answer, but I can't seem to find it in the help files.

A:

Please see '?Value':
gap> x:=Indeterminate(Integers,"x");;
gap> f:=x^2+3;;
gap> Value(f,100);
10003

Similarly, for multivariate polynomials do:
gap> x:=Indeterminate(Integers,"x");;
gap> y:=Indeterminate(Integers,"y");;
gap> f:=x*y+y+x^7;
x^7+x*y+y
gap> Value(f,[x,y],[5,7]);
78167

Remark (added later): furthermore, substitution is not limited to the elements of the ring of coefficients. One could, for example, substitute indeterminates like here
gap> x:=Indeterminate(Integers,"x");;
gap> y:=Indeterminate(Integers,"y");;
gap> z:=Indeterminate(Integers,"`");;
gap> f:=x*y+y+x^7+z;
x^7+x*y+y+z
gap> g:=Value(f,[x,y],[z^2,2]);
z^14+2*z^2+z+2
gap> Value(g,2);
16396

or matrices like here:
gap> m:=[ [ 0, -1, -1, 0, 0 ],
>         [ 0,  0,  0, 1, 0 ],
>         [ 0,  0,  0, 0, 1 ],
>         [ 1,  0,  0, 0, 0 ],
>         [ 0,  0,  1, 0, 0 ] ];;
gap> charpol:=CharacteristicPolynomial(m);
x^5-x^3+x^2-1
gap> Value(charpol,m);
[ [ 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0 ], 
  [ 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0 ] ]

