collecting terms



As soon as you use ratcoeff, your result will be fully expanded, e.g.

        ratcoeff( x * (2*y+1)^23, x, 1) => 8388608*y^23 + ...

I don't know if there is any built-in function which is half-way
between coeff and ratcoeff, expanding only as much as necessary to
extract the coefficients.

But back to the original question, perhaps all you want is rat(...,var), e.g.:

   t :  (x+1)^4 + a*(x+1)^2+b*(x+1)+c;

   rat(t,x) =>

      x^4+4*x^3+(a+6)*x^2+(b+2*a+4)*x+C+b+a+1

             -s