RFC: extracting coefficients of a multivariate polynomial



Well, this is quite a different problem.  If you need all the coefficients,
why did you provide a list of the exponent vectors?
You computed a huge list that was not necessary.


Could you tell us what is it that you are doing with the coefficients? 

I am guessing that what you are doing could be done directly on the
polynomial, and the
extraction of the coefficients is unnecessary.

RJF
 

> -----Original Message-----
> From: maxima-bounces at math.utexas.edu 
> [mailto:maxima-bounces at math.utexas.edu] On Behalf Of andre maute
> Sent: Sunday, April 27, 2008 9:23 AM
> To: maxima at math.utexas.edu
> Subject: Re: [Maxima] RFC: extracting coefficients of a 
> multivariate polynomial
> 
> On Sunday 27 April 2008, S. Newhouse wrote:
> > andre maute wrote:
> > > 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 :-(
> >
> > Do you really need the whole list of coefficients, or just 
> a particular
> > one?
> 
> The whole list!
> 
> For the moment I'm satisfied, perhaps the degree set exps can be
> organized in a tree so you don't need every coeff/ratcoef 
> function call.
> 
> Andre
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>