Revision history [back]

Here is a possibility:

sage: var('a x')
(a, x)
sage: f = a*x^3+1
sage: f.parent()
Symbolic Ring
sage: q = f.polynomial(SR)
sage: q
a*x^3 + 1
sage: q.parent()
Multivariate Polynomial Ring in a, x over Symbolic Ring
sage: q.variables()
(a, x)


So, at this point you got a polynomial with coefficients in SR but with both a and x as polynomial variables. Hence, it is not possible to send it into the ring R:

sage: R.<x> = SR[]
sage: R(q)
TypeError: not a constant polynomial


So, you have to substitute the polynomial variable a of q into the symbolic variable a:

sage: s = q.subs(a=SR.var('a'))
sage: s.parent()
Multivariate Polynomial Ring in a, x over Symbolic Ring
sage: P = R(s)
sage: P
a*x^3 + 1
sage: P.parent()
Univariate Polynomial Ring in x over Symbolic Ring
sage: P.variables()
(x,)