# Multivariate Polynomials Sage

Sorry if I'm in the wrong Stackexchange (but sage is a math program...)

I'm computing something on multivariate polynomials: I have a primary variable $x$ and several other variables $a, b, c, \dots$. When I do an operation, I would like the output grouped together as powers of $x$, not in the very expanded form. Does anyone know how to do this?

Code example:

S = PolynomialRing(GF(4,'x'),4,"abcd")

c1=(a*b*d + a*b + c + d + 1)*x + (a*b*c*d + b*c*d + c*d + a + d)

c2=(a*b*c*d + a*b*d + b*c*d + a*b + a*c + a*d + a)*x + (a*b*c + a*c + b*d + c)

Output:

x*a*b*c*d + x*b*c*d + a*b*c*d + x*a*c + a*b*c + x*a*d + b*c*d + x*a + x*c + a*c + x*d + b*d + c*d + x + a + c + d

Output I would like:

x*(a*b*c*d + b*c*d + a*c + a*d + a + c + d + 1) + (a*b*c*d + a*b*c + b*c*d + a*c + b*d + c*d + a + c + d)

Thanks!

• I suppose that, using Sage, you could expand $cadd$ as a Taylor series built at $x=0$. I don't know Sage, but this would be my way. – Claude Leibovici Jul 23 '14 at 11:01