Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I'm not sure why you want to do this in particular, but if I take your requests literally I think you can cast the polynomials the way you want just by calling the base ring.

sage: # make a multivariate polynomial ring in 3 variables
sage: MR3.<x,y,z> = QQ[]
sage: MR3
Multivariate Polynomial Ring in x, y, z over Rational Field
sage: # make a polynomial
sage: mp3 = x**4
sage: # check the parents
sage: parent(mp3)
Multivariate Polynomial Ring in x, y, z over Rational Field
sage: list((v,parent(v)) for v in mp3.variables())
[(x, Multivariate Polynomial Ring in x, y, z over Rational Field)]

If I understand you that's your starting polynomial. Then you want it in Multivariate Polynomial Ring in x over Rational Field:

sage: # make a 1-variable multivariate ring (instead of a univariate ring)
sage: MR1.<x> = PolynomialRing(QQ, 'x', 1)
sage: MR1
Multivariate Polynomial Ring in x over Rational Field
sage: 
sage: # ensure that mp3 is still in MPR(x,y,z)
sage: parent(mp3) 
Multivariate Polynomial Ring in x, y, z over Rational Field
sage: list((v,parent(v)) for v in mp3.variables())
[(x, Multivariate Polynomial Ring in x, y, z over Rational Field)]
sage: 
sage: # cast the polynomial into R1
sage: mp1 = MR1(mp3)
sage: mp1
x^4
sage: parent(mp1)
Multivariate Polynomial Ring in x over Rational Field
sage: list((v,parent(v)) for v in mp1.variables())
[(x, Multivariate Polynomial Ring in x over Rational Field)]

And I think mp1 is what you want. Similarly:

sage: # make a univariate polynomial in x
sage: R.<x> = QQ[]
sage: p1 = x**4
sage: parent(p1)
Univariate Polynomial Ring in x over Rational Field
sage: list((v,parent(v)) for v in p1.variables())
[(x, Univariate Polynomial Ring in x over Rational Field)]
sage: 
sage: # cast into MR1
sage: mp1b = MR1(p1)
sage: parent(mp1b), 
(Multivariate Polynomial Ring in x over Rational Field,)
sage: list((v,parent(v)) for v in mp1b.variables())
[(x, Multivariate Polynomial Ring in x over Rational Field)]