> < ^ Date: Mon, 11 Aug 2003 08:16:22 -0500 (CDT)
> < ^ From: Luc Teirlinck <teirllm@dms.auburn.edu >
> < ^ Subject: Re: polynomial question

gap-forum

David Ponce wrote:

```gap> R := PolynomialRing(Rationals,["x"]);
PolynomialRing(..., [ x ])
gap>
gap> f:=x^2+1;
1+x^2
gap> f in R;
false
```

return "true"? Am I using the "in" command wrong?

Where did you define the *variable* x? Your first line assigns a
*name* x to Indeterminate(Rationals,1). (If the above is your entire
GAP run. Otherwise it assigns the name "x" to
Indeterminate(Rationals, whichever number), see below.) The line
"f:=x^2+1;" should have produced an error, unless your excerpt is part
of a bigger GAP run, where x was assigned before.

Also, with `PolynomialRing', you have to be very careful with repeated
calls. See the GAP run below:

gap> R := PolynomialRing(Rationals,["x"]);
PolynomialRing(..., [ x ])
gap> f:=x^2+1;
Variable: 'x' must have a value

gap> var:=Indeterminate(Rationals,1);
x
gap> f:=var^2+1;
1+x^2
gap> f in R;
true
gap> R := PolynomialRing(Rationals,["x"]);
PolynomialRing(..., [ x ])
gap> f in R;
false
gap> var:=Indeterminate(Rationals,2);
x
gap> f:=var^2+1;
1+x^2
gap> f in R;
true
gap>

Sincerely,

Luc Teirlinck.