Ask Your Question

Revision history [back]

In your test_2 the object K1 is the cyclotomic field, not the polynomial ring over it, hence the error.

Probably you meant something like this:

def test_3(p):
    K.<z> = CyclotomicField(p**2)
    R.<x> = PolynomialRing(K)
    v = [E(p)**s for s in srange(0,p)]
    v.reverse()
    F = R(v)
    return F

Example:

sage: test_3(3)
x^2 + z^3*x - z^3 - 1
sage: test_3(3).factor()
(x - 1) * (x + z^3 + 1)