Bill Allombert on Wed, 17 Mar 2010 11:25:18 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: How to access coefficients of multivariate polynomials in PARI


On Wed, Mar 17, 2010 at 12:27:15AM -0500, Phat Tran wrote:
> I want to evaluate this multivariate polynomials (1 + x + y)^5 mod (7, x^3 -
> 2, y^2 - 3) and below is the code in C.
> 
> GEN x = pol_x[fetch_user_var("x")];
> GEN y = pol_x[fetch_user_var("y")];
> GEN a = pol_x[fetch_user_var("a")];
> 
> a = gpowgs(gmodulo(gadd(x, gmodulo(gadd(y, gmodulss(1, 7)), gsubgs(gsqr(y),
> 3))), gsubgs(gpowgs(x, 3), 2)), 5);
> 
> Right now I can only print out the result as below:
> 
> Mod(Mod(Mod(4, 7)*y + Mod(4, 7), y^2 - 3)*x^2 + Mod(Mod(6, 7)*y + Mod(3, 7),
> y^2 - 3)*x + Mod(Mod(2, 7), y^2 - 3), x^3 - 2)
> 
> I wonder if there is a way to retrieve the coefficient of a term in this
> polynomial; for example I want to retrieve the coefficient of the term xy,
> which is 6 or Mod(6, 7).

First note that the quantitiy above is not a polynomial, this is a POLMOD.
Let
z = Mod(Mod(Mod(4, 7)*y + Mod(4, 7), y^2 - 3)*x^2 + Mod(Mod(6, 7)*y + Mod(3, 7), y^2 - 3)*x + Mod(Mod(2, 7), y^2 - 3), x^3 - 2)

To recover the underlying polynomial, you can do:
P=lift(lift(z))
To recover the coefficient of degree a in x and b in y do
polcoeff(polcoeff(P,a),b))

So you can do 

P=lift(lift(z));
polcoeff(polcoeff(P,1),1)
%11 = Mod(6, 7)

Cheers,
Bill.