Getting the coefficients of a polynomial



On 4/17/2013 1:02 PM, Anton Voropaev wrote:
> Maybe this is what you are looking for?
>
> (%i1) load("coeflist");
> (%o1) 
> "C:/PROGRA~1/MAXIMA~1.0-2/share/maxima/5.28.0-2/share/contrib/format/coeflist.lisp"
>
> (%i2) coeffs(x^3+a*x+1,x);
> (%o2) [[%poly,x],[1,0],[a,1],[1,3]]
>
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
It looks to me like the code favors versatility over efficiency.
RJF

?cadadr(rat(x^3+a*x+1,x)) returns 3,  not by accident.

here's a function that might  be of some use, but it has no checking.

do
r:rat(x^3+a*x+1,x);

:lisp (defun $polylist(r)(cons '(mlist) (mapcar #'pdisrep(cdadr r))))

polylist(r)  returns

[3,1,1,a,0,1]

meaning 1*x^3 + a*x^1+ 1*x^0

RJF