collect coefficients



You can use the format package:

(%i1) (x^b+a*x^b+x)^2;
(%o1) (a*x^b+x^b+x)^2
(%i2) load(format)$
(%i3) format(%o1, %poly(x));
(%o3) (a+1)^2*x^(2*b)+2*(a+1)*x^(b+1)+x^2

Andrej



On Tue, Dec 23, 2008 at 3:30 PM, Eli Brosh <ebrosh1 at gmail.com> wrote:
> Hello,
> Is there a command in maxima, parallel to the
> collect(expression,variable) in maple ?
> It should present the expression as a generalized polynomial in powers
> of the variable.
> For example:
> collect(x^b+a*x^b+x)^2=
> (a + 1)^2*x^(2*b) + 2*(a + 1)*x^(b + 1) + x^2
>
> In sage (that uses maxima), the problem is solved by using Python programming:
> def collect(f,x):
>    return sum(c*x^i for c, i in f.coeffs(x))
>
>
> Is it possible to program something of this sort within maxima ?
>
> Thanks,
> Eli
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>