1 | initial version |
You should define the xi
as variables in a polynomial ring, not as elements of the symbolic ring:
sage: F = CyclotomicField(3)
sage: w = F.gen()
sage: R = PolynomialRing(F,3,'x') ; R
Multivariate Polynomial Ring in x0, x1, x2 over Cyclotomic Field of order 3 and degree 2
sage: R.inject_variables()
Defining x0, x1, x2
sage: s0 = x0 + x1 + x2
sage: s1 = x0 + x1*w + x2*w^2
sage: s2 = x0 + x1*w^2 + x2*w
sage: s1^3 + s2^3
2*x0^3 - 3*x0^2*x1 - 3*x0*x1^2 + 2*x1^3 - 3*x0^2*x2 + 12*x0*x1*x2 - 3*x1^2*x2 - 3*x0*x2^2 - 3*x1*x2^2 + 2*x2^3
2 | No.2 Revision |
You If you want to work on the symbolic ring (this is what you did with the way to define the variables xi
), you should ask for simplification:
sage: (s1^3 + s2^3).full_simplify()
2*x0^3 - 3*x0^2*x1 - 3*x0*x1^2 + 2*x1^3 - 3*(x0 + x1)*x2^2 + 2*x2^3 - 3*(x0^2 - 4*x0*x1 + x1^2)*x2
This works in this case, but you will never be sure how far will the simplification be done. Otherwise, you should define the xi
as variables in a well-defined polynomial ring, not as elements of the symbolic ring:
sage: F = CyclotomicField(3)
sage: w = F.gen()
sage: R = PolynomialRing(F,3,'x') ; R
Multivariate Polynomial Ring in x0, x1, x2 over Cyclotomic Field of order 3 and degree 2
sage: R.inject_variables()
Defining x0, x1, x2
sage: s0 = x0 + x1 + x2
sage: s1 = x0 + x1*w + x2*w^2
sage: s2 = x0 + x1*w^2 + x2*w
sage: s1^3 + s2^3
2*x0^3 - 3*x0^2*x1 - 3*x0*x1^2 + 2*x1^3 - 3*x0^2*x2 + 12*x0*x1*x2 - 3*x1^2*x2 - 3*x0*x2^2 - 3*x1*x2^2 + 2*x2^3
3 | No.3 Revision |
If you want to work on the symbolic ring (this is what you did with the way to define the variables xi
), you should ask for simplification:
sage: (s1^3 + s2^3).full_simplify()
2*x0^3 - 3*x0^2*x1 - 3*x0*x1^2 + 2*x1^3 - 3*(x0 + x1)*x2^2 + 2*x2^3 - 3*(x0^2 - 4*x0*x1 + x1^2)*x2
This works in this case, but you will never be sure how far will the simplification be done. Otherwise, you should define the xi
as variables indeterminates in a well-defined polynomial ring, not as elements of the symbolic ring:
sage: F = CyclotomicField(3)
sage: w = F.gen()
sage: R = PolynomialRing(F,3,'x') ; R
Multivariate Polynomial Ring in x0, x1, x2 over Cyclotomic Field of order 3 and degree 2
sage: R.inject_variables()
Defining x0, x1, x2
sage: s0 = x0 + x1 + x2
sage: s1 = x0 + x1*w + x2*w^2
sage: s2 = x0 + x1*w^2 + x2*w
sage: s1^3 + s2^3
2*x0^3 - 3*x0^2*x1 - 3*x0*x1^2 + 2*x1^3 - 3*x0^2*x2 + 12*x0*x1*x2 - 3*x1^2*x2 - 3*x0*x2^2 - 3*x1*x2^2 + 2*x2^3