Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Yes, you can do it like this:

sage: R.<x> = PolynomialRing(ZZ)
sage: p = 1+x+2*x^2+x^3+x^4
sage: K.<z> = CyclotomicField(5)
sage: p(z)
z^2

Here it's important that x is the generator of a polynomial ring.

It doesn't work when x is symbolic, as you noticed.

If you have to start with a symbolic polynomial, then you can convert it first using the polynomial() method:

sage: var('y')
sage: q = 1+y+2*y^2+y^3+y^4
sage: q.polynomial(ZZ)(z)
z^2

Yes, you can do it like this:

sage: R.<x> = PolynomialRing(ZZ)
sage: p = 1+x+2*x^2+x^3+x^4
sage: K.<z> K.<w> = CyclotomicField(5)
sage: p(z)
z^2
p(w)
w^2

Here it's important that x is the generator of a polynomial ring.

It doesn't work when x is symbolic, as you noticed.

If you have to start with a symbolic polynomial, then you can convert it first using the polynomial() method:

sage: var('y')
sage: q = 1+y+2*y^2+y^3+y^4
sage: q.polynomial(ZZ)(z)
q.polynomial(ZZ)(w)
z^2

Yes, you can do it like this:

sage: R.<x> = PolynomialRing(ZZ)
sage: p = 1+x+2*x^2+x^3+x^4
sage: K.<w> = CyclotomicField(5)
sage: p(w)
w^2

Here it's important that x is the generator of a polynomial ring.

ring. It doesn't work when x is symbolic, as you noticed.

If you have to start with a symbolic polynomial, then you can convert it first using the polynomial() method:

sage: var('y')
sage: q = 1+y+2*y^2+y^3+y^4
sage: q.polynomial(ZZ)(w)
z^2

Yes, you can do it like this:

sage: R.<x> = PolynomialRing(ZZ)
sage: p = 1+x+2*x^2+x^3+x^4
sage: K.<w> = CyclotomicField(5)
sage: p(w)
w^2

Here it's important that x is the generator of a polynomial ring. It doesn't work when x is symbolic, as you noticed.

noticed. If you have to start with a symbolic polynomial, then you can convert it first using the polynomial() method:

sage: var('y')
sage: q = 1+y+2*y^2+y^3+y^4
sage: q.polynomial(ZZ)(w)
z^2

Yes, you can do it like this:

sage: R.<x> = PolynomialRing(ZZ)
sage: p = 1+x+2*x^2+x^3+x^4
sage: K.<w> = CyclotomicField(5)
sage: p(w)
w^2

Here it's important that x is the generator of a polynomial ring. It doesn't work when x is symbolic, as you noticed. If you have to start with a symbolic polynomial, then you can convert it first using the polynomial() method:

sage: var('y')
sage: q = 1+y+2*y^2+y^3+y^4
sage: q.polynomial(ZZ)(w)
z^2
w^2