0
$\begingroup$

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)

cadd = c1 + c2

print(cadd)

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!

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Claude Leibovici Jul 23 '14 at 11:01
0
$\begingroup$

Ok never mind, I found out - just in case anyone ever has a similar problem:

R. = PolynomialRing(GF(2), 4)

S. = PolynomialRing(R)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.