Ask Your Question
1

define a polynomial ring

asked 2013-11-24 00:24:27 -0500

gundamlh gravatar image

updated 2013-11-24 00:26:09 -0500

Dear all,

sage: R.<x> = PolynomialRing(QQ); R
Univariate Polynomial Ring in x over Rational Field
sage: R([1,2,3])
3*x^2 + 2*x + 1
sage: R1.<x> = PolynomialRing(QQ,1); R1
Multivariate Polynomial Ring in x over Rational Field
sage: R1([1,2,3])
---------------------------------------------------------------------------    
TypeError: Could not find a mapping of the passed element to this ring.

  Note that a multivariate polynomial ring is returned when an
  explicit number is given.

     sage: PolynomialRing(QQ,"x",1)
     Multivariate Polynomial Ring in x over Rational Field
     sage: PolynomialRing(QQ,"x",0)
     Multivariate Polynomial Ring in no variables over Rational Field

I want to know the reason .. Why

a multivariate polynomial ring is returned when an explicit number is given.

?

Does it offer users of SAGE any simplicity/convenience?

Thanks in advance!

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2013-11-24 00:58:44 -0500

ppurka gravatar image

Yes. It offers the convenience of not having to define your variables. The number denotes the number of variables in the multivariate polynomial ring.

sage: PolynomialRing(QQ,"x",2)
Multivariate Polynomial Ring in x0, x1 over Rational Field
sage: R = PolynomialRing(QQ,"x",5); R
Multivariate Polynomial Ring in x0, x1, x2, x3, x4 over Rational Field
sage: R.inject_variables()
Defining x0, x1, x2, x3, x4
sage: x0 in R
True

So, now you can programmatically access the variables and play around with them.

sage: xvars = R.gens(); xvars
(x0, x1, x2, x3, x4)
sage: xvars[0] in R
True
edit flag offensive delete link more

Comments

Thanks! Quick and in detail!

gundamlh gravatar imagegundamlh ( 2013-11-24 01:06:41 -0500 )edit

For PolynomialRing(QQ,"x",n) the integer n must be < 2**15 (otherwise "OverflowError: value too large to convert to short"). Do you know a way for having arbitrary large integer n ?

Sébastien Palcoux gravatar imageSébastien Palcoux ( 2014-01-03 00:13:13 -0500 )edit

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: 2013-11-24 00:24:27 -0500

Seen: 171 times

Last updated: Nov 24 '13