# Revision history [back]

### Collect polynomial in a different variable

I want to collect my polynomial in a different variable. How am I to do that. For example I have :

D=(a1*u^3+a2*u^2+a3*u+a4)x^4+(a5*u^3+a6*u^2+a7*u+a8)x^3+(a9*u^3+a10*u^2+a11*u+a12)x^2+(a13*u^3+a14*u^2+a15*u+a16)x


Now I want my D to be in the form where u is the main variable, so I will have :

D=(a1*x^4+a5*x^3+a9*x^2+a13*x)u^3+(...)u^2+(...)u


Maple do it with collect code. I try to search for a similar code in Sage but no luck.