Revision history [back]

Your g is an expression in Sage's symbolic ring. To map it to a polynomial, use the polynomial method.

sage: a, b, c, m, k = 1, 1, 1, 1, 6
sage: w = exp((2*pi*I*m )/k)
sage: p = x^4 - 6*x^2 -x *(w^(a-c) + w^(c-a) + w^b + w^(-b) + w^(b-c) + w^(c-b) + w^a + w^(-a)) + (3 -w^c - w^(-c) - w^(a+b-c) - w^(-a-b+c) - w^(a-b) - w^(-a+b))
sage: g = real_part(p).simplify()
sage: q = g.polynomial(QQbar)
sage: q
x^4 - 6*x^2 - 6*x - 1
sage: q.parent()
Univariate Polynomial Ring in x over Algebraic Field


Your g is an expression in Sage's symbolic ring. To map it to a polynomial, use the polynomial method.

sage: a, b, c, m, k = 1, 1, 1, 1, 6
sage: w = exp((2*pi*I*m )/k)
exp(2*pi*I*m/k)
sage: p = x^4 - 6*x^2 -x *(w^(a-c) - x*(w^(a-c) + w^(c-a) + w^b + w^(-b) + w^(b-c) + w^(c-b) + w^a + w^(-a)) + (3 -w^c - w^c - w^(-c) - w^(a+b-c) - w^(-a-b+c) - w^(a-b) - w^(-a+b))
sage: g = real_part(p).simplify()
sage: q = g.polynomial(QQbar)
sage: q
x^4 - 6*x^2 - 6*x - 1
sage: q.parent()
Univariate Polynomial Ring in x over Algebraic Field


Your g is an expression in Sage's symbolic ring. To map it to a polynomial, use the polynomial method.ring.

sage: a, b, c, m, k = 1, 1, 1, 1, 6
sage: w = exp(2*pi*I*m/k)
sage: p = x^4 - 6*x^2 - x*(w^(a-c) + w^(c-a) + w^b + w^(-b) + w^(b-c) + w^(c-b) + w^a + w^(-a)) + (3 - w^c - w^(-c) - w^(a+b-c) - w^(-a-b+c) - w^(a-b) - w^(-a+b))
sage: g = real_part(p).simplify()
sage: g
x^4 - 6*x^2 - 6*x - 1
sage: g.parent()
Symbolic Ring


To turn it into a polynomial, use the polynomial method.

sage: q = g.polynomial(QQbar)
sage: q
x^4 - 6*x^2 - 6*x - 1
sage: q.parent()
Univariate Polynomial Ring in x over Algebraic Field


Now that it is an element in some polynomial ring, you can change ring:

sage: qq = q.change_ring(ZZ)
sage: qq
x^4 - 6*x^2 - 6*x - 1
sage: qq.parent()
Univariate Polynomial Ring in x over Integer Ring