Ask Your Question
1

changing parent rings of polynomials

asked 2011-03-31 01:11:05 +0100

shacsmuggler gravatar image

I would like to be able to change the rings sage polynomials live in, so that the number of variables in the polynomial matches the number of generators of the ring. For example, if I have the polynomial x^4 in the Multivariate Polynomial Ring in x, y, z over Rational Field, I would like to get it (or a copy of it) into the Multivariate Polynomial Ring in x over Rational Field. Is there a simple way to do this?

On a similar note, when going in the opposite direction, sage recognizes R.<x> = QQ[] as a different type of object than R.<x,y> = QQ[], which makes my life complicated. Is there a way to convert a polynomial in a single variable ring ( like x^4 in single variable QQ[x]) into the same polynomial but with a multivariable parent (like x^4 in a Multivariate Polynomial Ring QQ[x])?

Thanks!

edit retag flag offensive close merge delete

Comments

Thanks for all of your suggestions. However, I don't think that works when the names in the polynomial rings are different. For example, I can't convert a^4 in A.<a, b,="" c=""> = QQ[] to a polynomial in R.<x> = QQ[]. Is there a way to get around this?

shacsmuggler gravatar imageshacsmuggler ( 2011-04-01 10:53:23 +0100 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2011-03-31 01:48:04 +0100

DSM gravatar image

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)]
edit flag offensive delete link more
1

answered 2011-03-31 03:14:25 +0100

Simon King gravatar image

I think that one of your questions remained unanswered: How does one create a polynomial ring with one variable that has the same class as a multivariate polynomial ring?

Indeed, Sage differentiates between a univariate ring (which has a specialised implementation) and a multivariate ring with one variable.

If you do

sage: R_univariate.<x> = QQ[]

then you will obtain a univariate ring, which has a different class than

sage: R_multivariate.<x,y> = QQ[]

You can obtain a multivariate ring with one variable as follows:

sage: R_one_variable.<x> = PolynomialRing(QQ,1)
sage: type(R_multivariate) == type(R_one_variable)
True
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-03-31 01:11:05 +0100

Seen: 3,697 times

Last updated: Mar 31 '11