Ask Your Question

Revision history [back]

Simply pass the string to the polynomial ring you want to consider:

sage: R.<x> = PolynomialRing(QQ)
sage: R
Univariate Polynomial Ring in x over Rational Field
sage: p = R(u'x + 2')
sage: p
x + 2
sage: p.degree()
1

Note that p = R(u'x + 2') is nothing but a special case of SageMath general scheme to construct an element E from its parent P:

sage: E = P(D)

where D is some data to initialize the element.

Simply pass the string to the polynomial ring you want to consider:

sage: R.<x> = PolynomialRing(QQ)
sage: R
Univariate Polynomial Ring in x over Rational Field
sage: p = R(u'x + 2')
sage: p
x + 2
sage: p.degree()
1
sage: p in R
True

Note that p = R(u'x + 2') is nothing but a special case of SageMath general scheme to construct an element E from its parent P:

sage: E = P(D)

where D is some data to initialize the element. element.