Rings#

This module provides the abstract base class Ring from which all rings in Sage (used to) derive, as well as a selection of more specific base classes.

Warning

Those classes, except maybe for the lowest ones like CommutativeRing and CommutativeAlgebra, are being progressively deprecated in favor of the corresponding categories. which are more flexible, in particular with respect to multiple inheritance.

The class inheritance hierarchy is:

Subclasses of PrincipalIdealDomain are

Some aspects of this structure may seem strange, but this is an unfortunate consequence of the fact that Cython classes do not support multiple inheritance. Hence, for instance, Field cannot be a subclass of both NoetherianRing and PrincipalIdealDomain, although all fields are Noetherian PIDs.

(A distinct but equally awkward issue is that sometimes we may not know in advance whether or not a ring belongs in one of these classes; e.g. some orders in number fields are Dedekind domains, but others are not, and we still want to offer a unified interface, so orders are never instances of the deprecated DedekindDomain class.)

AUTHORS:

  • David Harvey (2006-10-16): changed CommutativeAlgebra to derive from CommutativeRing instead of from Algebra.

  • David Loeffler (2009-07-09): documentation fixes, added to reference manual.

  • Simon King (2011-03-29): Proper use of the category framework for rings.

  • Simon King (2011-05-20): Modify multiplication and _ideal_class_ to support ideals of non-commutative rings.

class sage.rings.ring.Algebra#

Bases: Ring

Generic algebra

class sage.rings.ring.CommutativeAlgebra#

Bases: CommutativeRing

Generic commutative algebra

is_commutative()#

Return True since this algebra is commutative.

EXAMPLES:

Any commutative ring is a commutative algebra over itself:

sage: A = sage.rings.ring.CommutativeAlgebra
sage: A(ZZ).is_commutative()
True
sage: A(QQ).is_commutative()
True

Trying to create a commutative algebra over a non-commutative ring will result in a TypeError.

class sage.rings.ring.CommutativeRing#

Bases: Ring

Generic commutative ring.

derivation(arg=None, twist=None)#

Return the twisted or untwisted derivation over this ring specified by arg.

Note

A twisted derivation with respect to \(\theta\) (or a \(\theta\)-derivation for short) is an additive map \(d\) satisfying the following axiom for all \(x, y\) in the domain:

\[d(xy) = \theta(x) d(y) + d(x) y.\]

INPUT:

  • arg – (optional) a generator or a list of coefficients that defines the derivation

  • twist – (optional) the twisting homomorphism

EXAMPLES:

sage: R.<x,y,z> = QQ[]
sage: R.derivation()                                                        # needs sage.modules
d/dx

In that case, arg could be a generator:

sage: R.derivation(y)                                                       # needs sage.modules
d/dy

or a list of coefficients:

sage: R.derivation([1,2,3])                                                 # needs sage.modules
d/dx + 2*d/dy + 3*d/dz

It is not possible to define derivations with respect to a polynomial which is not a variable:

sage: R.derivation(x^2)                                                     # needs sage.modules
Traceback (most recent call last):
...
ValueError: unable to create the derivation

Here is an example with twisted derivations:

sage: R.<x,y,z> = QQ[]
sage: theta = R.hom([x^2, y^2, z^2])
sage: f = R.derivation(twist=theta); f                                      # needs sage.modules
0
sage: f.parent()                                                            # needs sage.modules
Module of twisted derivations over Multivariate Polynomial Ring in x, y, z
 over Rational Field (twisting morphism: x |--> x^2, y |--> y^2, z |--> z^2)

Specifying a scalar, the returned twisted derivation is the corresponding multiple of \(\theta - id\):

sage: R.derivation(1, twist=theta)                                          # needs sage.modules
[x |--> x^2, y |--> y^2, z |--> z^2] - id
sage: R.derivation(x, twist=theta)                                          # needs sage.modules
x*([x |--> x^2, y |--> y^2, z |--> z^2] - id)
derivation_module(codomain=None, twist=None)#

Returns the module of derivations over this ring.

INPUT:

  • codomain – an algebra over this ring or a ring homomorphism whose domain is this ring or None (default: None); if it is a morphism, the codomain of derivations will be the codomain of the morphism viewed as an algebra over self through the given morphism; if None, the codomain will be this ring

  • twist – a morphism from this ring to codomain or None (default: None); if None, the coercion map from this ring to codomain will be used

Note

A twisted derivation with respect to \(\theta\) (or a \(\theta\)-derivation for short) is an additive map \(d\) satisfying the following axiom for all \(x, y\) in the domain:

\[d(xy) = \theta(x) d(y) + d(x) y.\]

EXAMPLES:

sage: R.<x,y,z> = QQ[]
sage: M = R.derivation_module(); M                                          # needs sage.modules
Module of derivations over
 Multivariate Polynomial Ring in x, y, z over Rational Field
sage: M.gens()                                                              # needs sage.modules
(d/dx, d/dy, d/dz)

We can specify a different codomain:

sage: K = R.fraction_field()
sage: M = R.derivation_module(K); M                                         # needs sage.modules
Module of derivations
 from Multivariate Polynomial Ring in x, y, z over Rational Field
   to Fraction Field of
      Multivariate Polynomial Ring in x, y, z over Rational Field
sage: M.gen() / x                                                           # needs sage.modules
1/x*d/dx

Here is an example with a non-canonical defining morphism:

sage: ev = R.hom([QQ(0), QQ(1), QQ(2)])
sage: ev
Ring morphism:
  From: Multivariate Polynomial Ring in x, y, z over Rational Field
  To:   Rational Field
  Defn: x |--> 0
        y |--> 1
        z |--> 2
sage: M = R.derivation_module(ev)                                           # needs sage.modules
sage: M                                                                     # needs sage.modules
Module of derivations
 from Multivariate Polynomial Ring in x, y, z over Rational Field
   to Rational Field

Elements in \(M\) acts as derivations at \((0,1,2)\):

sage: # needs sage.modules
sage: Dx = M.gen(0); Dx
d/dx
sage: Dy = M.gen(1); Dy
d/dy
sage: Dz = M.gen(2); Dz
d/dz
sage: f = x^2 + y^2 + z^2
sage: Dx(f)  # = 2*x evaluated at (0,1,2)
0
sage: Dy(f)  # = 2*y evaluated at (0,1,2)
2
sage: Dz(f)  # = 2*z evaluated at (0,1,2)
4

An example with a twisting homomorphism:

sage: theta = R.hom([x^2, y^2, z^2])
sage: M = R.derivation_module(twist=theta); M                               # needs sage.modules
Module of twisted derivations over Multivariate Polynomial Ring in x, y, z
 over Rational Field (twisting morphism: x |--> x^2, y |--> y^2, z |--> z^2)

See also

derivation()

extension(poly, name=None, names=None, **kwds)#

Algebraically extends self by taking the quotient self[x] / (f(x)).

INPUT:

  • poly – A polynomial whose coefficients are coercible into self

  • name – (optional) name for the root of \(f\)

Note

Using this method on an algebraically complete field does not return this field; the construction self[x] / (f(x)) is done anyway.

EXAMPLES:

sage: R = QQ['x']
sage: y = polygen(R)
sage: R.extension(y^2 - 5, 'a')                                             # needs sage.libs.pari
Univariate Quotient Polynomial Ring in a over
 Univariate Polynomial Ring in x over Rational Field with modulus a^2 - 5
sage: # needs sage.rings.finite_rings
sage: P.<x> = PolynomialRing(GF(5))
sage: F.<a> = GF(5).extension(x^2 - 2)
sage: P.<t> = F[]
sage: R.<b> = F.extension(t^2 - a); R
Univariate Quotient Polynomial Ring in b over
 Finite Field in a of size 5^2 with modulus b^2 + 4*a
fraction_field()#

Return the fraction field of self.

EXAMPLES:

sage: R = Integers(389)['x,y']
sage: Frac(R)
Fraction Field of Multivariate Polynomial Ring in x, y over Ring of integers modulo 389
sage: R.fraction_field()
Fraction Field of Multivariate Polynomial Ring in x, y over Ring of integers modulo 389
frobenius_endomorphism(n=1)#

INPUT:

  • n – a nonnegative integer (default: 1)

OUTPUT:

The \(n\)-th power of the absolute arithmetic Frobenius endomorphism on this finite field.

EXAMPLES:

sage: K.<u> = PowerSeriesRing(GF(5))
sage: Frob = K.frobenius_endomorphism(); Frob
Frobenius endomorphism x |--> x^5 of Power Series Ring in u
 over Finite Field of size 5
sage: Frob(u)
u^5

We can specify a power:

sage: f = K.frobenius_endomorphism(2); f
Frobenius endomorphism x |--> x^(5^2) of Power Series Ring in u
 over Finite Field of size 5
sage: f(1+u)
1 + u^25
ideal_monoid()#

Return the monoid of ideals of this ring.

EXAMPLES:

sage: ZZ.ideal_monoid()
Monoid of ideals of Integer Ring
sage: R.<x>=QQ[]; R.ideal_monoid()
Monoid of ideals of Univariate Polynomial Ring in x over Rational Field
is_commutative()#

Return True, since this ring is commutative.

EXAMPLES:

sage: QQ.is_commutative()
True
sage: ZpCA(7).is_commutative()                                              # needs sage.rings.padics
True
sage: A = QuaternionAlgebra(QQ, -1, -3, names=('i','j','k')); A             # needs sage.combinat sage.modules
Quaternion Algebra (-1, -3) with base ring Rational Field
sage: A.is_commutative()                                                    # needs sage.combinat sage.modules
False
krull_dimension()#

Return the Krull dimension of this commutative ring.

The Krull dimension is the length of the longest ascending chain of prime ideals.

localization(additional_units, names=None, normalize=True, category=None)#

Return the localization of self at the given additional units.

EXAMPLES:

sage: R.<x, y> = GF(3)[]
sage: R.localization((x*y, x**2 + y**2))                                    # needs sage.rings.finite_rings
Multivariate Polynomial Ring in x, y over Finite Field of size 3
 localized at (y, x, x^2 + y^2)
sage: ~y in _                                                               # needs sage.rings.finite_rings
True
class sage.rings.ring.DedekindDomain#

Bases: IntegralDomain

class sage.rings.ring.Field#

Bases: PrincipalIdealDomain

Generic field

algebraic_closure()#

Return the algebraic closure of self.

Note

This is only implemented for certain classes of field.

EXAMPLES:

sage: K = PolynomialRing(QQ,'x').fraction_field(); K
Fraction Field of Univariate Polynomial Ring in x over Rational Field
sage: K.algebraic_closure()
Traceback (most recent call last):
...
NotImplementedError: Algebraic closures of general fields not implemented.
divides(x, y, coerce=True)#

Return True if x divides y in this field (usually True in a field!). If coerce is True (the default), first coerce x and y into self.

EXAMPLES:

sage: QQ.divides(2, 3/4)
True
sage: QQ.divides(0, 5)
False
fraction_field()#

Return the fraction field of self.

EXAMPLES:

Since fields are their own field of fractions, we simply get the original field in return:

sage: QQ.fraction_field()
Rational Field
sage: RR.fraction_field()                                                   # needs sage.rings.real_mpfr
Real Field with 53 bits of precision
sage: CC.fraction_field()                                                   # needs sage.rings.real_mpfr
Complex Field with 53 bits of precision

sage: x = polygen(ZZ, 'x')
sage: F = NumberField(x^2 + 1, 'i')                                         # needs sage.rings.number_field
sage: F.fraction_field()                                                    # needs sage.rings.number_field
Number Field in i with defining polynomial x^2 + 1
ideal(*gens, **kwds)#

Return the ideal generated by gens.

EXAMPLES:

sage: QQ.ideal(2)
Principal ideal (1) of Rational Field
sage: QQ.ideal(0)
Principal ideal (0) of Rational Field
integral_closure()#

Return this field, since fields are integrally closed in their fraction field.

EXAMPLES:

sage: QQ.integral_closure()
Rational Field
sage: Frac(ZZ['x,y']).integral_closure()
Fraction Field of Multivariate Polynomial Ring in x, y over Integer Ring
is_field(proof=True)#

Return True since this is a field.

EXAMPLES:

sage: Frac(ZZ['x,y']).is_field()
True
is_integrally_closed()#

Return True since fields are trivially integrally closed in their fraction field (since they are their own fraction field).

EXAMPLES:

sage: Frac(ZZ['x,y']).is_integrally_closed()
True
is_noetherian()#

Return True since fields are Noetherian rings.

EXAMPLES:

sage: QQ.is_noetherian()
True
krull_dimension()#

Return the Krull dimension of this field, which is 0.

EXAMPLES:

sage: QQ.krull_dimension()
0
sage: Frac(QQ['x,y']).krull_dimension()
0
prime_subfield()#

Return the prime subfield of self.

EXAMPLES:

sage: k = GF(9, 'a')                                                        # needs sage.rings.finite_rings
sage: k.prime_subfield()                                                    # needs sage.rings.finite_rings
Finite Field of size 3
class sage.rings.ring.IntegralDomain#

Bases: CommutativeRing

Generic integral domain class.

This class is deprecated. Please use the sage.categories.integral_domains.IntegralDomains category instead.

is_field(proof=True)#

Return True if this ring is a field.

EXAMPLES:

sage: GF(7).is_field()
True

The following examples have their own is_field implementations:

sage: ZZ.is_field(); QQ.is_field()
False
True
sage: R.<x> = PolynomialRing(QQ); R.is_field()
False
is_integral_domain(proof=True)#

Return True, since this ring is an integral domain.

(This is a naive implementation for objects with type IntegralDomain)

EXAMPLES:

sage: ZZ.is_integral_domain()
True
sage: QQ.is_integral_domain()
True
sage: ZZ['x'].is_integral_domain()
True
sage: R = ZZ.quotient(ZZ.ideal(10)); R.is_integral_domain()
False
is_integrally_closed()#

Return True if this ring is integrally closed in its field of fractions; otherwise return False.

When no algorithm is implemented for this, then this function raises a NotImplementedError.

Note that is_integrally_closed has a naive implementation in fields. For every field \(F\), \(F\) is its own field of fractions, hence every element of \(F\) is integral over \(F\).

EXAMPLES:

sage: ZZ.is_integrally_closed()
True
sage: QQ.is_integrally_closed()
True
sage: QQbar.is_integrally_closed()                                          # needs sage.rings.number_field
True
sage: GF(5).is_integrally_closed()
True
sage: Z5 = Integers(5); Z5
Ring of integers modulo 5
sage: Z5.is_integrally_closed()
Traceback (most recent call last):
...
AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'...
class sage.rings.ring.NoetherianRing#

Bases: CommutativeRing

Generic Noetherian ring class.

A Noetherian ring is a commutative ring in which every ideal is finitely generated.

This class is deprecated, and not actually used anywhere in the Sage code base. If you think you need it, please create a category NoetherianRings, move the code of this class there, and use it instead.

is_noetherian()#

Return True since this ring is Noetherian.

EXAMPLES:

sage: ZZ.is_noetherian()
True
sage: QQ.is_noetherian()
True
sage: R.<x> = PolynomialRing(QQ)
sage: R.is_noetherian()
True
class sage.rings.ring.PrincipalIdealDomain#

Bases: IntegralDomain

Generic principal ideal domain.

This class is deprecated. Please use the PrincipalIdealDomains category instead.

class_group()#

Return the trivial group, since the class group of a PID is trivial.

EXAMPLES:

sage: QQ.class_group()                                                      # needs sage.groups
Trivial Abelian group
content(x, y, coerce=True)#

Return the content of \(x\) and \(y\), i.e. the unique element \(c\) of self such that \(x/c\) and \(y/c\) are coprime and integral.

EXAMPLES:

sage: QQ.content(ZZ(42), ZZ(48)); type(QQ.content(ZZ(42), ZZ(48)))
6
<class 'sage.rings.rational.Rational'>
sage: QQ.content(1/2, 1/3)
1/6
sage: factor(1/2); factor(1/3); factor(1/6)
2^-1
3^-1
2^-1 * 3^-1
sage: a = (2*3)/(7*11); b = (13*17)/(19*23)
sage: factor(a); factor(b); factor(QQ.content(a,b))
2 * 3 * 7^-1 * 11^-1
13 * 17 * 19^-1 * 23^-1
7^-1 * 11^-1 * 19^-1 * 23^-1

Note the changes to the second entry:

sage: c = (2*3)/(7*11); d = (13*17)/(7*19*23)
sage: factor(c); factor(d); factor(QQ.content(c,d))
2 * 3 * 7^-1 * 11^-1
7^-1 * 13 * 17 * 19^-1 * 23^-1
7^-1 * 11^-1 * 19^-1 * 23^-1
sage: e = (2*3)/(7*11); f = (13*17)/(7^3*19*23)
sage: factor(e); factor(f); factor(QQ.content(e,f))
2 * 3 * 7^-1 * 11^-1
7^-3 * 13 * 17 * 19^-1 * 23^-1
7^-3 * 11^-1 * 19^-1 * 23^-1
gcd(x, y, coerce=True)#

Return the greatest common divisor of x and y, as elements of self.

EXAMPLES:

The integers are a principal ideal domain and hence a GCD domain:

sage: ZZ.gcd(42, 48)
6
sage: 42.factor(); 48.factor()
2 * 3 * 7
2^4 * 3
sage: ZZ.gcd(2^4*7^2*11, 2^3*11*13)
88
sage: 88.factor()
2^3 * 11

In a field, any nonzero element is a GCD of any nonempty set of nonzero elements. In previous versions, Sage used to return 1 in the case of the rational field. However, since github issue #10771, the rational field is considered as the fraction field of the integer ring. For the fraction field of an integral domain that provides both GCD and LCM, it is possible to pick a GCD that is compatible with the GCD of the base ring:

sage: QQ.gcd(ZZ(42), ZZ(48)); type(QQ.gcd(ZZ(42), ZZ(48)))
6
<class 'sage.rings.rational.Rational'>
sage: QQ.gcd(1/2, 1/3)
1/6

Polynomial rings over fields are GCD domains as well. Here is a simple example over the ring of polynomials over the rationals as well as over an extension ring. Note that gcd requires x and y to be coercible:

sage: # needs sage.rings.number_field
sage: R.<x> = PolynomialRing(QQ)
sage: S.<a> = NumberField(x^2 - 2, 'a')
sage: f = (x - a)*(x + a); g = (x - a)*(x^2 - 2)
sage: print(f); print(g)
x^2 - 2
x^3 - a*x^2 - 2*x + 2*a
sage: f in R
True
sage: g in R
False
sage: R.gcd(f, g)
Traceback (most recent call last):
...
TypeError: Unable to coerce 2*a to a rational
sage: R.base_extend(S).gcd(f,g)
x^2 - 2
sage: R.base_extend(S).gcd(f, (x - a)*(x^2 - 3))
x - a
is_noetherian()#

Every principal ideal domain is noetherian, so we return True.

EXAMPLES:

sage: Zp(5).is_noetherian()                                                 # needs sage.rings.padics
True
class sage.rings.ring.Ring#

Bases: ParentWithGens

Generic ring class.

base_extend(R)#

EXAMPLES:

sage: QQ.base_extend(GF(7))
Traceback (most recent call last):
...
TypeError: no base extension defined
sage: ZZ.base_extend(GF(7))
Finite Field of size 7
category()#

Return the category to which this ring belongs.

Note

This method exists because sometimes a ring is its own base ring. During initialisation of a ring \(R\), it may be checked whether the base ring (hence, the ring itself) is a ring. Hence, it is necessary that R.category() tells that R is a ring, even before its category is properly initialised.

EXAMPLES:

sage: FreeAlgebra(QQ, 3, 'x').category()  # todo: use a ring which is not an algebra!   # needs sage.combinat sage.modules
Category of algebras with basis over Rational Field

Since a quotient of the integers is its own base ring, and during initialisation of a ring it is tested whether the base ring belongs to the category of rings, the following is an indirect test that the category() method of rings returns the category of rings even before the initialisation was successful:

sage: I = Integers(15)
sage: I.base_ring() is I
True
sage: I.category()
Join of Category of finite commutative rings
    and Category of subquotients of monoids
    and Category of quotients of semigroups
    and Category of finite enumerated sets
epsilon()#

Return the precision error of elements in this ring.

EXAMPLES:

sage: RDF.epsilon()
2.220446049250313e-16
sage: ComplexField(53).epsilon()                                            # needs sage.rings.real_mpfr
2.22044604925031e-16
sage: RealField(10).epsilon()                                               # needs sage.rings.real_mpfr
0.0020

For exact rings, zero is returned:

sage: ZZ.epsilon()
0

This also works over derived rings:

sage: RR['x'].epsilon()                                                     # needs sage.rings.real_mpfr
2.22044604925031e-16
sage: QQ['x'].epsilon()
0

For the symbolic ring, there is no reasonable answer:

sage: SR.epsilon()                                                          # needs sage.symbolic
Traceback (most recent call last):
...
NotImplementedError
ideal(*args, **kwds)#

Return the ideal defined by x, i.e., generated by x.

INPUT:

  • *x – list or tuple of generators (or several input arguments)

  • coerce – bool (default: True); this must be a keyword argument. Only set it to False if you are certain that each generator is already in the ring.

  • ideal_class – callable (default: self._ideal_class_()); this must be a keyword argument. A constructor for ideals, taking the ring as the first argument and then the generators. Usually a subclass of Ideal_generic or Ideal_nc.

  • Further named arguments (such as side in the case of non-commutative rings) are forwarded to the ideal class.

EXAMPLES:

sage: R.<x,y> = QQ[]
sage: R.ideal(x,y)
Ideal (x, y) of Multivariate Polynomial Ring in x, y over Rational Field
sage: R.ideal(x+y^2)
Ideal (y^2 + x) of Multivariate Polynomial Ring in x, y over Rational Field
sage: R.ideal( [x^3,y^3+x^3] )
Ideal (x^3, x^3 + y^3) of Multivariate Polynomial Ring in x, y over Rational Field

Here is an example over a non-commutative ring:

sage: A = SteenrodAlgebra(2)                                                # needs sage.combinat sage.modules
sage: A.ideal(A.1, A.2^2)                                                   # needs sage.combinat sage.modules
Twosided Ideal (Sq(2), Sq(2,2)) of mod 2 Steenrod algebra, milnor basis
sage: A.ideal(A.1, A.2^2, side='left')                                      # needs sage.combinat sage.modules
Left Ideal (Sq(2), Sq(2,2)) of mod 2 Steenrod algebra, milnor basis
ideal_monoid()#

Return the monoid of ideals of this ring.

EXAMPLES:

sage: # needs sage.combinat sage.modules
sage: F.<x,y,z> = FreeAlgebra(ZZ, 3)
sage: I = F * [x*y + y*z, x^2 + x*y - y*x - y^2] * F
sage: Q = F.quotient(I)
sage: Q.ideal_monoid()
Monoid of ideals of Quotient of Free Algebra on 3 generators (x, y, z)
 over Integer Ring by the ideal (x*y + y*z, x^2 + x*y - y*x - y^2)
sage: F.<x,y,z> = FreeAlgebra(ZZ, implementation='letterplace')
sage: I = F * [x*y + y*z, x^2 + x*y - y*x - y^2] * F
sage: Q = F.quo(I)
sage: Q.ideal_monoid()
Monoid of ideals of Quotient of Free Associative Unital Algebra
 on 3 generators (x, y, z) over Integer Ring
 by the ideal (x*y + y*z, x*x + x*y - y*x - y*y)
is_exact()#

Return True if elements of this ring are represented exactly, i.e., there is no precision loss when doing arithmetic.

Note

This defaults to True, so even if it does return True you have no guarantee (unless the ring has properly overloaded this).

EXAMPLES:

sage: QQ.is_exact()    # indirect doctest
True
sage: ZZ.is_exact()
True
sage: Qp(7).is_exact()                                                      # needs sage.rings.padics
False
sage: Zp(7, type='capped-abs').is_exact()                                   # needs sage.rings.padics
False
is_field(proof=True)#

Return True if this ring is a field.

INPUT:

  • proof – (default: True) Determines what to do in unknown cases

ALGORITHM:

If the parameter proof is set to True, the returned value is correct but the method might throw an error. Otherwise, if it is set to False, the method returns True if it can establish that self is a field and False otherwise.

EXAMPLES:

sage: QQ.is_field()
True
sage: GF(9, 'a').is_field()                                                 # needs sage.rings.finite_rings
True
sage: ZZ.is_field()
False
sage: QQ['x'].is_field()
False
sage: Frac(QQ['x']).is_field()
True

This illustrates the use of the proof parameter:

sage: R.<a,b> = QQ[]
sage: S.<x,y> = R.quo((b^3))                                                # needs sage.libs.singular
sage: S.is_field(proof=True)                                                # needs sage.libs.singular
Traceback (most recent call last):
...
NotImplementedError
sage: S.is_field(proof=False)                                               # needs sage.libs.singular
False
is_integral_domain(proof=True)#

Return True if this ring is an integral domain.

INPUT:

  • proof – (default: True) Determines what to do in unknown cases

ALGORITHM:

If the parameter proof is set to True, the returned value is correct but the method might throw an error. Otherwise, if it is set to False, the method returns True if it can establish that self is an integral domain and False otherwise.

EXAMPLES:

sage: QQ.is_integral_domain()
True
sage: ZZ.is_integral_domain()
True
sage: ZZ['x,y,z'].is_integral_domain()
True
sage: Integers(8).is_integral_domain()
False
sage: Zp(7).is_integral_domain()                                            # needs sage.rings.padics
True
sage: Qp(7).is_integral_domain()                                            # needs sage.rings.padics
True
sage: R.<a,b> = QQ[]
sage: S.<x,y> = R.quo((b^3))                                                # needs sage.libs.singular
sage: S.is_integral_domain()                                                # needs sage.libs.singular
False

This illustrates the use of the proof parameter:

sage: R.<a,b> = ZZ[]
sage: S.<x,y> = R.quo((b^3))                                                # needs sage.libs.singular
sage: S.is_integral_domain(proof=True)                                      # needs sage.libs.singular
Traceback (most recent call last):
...
NotImplementedError
sage: S.is_integral_domain(proof=False)                                     # needs sage.libs.singular
False
is_noetherian()#

Return True if this ring is Noetherian.

EXAMPLES:

sage: QQ.is_noetherian()
True
sage: ZZ.is_noetherian()
True
is_prime_field()#

Return True if this ring is one of the prime fields \(\QQ\) or \(\GF{p}\).

EXAMPLES:

sage: QQ.is_prime_field()
True
sage: GF(3).is_prime_field()
True
sage: GF(9, 'a').is_prime_field()                                           # needs sage.rings.finite_rings
False
sage: ZZ.is_prime_field()
False
sage: QQ['x'].is_prime_field()
False
sage: Qp(19).is_prime_field()                                               # needs sage.rings.padics
False
is_subring(other)#

Return True if the canonical map from self to other is injective.

Raises a NotImplementedError if not known.

EXAMPLES:

sage: ZZ.is_subring(QQ)
True
sage: ZZ.is_subring(GF(19))
False
one()#

Return the one element of this ring (cached), if it exists.

EXAMPLES:

sage: ZZ.one()
1
sage: QQ.one()
1
sage: QQ['x'].one()
1

The result is cached:

sage: ZZ.one() is ZZ.one()
True
order()#

The number of elements of self.

EXAMPLES:

sage: GF(19).order()
19
sage: QQ.order()
+Infinity
principal_ideal(gen, coerce=True)#

Return the principal ideal generated by gen.

EXAMPLES:

sage: R.<x,y> = ZZ[]
sage: R.principal_ideal(x+2*y)
Ideal (x + 2*y) of Multivariate Polynomial Ring in x, y over Integer Ring
random_element(bound=2)#

Return a random integer coerced into this ring, where the integer is chosen uniformly from the interval [-bound,bound].

INPUT:

  • bound – integer (default: 2)

ALGORITHM:

Uses Python’s randint.

unit_ideal()#

Return the unit ideal of this ring.

EXAMPLES:

sage: Zp(7).unit_ideal()                                                    # needs sage.rings.padics
Principal ideal (1 + O(7^20)) of 7-adic Ring with capped relative precision 20
zero()#

Return the zero element of this ring (cached).

EXAMPLES:

sage: ZZ.zero()
0
sage: QQ.zero()
0
sage: QQ['x'].zero()
0

The result is cached:

sage: ZZ.zero() is ZZ.zero()
True
zero_ideal()#

Return the zero ideal of this ring (cached).

EXAMPLES:

sage: ZZ.zero_ideal()
Principal ideal (0) of Integer Ring
sage: QQ.zero_ideal()
Principal ideal (0) of Rational Field
sage: QQ['x'].zero_ideal()
Principal ideal (0) of Univariate Polynomial Ring in x over Rational Field

The result is cached:

sage: ZZ.zero_ideal() is ZZ.zero_ideal()
True
zeta(n=2, all=False)#

Return a primitive n-th root of unity in self if there is one, or raise a ValueError otherwise.

INPUT:

  • n – positive integer

  • all – bool (default: False) - whether to return a list of all primitive \(n\)-th roots of unity. If True, raise a ValueError if self is not an integral domain.

OUTPUT:

Element of self of finite order

EXAMPLES:

sage: QQ.zeta()
-1
sage: QQ.zeta(1)
1
sage: CyclotomicField(6).zeta(6)                                            # needs sage.rings.number_field
zeta6
sage: CyclotomicField(3).zeta(3)                                            # needs sage.rings.number_field
zeta3
sage: CyclotomicField(3).zeta(3).multiplicative_order()                     # needs sage.rings.number_field
3

sage: # needs sage.rings.finite_rings
sage: a = GF(7).zeta(); a
3
sage: a.multiplicative_order()
6
sage: a = GF(49,'z').zeta(); a
z
sage: a.multiplicative_order()
48
sage: a = GF(49,'z').zeta(2); a
6
sage: a.multiplicative_order()
2

sage: QQ.zeta(3)
Traceback (most recent call last):
...
ValueError: no n-th root of unity in rational field
sage: Zp(7, prec=8).zeta()                                                  # needs sage.rings.padics
3 + 4*7 + 6*7^2 + 3*7^3 + 2*7^5 + 6*7^6 + 2*7^7 + O(7^8)
zeta_order()#

Return the order of the distinguished root of unity in self.

EXAMPLES:

sage: CyclotomicField(19).zeta_order()                                      # needs sage.rings.number_field
38
sage: GF(19).zeta_order()
18
sage: GF(5^3,'a').zeta_order()                                              # needs sage.rings.finite_rings
124
sage: Zp(7, prec=8).zeta_order()                                            # needs sage.rings.padics
6
sage.rings.ring.is_Ring(x)#

Return True if x is a ring.

EXAMPLES:

sage: from sage.rings.ring import is_Ring
sage: is_Ring(ZZ)
True
sage: MS = MatrixSpace(QQ, 2)                                                   # needs sage.modules
sage: is_Ring(MS)                                                               # needs sage.modules
True