For comparison, on my computer..
test:ratsimp((x+1)^100)$
showtime:all$
coefficient_list(p,s) :=
block(
[n:floor(hipow(expand(p),s))],
map(lambda([u],coeff(expand(p),s,u)),makelist(i,i,0,n))
)$
coefficient_list(test,x);
takes 0.075 seconds
:lisp (defun $polylist(r)(cons '(mlist) (mapcar #'pdisrep(cdadr r))))
polylist(rat(test,x));
takes 0.0000 seconds.
RJF
On 4/19/2013 2:58 AM, Rupert Swarbrick wrote:
> Wilhelm Haager <wilhelm.haager at htlstp.ac.at> writes:
>
>> Probably a stupid remark; but doesn't meet the following
>> function all requirements? (same name as the corresponding function
>> in Mathematica)
>>
>> coefficient_list(p,s) :=
>> block(
>> [n:floor(hipow(p,s))],
>> p:expand(p),
>> map(lambda([u],coeff(p,s,u)),makelist(i,i,0,n))
>> )$
> Yes, but Stavros's original point is that this is rather inefficient if
> p is already in CRE form. That form stores the expression as basically a
> list of powers of s along with their corresponding coefficients. As it
> stands, the implementation of hipow starts by throwing away all that
> information (as does expand, for that matter)
>
> Rupert
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima