Used in converting this ring to the corresponding ring in Magma.
EXAMPLES:
sage: R.<a,b,c,d,e,f,g,h,i,j> = PolynomialRing(GF(127),10)
sage: R._magma_init_(magma) # optional - magma
'SageCreateWithNames(PolynomialRing(_sage_ref...,10,"grevlex"),["a","b","c","d","e","f","g","h","i","j"])'
sage: R.<y,z,w> = PolynomialRing(QQ,3)
sage: magma(R) # optional - magma
Polynomial ring of rank 3 over Rational Field
Graded Reverse Lexicographical Order
Variables: y, z, w
A complicated nested example:
sage: R.<a,b,c> = PolynomialRing(GF(9,'a')); S.<T,W> = R[]; S
Multivariate Polynomial Ring in T, W over Multivariate Polynomial Ring in a, b, c over Finite Field in a of size 3^2
sage: magma(S) # optional - magma
Polynomial ring of rank 2 over Polynomial ring of rank 3 over GF(3^2)
Graded Reverse Lexicographical Order
Variables: T, W
sage: magma(PolynomialRing(GF(7),4, 'x')) # optional - magma
Polynomial ring of rank 4 over GF(7)
Graded Reverse Lexicographical Order
Variables: x0, x1, x2, x3
sage: magma(PolynomialRing(GF(49,'a'),10, 'x')) # optional - magma
Polynomial ring of rank 10 over GF(7^2)
Graded Reverse Lexicographical Order
Variables: x0, x1, x2, x3, x4, x5, x6, x7, x8, x9
sage: magma(PolynomialRing(ZZ['a,b,c'],3, 'x')) # optional - magma
Polynomial ring of rank 3 over Polynomial ring of rank 3 over Integer Ring
Graded Reverse Lexicographical Order
Variables: x0, x1, x2
Given a number of variable n and a degree d return a tuple (C,t) such that C is a list of the cardinalities of the sets of monomials up to degree d (including) in n variables and t is the sum of these cardinalities.
INPUT:
EXAMPLES:
sage: P.<x,y> = PolynomialRing(ZZ)
sage: C,t = P._precomp_counts(10,2)
sage: C[0]
1
sage: C[1]
10
sage: C[2]
55
sage: t
66
TESTS:
sage: P.<x,y> = PolynomialRing(ZZ)
sage: C,t = P._precomp_counts(1,2)
sage: C[0]
1
sage: C[1]
1
sage: C[2]
1
sage: t
3
Choose a random exponent tuple for variables with a random
degree
, i.e. choose the degree uniformly at random first
before choosing a random monomial.
INPUT:
EXAMPLES:
sage: K.<x,y,z,w> = QQ[]
sage: K._random_monomial_upto_degree_class(5, 7)
(0, 0, 0, 3, 0)
Choose a random exponent tuple for variables with a random
degree up to
, i.e. choose a random monomial uniformly random
from all monomials up to degree
. This discriminates against
smaller degrees because there are more monomials of bigger
degrees.
INPUT:
EXAMPLES:
sage: K.<x,y,z,w> = QQ[]
sage: K._random_monomial_upto_degree_uniform(4, 3)
(1, 0, 0, 1)
Return string representation of this object.
EXAMPLES:
sage: PolynomialRing(QQ, names=[])
Multivariate Polynomial Ring in no variables over Rational Field
sage: PolynomialRing(QQ, names=['x', 'y'])
Multivariate Polynomial Ring in x, y over Rational Field
Given an index i, a number of variables n and a degree d return the i-th monomial of degree d in n variables.
INPUT:
EXAMPLES:
sage: P.<x,y> = PolynomialRing(QQ)
sage: P._to_monomial(0,10,2)
(0, 0, 0, 0, 0, 0, 0, 0, 0, 2)
sage: P._to_monomial(8,10,2)
(0, 0, 0, 0, 0, 0, 1, 1, 0, 0)
sage: P._to_monomial(54,10,2)
(2, 0, 0, 0, 0, 0, 0, 0, 0, 0)
Note
We do not check if the provided index/rank is within the allowed range. If it is not an infinite loop will occur.
Return a new multivariate polynomial ring which isomorphic to self, but has a different ordering given by the parameter ‘order’ or names given by the parameter ‘names’.
INPUT:
EXAMPLES:
sage: P.<x,y,z> = PolynomialRing(GF(127),3,order='lex')
sage: x > y^2
True
sage: Q.<x,y,z> = P.change_ring(order='degrevlex')
sage: x > y^2
False
Return the characteristic of this polynomial ring.
EXAMPLES:
sage: R = PolynomialRing(QQ, 'x', 3)
sage: R.characteristic()
0
sage: R = PolynomialRing(GF(7),'x', 20)
sage: R.characteristic()
7
Returns a functor F and base ring R such that F(R) == self.
EXAMPLES:
sage: S = ZZ['x,y']
sage: F, R = S.construction(); R
Integer Ring
sage: F
MPoly[x,y]
sage: F(R) == S
True
sage: F(R) == ZZ['x']['y']
False
EXAMPLES:
sage: ZZ['x,y'].is_integral_domain()
True
sage: Integers(8)['x,y'].is_integral_domain()
False
EXAMPLES:
sage: ZZ['x,y'].is_noetherian()
True
sage: Integers(8)['x,y'].is_noetherian()
True
Return a random polynomial of at most degree and at most
terms.
First monomials are chosen uniformly random from the set of all
possible monomials of degree up to (inclusive). This means
that it is more likely that a monomial of degree
appears than
a monomial of degree
because the former class is bigger.
Exactly distinct monomials are chosen this way and each one gets
a random coefficient (possibly zero) from the base ring assigned.
The returned polynomial is the sum of this list of terms.
INPUT:
EXAMPLES:
sage: P.<x,y,z> = PolynomialRing(QQ)
sage: P.random_element(2, 5)
-6/5*x^2 + 2/3*z^2 - 1
sage: P.random_element(2, 5, choose_degree=True)
-1/4*x*y - 1/5*x*z - 1/14*y*z - z^2
Stacked rings:
sage: R = QQ['x,y']
sage: S = R['t,u']
sage: S.random_element(degree=2, terms=1)
-3*x*y + 5/2*y^2 - 1/2*x - 1/4*y + 4
sage: S.random_element(degree=2, terms=1)
(-1/2*x^2 - x*y - 2/7*y^2 + 3/2*x - y)*t*u
Default values apply if no degree and/or number of terms is provided:
sage: random_matrix(QQ['x,y,z'], 2, 2)
[ 2*y^2 - 2/27*y*z - z^2 + 2*z 1/2*x*y - 1/2*y^2 + 2*x - 2*y]
[-1/27*x^2 + 2/5*y^2 - 1/10*z^2 - 2*z -13*y^2 + 2/3*z^2 + 2*y]
sage: random_matrix(QQ['x,y,z'], 2, 2, terms=1, degree=2)
[-1/4*x 1/2]
[ 1/3*x x*y]
sage: P.random_element(0, 1)
-1
sage: P.random_element(2, 0)
0
sage: R.<x> = PolynomialRing(Integers(3), 1)
sage: R.random_element()
x + 1
Return structured string representation of self.
EXAMPLES:
sage: P.<x,y,z> = PolynomialRing(QQ,order=TermOrder('degrevlex',1)+TermOrder('lex',2))
sage: print P.repr_long()
Polynomial Ring
Base Ring : Rational Field
Size : 3 Variables
Block 0 : Ordering : degrevlex
Names : x
Block 1 : Ordering : lex
Names : y, z
Returns the list of variable names of this and its base rings, as if it were a single multi-variate polynomial.
EXAMPLES:
sage: R = QQ['x,y']['z,w']
sage: R.variable_names_recursive()
('x', 'y', 'z', 'w')
sage: R.variable_names_recursive(3)
('y', 'z', 'w')