Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

A possible approach is to define w, a, b etc. as polynomial variables, and define an ideal generated by cyclotomic_polynomial(3,w) and whatever other relations between the variables. Then you can reduce your polynomial with respect this ideal and access the coefficients of w^i via .coefficient({w:i}). For example

K.<w,a,b,c> = QQ[]
J = K.ideal( [cyclotomic_polynomial(3,w), a+b+c] )
f = ((a+b*w+c*w^2)^3).reduce(J)
print( ' + '.join(f'({f.coefficient({{w:i}})}*w^{i}' for i in range(f.degree(w)+1)) )

prints

(3b^3 - 9b^2c - 18bc^2 - 3c^3)w^0 + (6b^3 + 9b^2c - 9bc^2 - 6c^3)w^1

A possible approach is to define w, a, b etc. as polynomial variables, and define an ideal generated by cyclotomic_polynomial(3,w) and whatever other relations between the variables. Then you can reduce your polynomial with respect this ideal and access the coefficients of w^i via .coefficient({w:i}). For example

K.<w,a,b,c> = QQ[]
J = K.ideal( [cyclotomic_polynomial(3,w), a+b+c] )
f = ((a+b*w+c*w^2)^3).reduce(J)
print( ' + '.join(f'({f.coefficient({{w:i}})}*w^{i}' '.join(f'({f.coefficient({{w:i}})} * w^{i}' for i in range(f.degree(w)+1)) )

prints

(3b^3 - 9b^2c - 18bc^2 - 3c^3)c^3) * w^0 + (6b^3 + 9b^2b^2c - 9bbc^2 - 6c^3)c^3) * w^1

A possible approach is to define w, a, b etc. as polynomial variables, and define an ideal generated by cyclotomic_polynomial(3,w) and whatever other relations between the variables. Then you can reduce your polynomial with respect this ideal and access the coefficients of w^i via .coefficient({w:i}). For example

K.<w,a,b,c> = QQ[]
J = K.ideal( [cyclotomic_polynomial(3,w), a+b+c] )
f = ((a+b*w+c*w^2)^3).reduce(J)
print( ' + '.join(f'({f.coefficient({{w:i}})} * w^{i}' for i in range(f.degree(w)+1)) )

prints

(3b^3 (3*b^3 - 9b^2c 9*b^2*c - 18bc^2 18*b*c^2 - 3c^3) 3*c^3) * w^0 + (6b^3 (6*b^3 + 9b^2c 9*b^2*c - 9bc^2 9*b*c^2 - 6c^3) 6*c^3) * w^1

A possible approach is to define w, a, b etc. as polynomial variables, and define an ideal generated by cyclotomic_polynomial(3,w) and whatever other relations between the variables. Then you can reduce your polynomial with respect to this ideal ideal, and access the coefficients of w^i via .coefficient({w:i}). For example

K.<w,a,b,c> = QQ[]
J = K.ideal( [cyclotomic_polynomial(3,w), a+b+c] )
f = ((a+b*w+c*w^2)^3).reduce(J)
print( ' + '.join(f'({f.coefficient({{w:i}})} * w^{i}' for i in range(f.degree(w)+1)) )

prints

(3*b^3 - 9*b^2*c - 18*b*c^2 - 3*c^3) * w^0 + (6*b^3 + 9*b^2*c - 9*b*c^2 - 6*c^3) * w^1

A possible approach is to define w, a, b etc. as polynomial variables, and define an ideal generated by cyclotomic_polynomial(3,w) and whatever other relations between the variables. Then you can reduce your polynomial with respect to this ideal, and access the coefficients of w^i via .coefficient({w:i}). For example

K.<w,a,b,c> = QQ[]
J = K.ideal( [cyclotomic_polynomial(3,w), a+b+c] )
f = ((a+b*w+c*w^2)^3).reduce(J)
print( ' + '.join(f'({f.coefficient({{w:i}})} * w^{i}' for i in range(f.degree(w)+1)) )

prints

(3*b^3 - 9*b^2*c - 18*b*c^2 - 3*c^3) * w^0 + (6*b^3 + 9*b^2*c - 9*b*c^2 - 6*c^3) * w^1


Alternatively, you can define w over the quotient ring in a, b, c - like

K.<a_,b_,c_> = QQ[]
Q.<a,b,c> = K.quotient( [a_+b_+c_] )
E.<w> = Q[]
f = (a+b*w+c*w^2)^3 % cyclotomic_polynomial(3,w)
print(f)

which prints

(6*b^3 + 9*b^2*c - 9*b*c^2 - 6*c^3)*w + 3*b^3 - 9*b^2*c - 18*b*c^2 - 3*c^3