Base class for multivariate polynomial rings

class sage.rings.polynomial.multi_polynomial_ring_generic.MPolynomialRing_generic
__contains__()
x.__contains__(y) <==> y in x
__eq__()
x.__eq__(y) <==> x==y
__ge__()
x.__ge__(y) <==> x>=y
__gt__()
x.__gt__(y) <==> x>y
__init__()
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
__le__()
x.__le__(y) <==> x<=y
__lt__()
x.__lt__(y) <==> x<y
__ne__()
x.__ne__(y) <==> x!=y
static __new__()
T.__new__(S, ...) -> a new object with type S, a subtype of T
__reduce__()
_extract_polydict()
Assuming other_vars is a subset of self.variable_names(), convert the dict of ETuples with respect to other_vars to a dict with respect to self.variable_names().
_has_singular
_ideal_class_()
_is_valid_homomorphism_()
_latex_()
_magma_cache
_magma_gens
_magma_init_()

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
_monomial_order_function()
_mpoly_base_ring()
Returns the base ring if this is viewed as a polynomial ring over vars. See also MPolynomial._mpoly_dict_recursive.
_precomp_counts()

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:

  • n – number of variables
  • d – degree

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
_random_monomial_upto_degree_class()

Choose a random exponent tuple for n variables with a random degree d, i.e. choose the degree uniformly at random first before choosing a random monomial.

INPUT:

  • n – number of variables
  • degree – degree of monomials
  • counts – ignored
  • total – ignored

EXAMPLES:

sage: K.<x,y,z,w> = QQ[]
sage: K._random_monomial_upto_degree_class(5, 7)
(0, 0, 0, 3, 0)
_random_monomial_upto_degree_uniform()

Choose a random exponent tuple for n variables with a random degree up to d, i.e. choose a random monomial uniformly random from all monomials up to degree d. This discriminates against smaller degrees because there are more monomials of bigger degrees.

INPUT:

  • n – number of variables
  • degree – degree of monomials
  • counts – ignored
  • total – ignored

EXAMPLES:

sage: K.<x,y,z,w> = QQ[]
sage: K._random_monomial_upto_degree_uniform(4, 3)
(1, 0, 0, 1)
_repr_()

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
_to_monomial()

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:

  • i – index: 0 <= i < binom(n+d-1,n-1)
  • n – number of variables
  • d – degree

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.

change_ring()

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:

  • base_ring – a base ring
  • names – variable names
  • order – a term order

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
characteristic()

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
completion()
construction()

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
gen()
is_field()
Return True if this multivariate polynomial ring is a field, i.e., it is a ring in 0 generators over a field.
is_finite()
is_integral_domain()

EXAMPLES:

sage: ZZ['x,y'].is_integral_domain()
True
sage: Integers(8)['x,y'].is_integral_domain()
False
is_noetherian()

EXAMPLES:

sage: ZZ['x,y'].is_noetherian()
True
sage: Integers(8)['x,y'].is_noetherian()
True
krull_dimension()
ngens()
random_element()

Return a random polynomial of at most degree d and at most t terms.

First monomials are chosen uniformly random from the set of all possible monomials of degree up to d (inclusive). This means that it is more likely that a monomial of degree d appears than a monomial of degree d-1 because the former class is bigger.

Exactly t 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:

  • degree – maximal degree (likely to be reached) (default: 2)
  • terms – number of terms requested (default: 5)
  • choose_degree – choose degrees of monomials randomly first rather than monomials uniformly random.
  • **kwargs – passed to the random element generator of the base ring

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
remove_var()
repr_long()

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
term_order()
variable_names_recursive()

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')
sage.rings.polynomial.multi_polynomial_ring_generic.is_MPolynomialRing()
sage.rings.polynomial.multi_polynomial_ring_generic.unpickle_MPolynomialRing_generic()
sage.rings.polynomial.multi_polynomial_ring_generic.unpickle_MPolynomialRing_generic_v1()

Previous topic

Term Orderings

Next topic

Base class for elements of multivariate polynomial rings

This Page