Revision history [back]

Using gap under the hood

sage: x = polygen(ZZ)
sage: p = 1+x+2*x^2+x^3+x^4
sage: p(E(5))
E(5)^2


In GAP (and Sagemath) E(k) is the primitive k-th root of unity.

Using gap GAP's universal cyclotomic field under the hood

sage: x = polygen(ZZ)
sage: p = 1+x+2*x^2+x^3+x^4
sage: p(E(5))
E(5)^2


In GAP (and Sagemath) E(k) is the primitive k-th root of unity.unity. The advantage of this approach is that you can mix distinct roots of unity and GAP will take care of any simplification

sage: R.<x,y> = PolynomialRing(ZZ)
sage: p = x*y + x^2 - 2*y^3
sage: p(E(3), E(5))
-E(15) + E(15)^4 - E(15)^7 + E(15)^8 - E(15)^13 + 2*E(15)^14