Ask Your Question

Revision history [back]

You can use the subs method of polynomials:

sage: x = polygen(ZZ)
sage: K.<a>= NumberField(x^2+1)
sage: (x^2).subs(x=a)
-1

Now, if you want to apply it to all elements of a list E, you can use Python's list comprehension:

sage: [p.subs(x=a) for p in E]
[a, -1, a + 1]

Or, for the conjugate:

sage: [p.subs(x=a.conjugate()) for p in E]
[-a, -1, -a + 1]

Note that in the univariate case, you can directly call the polynomial:

sage: (x^2)(a)
-1
sage: [p(a) for p in E]
[a, -1, a + 1]
sage: [p(a.conjugate()) for p in E]
[-a, -1, -a + 1]