coefficients of a polynomial in two or more variables
Subject: coefficients of a polynomial in two or more variables
From: Christian Stengg
Date: Wed, 02 Dec 2009 18:55:06 +0100
Dear list,
if I have a polynomial in the variable x, for instance
p:(a*x-b)*(3*x-2)+(c*x+d)*(1-2*x);
I can get the coefficients of the powers of x in the following way:
p_cre:rat(p,x);
c0:coeff(p_cre,x,0);
c1:coeff(p_cre,x,1);
c2:coeff(p_cre,x,2);
I would like to do the same for a polynomial in two (or more) variables
x and y, for instance for
q:(a*x-b*y)*(4*x-y+1)+(c*x+d)*(y-2);
If I use
q_cre:rat(q,y,x);
I get
4*a*x^2+((c-4*b-a)*y-2*c+a)*x+b*y^2+(d-b)*y-2*d.
But I would like to get the coefficients of the powers of x and y and of
the mixed term x*y. I would like it best, if I could write a function
that does this work automatically for any polynomial in two or more
variables and returns a list of the coefficients. Can someone give me a
hint how I could approach this problem?
Thanks for any help,
Christian