[Maxima] RFC: extracting coefficients of a multivariate polynomial
fateman at cs.berkeley.edu
Fri Apr 25 09:29:18 CDT 2008
Here's another version. (I haven't run it...)
my_coeff7(v,exps,poly) := block(
for k in exps do block([h:rpoly],
for L in v do block([e: k],
h : ratcoeff(h,L,first(e)),
e : rest(e)),
c : cons(h,c)),
/* assumes v is a list of variables like [x,y,z,w,t],
assumes exps is a list of exponents like [ [1,3,5,8,5], [2,2,2,4,5] ...],
assumes poly is a polynomial in vars x,y,z,w,t and perhaps other
The reason this REVERSES ratvars is important.
ratcoef(h,x,2)$ takes 0.5 seconds
ratcoef(h,z,2)$ takes 0.0 seconds.
The first one has to go through all the terms in the polynomial and add up
those that are part of the (.....)x^2 term.
The second one has all that work done free, because the representation has
already added them up.
> -----Original Message-----
> From: maxima-bounces at math.utexas.edu
> [mailto:maxima-bounces at math.utexas.edu] On Behalf Of andre maute
> Sent: Friday, April 25, 2008 7:23 AM
> To: maxima at math.utexas.edu
> Subject: Re: [Maxima]RFC: extracting coefficients of a
> multivariate polynomial
> As Fateman pointed out,
> to a list in maxima needs O(n) operations,
> where n is the number of list entries.
> So I believe one of my problems came from a 'feature' of the
> maxima 5.13.0
> documentation. I'm a programmer with strong C++ background.
> I knew I did need a list, I knew I did need an insert
> function to lists.
> The first I found was append, you know the things children learn in
> elementary school, 'a b c ...' :-)
> But in C++, appending to list is an O(1) operation,
> There should really be a kind of warning in the documentation.
> Maxima mailing list
> Maxima at math.utexas.edu
More information about the Maxima