3

given a polynomial $p(x,y)$ from $\mathbb Z[x,y]$. I want to substitute $x=1$ leaving $y$ as it is. The command Value(p,[1,y]) does not work. Can you give me a hint?

After that it gets a little more complicated. Let $$p(x,y)=x^6+y^6$$ After substituting $x=1$ we have $p(1,y)=1+y^6$. Given a natural number $j$. I want to find all expressions $y^j$ in $p$ and substitute these $y^j$ by $1$ and the others by $0$. In this case (and for $j=6$) we would get $1+1=2$. If $$p(x,y)=x^4y^2+x^2y^6$$ we should get $0+1=1$. Is there any way to do this?

Thanks for reading! edit: Well, it turns out I used the function Value wrong. The right code for my problem would be Value(p,[x,y],[1,y]). So my first question is solved.

Olexandr Konovalov
  • 7,002
  • 2
  • 34
  • 72

1 Answers1

4

I suggest to use the so called external representation of the polynomial. For example, for $$p(x,y)=x^4y^2+x^2y^6$$ we have:

gap> x:=Indeterminate(Rationals,"x");;
gap> y:=Indeterminate(Rationals,"y");;
gap> p:=x^4*y^2+x^2*y^6;
x^2*y^6+x^4*y^2
gap> ExtRepPolynomialRatFun(p);                 
[ [ 1, 4, 2, 2 ], 1, [ 1, 2, 2, 6 ], 1 ]

The format of the list returned by the last command is documented in the Section "The Defining Attributes of Rational Functions" of the GAP Reference Manual chapter "Polynomials and Rational Functions". It has lists representing monomials in odd positions and corresponding coefficient in even positions. A monomial is represented as a list of the form [inum,exp,inum,exp,...] where each inum is the number of an indeterminate and exp the corresponding exponent. It should be straightforward now to implement the calculation as described in the question - please do not hesitate to ask if you need further hints.

Olexandr Konovalov
  • 7,002
  • 2
  • 34
  • 72