RFC: extracting coefficients of a multivariate polynomial



try something like this


zz:rat((1+x+y)^5); 
for i:0 thru 5 do (h:ratcoef(zz,x,i),for j:0 thru 5 do
c[i,j]:ratcoef(h,y,j));

If you have only polynomials, doing poly:rat(poly)  once should do it all.



> -----Original Message-----
> From: maxima-bounces at math.utexas.edu 
> [mailto:maxima-bounces at math.utexas.edu] On Behalf Of andre maute
> Sent: Thursday, April 24, 2008 10:29 AM
> To: maxima at math.utexas.edu
> Subject: RFC: extracting coefficients of a 
> multivariate polynomial
> 
> Hi all,
> 
> I have to extract the coefficients of a multivariate polynomial.
> The monomials appearing in the multivariate polynomial are given.
> 
> For now I'm using the following function,
> which is also the bottleneck of my application.
> 
> ---------------------------------------------------------------
> display2d : false;
> 
> v : [x,y];
> exps : [[0,2], [0,0], [1,1], [0,1], [1,0], [2,0]];
> poly : a00 + a10*x + a01*y + a20*x^2 + a11*x*y + a02*y^2;
> 
> my_coeff(v,exps,poly) := block(
> 
>         [c,k,l,h],
> 
>         c : [],
>         for k : 1 thru length(exps) do block(
>                 h : poly,
>                 for l : 1 thru length(v) do block(
>                         if exps[k][l] # 0 then block(
>                                 h : coeff(h,v[l],exps[k][l])
>                         )
>                 ),
>                 for l : 1 thru length(v) do block(
>                         h : subst(0,v[l],h)
>                 ),
>                 h : ratsimp(h),
>                 c : append(c,[h])
>         ),
> 
>         return(c)
> 
> )$
> 
> my_coeff(v,exps,poly);
> ---------------------------------------------------------------------
> 
> Does someone know,
> if Maxima does have such a function, a potentially faster one?
> 
> The documentation of Maxima revealed nothing for me :-(
> 
> Kind Regards,
> Andre
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>