Noncommutative polynomials via libSINGULAR/Plural¶
This module provides specialized and optimized implementations for noncommutative multivariate polynomials over many coefficient rings, via the shared library interface to SINGULAR. In particular, the following coefficient rings are supported by this implementation:
the rational numbers \(\QQ\), and
finite fields \(\GF{p}\) for \(p\) prime
AUTHORS:
The PLURAL wrapper is due to
Burcin Erocal (2008-11 and 2010-07): initial implementation and concept
Michael Brickenstein (2008-11 and 2010-07): initial implementation and concept
Oleksandr Motsak (2010-07): complete overall noncommutative functionality and first release
Alexander Dreyer (2010-07): noncommutative ring functionality and documentation
Simon King (2011-09): left and two-sided ideals; normal forms; pickling; documentation
The underlying libSINGULAR interface was implemented by
Martin Albrecht (2007-01): initial implementation
Joel Mohler (2008-01): misc improvements, polishing
Martin Albrecht (2008-08): added \(\QQ(a)\) and \(\ZZ\) support
Simon King (2009-04): improved coercion
Martin Albrecht (2009-05): added \(\ZZ/n\ZZ\) support, refactoring
Martin Albrecht (2009-06): refactored the code to allow better re-use
Todo
extend functionality towards those of libSINGULARs commutative part
EXAMPLES:
We show how to construct various noncommutative polynomial rings:
sage: A.<x,y,z> = FreeAlgebra(QQ, 3)
sage: P.<x,y,z> = A.g_algebra(relations={y*x:-x*y}, order = 'lex')
sage: P
Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {y*x: -x*y}
sage: y*x + 1/2
-x*y + 1/2
sage: A.<x,y,z> = FreeAlgebra(GF(17), 3)
sage: P.<x,y,z> = A.g_algebra(relations={y*x:-x*y}, order = 'lex')
sage: P
Noncommutative Multivariate Polynomial Ring in x, y, z over Finite Field of size 17, nc-relations: {y*x: -x*y}
sage: y*x + 7
-x*y + 7
>>> from sage.all import *
>>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3)
>>> P = A.g_algebra(relations={y*x:-x*y}, order = 'lex', names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)
>>> P
Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {y*x: -x*y}
>>> y*x + Integer(1)/Integer(2)
-x*y + 1/2
>>> A = FreeAlgebra(GF(Integer(17)), Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3)
>>> P = A.g_algebra(relations={y*x:-x*y}, order = 'lex', names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)
>>> P
Noncommutative Multivariate Polynomial Ring in x, y, z over Finite Field of size 17, nc-relations: {y*x: -x*y}
>>> y*x + Integer(7)
-x*y + 7
Raw use of this class; this is not the intended use!
sage: from sage.matrix.constructor import Matrix
sage: c = Matrix(3)
sage: c[0,1] = -2
sage: c[0,2] = 1
sage: c[1,2] = 1
sage: d = Matrix(3)
sage: d[0, 1] = 17
sage: P = QQ['x','y','z']
sage: c = c.change_ring(P)
sage: d = d.change_ring(P)
sage: from sage.rings.polynomial.plural import NCPolynomialRing_plural
sage: R.<x,y,z> = NCPolynomialRing_plural(QQ, c = c, d = d, order=TermOrder('lex',3),category=Algebras(QQ))
sage: R
Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {y*x: -2*x*y + 17}
sage: R.term_order()
Lexicographic term order
sage: a,b,c = R.gens()
sage: f = 57 * a^2*b + 43 * c + 1; f
57*x^2*y + 43*z + 1
>>> from sage.all import *
>>> from sage.matrix.constructor import Matrix
>>> c = Matrix(Integer(3))
>>> c[Integer(0),Integer(1)] = -Integer(2)
>>> c[Integer(0),Integer(2)] = Integer(1)
>>> c[Integer(1),Integer(2)] = Integer(1)
>>> d = Matrix(Integer(3))
>>> d[Integer(0), Integer(1)] = Integer(17)
>>> P = QQ['x','y','z']
>>> c = c.change_ring(P)
>>> d = d.change_ring(P)
>>> from sage.rings.polynomial.plural import NCPolynomialRing_plural
>>> R = NCPolynomialRing_plural(QQ, c = c, d = d, order=TermOrder('lex',Integer(3)),category=Algebras(QQ), names=('x', 'y', 'z',)); (x, y, z,) = R._first_ngens(3)
>>> R
Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {y*x: -2*x*y + 17}
>>> R.term_order()
Lexicographic term order
>>> a,b,c = R.gens()
>>> f = Integer(57) * a**Integer(2)*b + Integer(43) * c + Integer(1); f
57*x^2*y + 43*z + 1
- sage.rings.polynomial.plural.ExteriorAlgebra(base_ring, names, order='degrevlex')[source]¶
Return the exterior algebra on some generators.
This is also known as a Grassmann algebra. This is a finite dimensional algebra, where all generators anti-commute.
See Wikipedia article Exterior algebra
INPUT:
base_ring
– the ground ringnames
– list of variable names
EXAMPLES:
sage: from sage.rings.polynomial.plural import ExteriorAlgebra sage: E = ExteriorAlgebra(QQ, ['x', 'y', 'z']) ; E #random Quotient of Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {z*x: -x*z, z*y: -y*z, y*x: -x*y} by the ideal (z^2, y^2, x^2) sage: sorted(E.cover().domain().relations().items(), key=str) [(y*x, -x*y), (z*x, -x*z), (z*y, -y*z)] sage: sorted(E.cover().kernel().gens(),key=str) [x^2, y^2, z^2] sage: E.inject_variables() Defining xbar, ybar, zbar sage: x,y,z = (xbar,ybar,zbar) sage: y*x -x*y sage: all(v^2==0 for v in E.gens()) True sage: E.one() 1
>>> from sage.all import * >>> from sage.rings.polynomial.plural import ExteriorAlgebra >>> E = ExteriorAlgebra(QQ, ['x', 'y', 'z']) ; E #random Quotient of Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {z*x: -x*z, z*y: -y*z, y*x: -x*y} by the ideal (z^2, y^2, x^2) >>> sorted(E.cover().domain().relations().items(), key=str) [(y*x, -x*y), (z*x, -x*z), (z*y, -y*z)] >>> sorted(E.cover().kernel().gens(),key=str) [x^2, y^2, z^2] >>> E.inject_variables() Defining xbar, ybar, zbar >>> x,y,z = (xbar,ybar,zbar) >>> y*x -x*y >>> all(v**Integer(2)==Integer(0) for v in E.gens()) True >>> E.one() 1
- class sage.rings.polynomial.plural.ExteriorAlgebra_plural[source]¶
Bases:
NCPolynomialRing_plural
- class sage.rings.polynomial.plural.G_AlgFactory[source]¶
Bases:
UniqueFactory
A factory for the creation of g-algebras as unique parents.
- create_key_and_extra_args(base_ring, c, d, names=None, order=None, category=None, check=None, commutative=None)[source]¶
Create a unique key for g-algebras.
INPUT:
base_ring
– a ringc
,d
– two matricesnames
– tuple or list of namesorder
– (optional) term ordercategory
– (optional) categorycheck
– (optional) booleancommutative
– (optional) boolean
- create_object(version, key, **extra_args)[source]¶
Create a g-algebra to a given unique key.
INPUT:
key
– a 6-tuple, formed by a base ring, a tuple of names, two matrices over a polynomial ring over the base ring with the given variable names, a term order, and a categoryextra_args
– dictionary, whose only relevant key is ‘check’
- class sage.rings.polynomial.plural.NCPolynomialRing_plural[source]¶
Bases:
Ring
A non-commutative polynomial ring.
EXAMPLES:
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: H = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) sage: H._is_category_initialized() True sage: H.category() Category of algebras over Rational Field sage: TestSuite(H).run()
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> H = A.g_algebra({y*x:x*y-z, z*x:x*z+Integer(2)*x, z*y:y*z-Integer(2)*y}) >>> H._is_category_initialized() True >>> H.category() Category of algebras over Rational Field >>> TestSuite(H).run()
Note that two variables commute if they are not part of the given relations:
sage: H.<x,y,z> = A.g_algebra({z*x:x*z+2*x, z*y:y*z-2*y}) sage: x*y == y*x True
>>> from sage.all import * >>> H = A.g_algebra({z*x:x*z+Integer(2)*x, z*y:y*z-Integer(2)*y}, names=('x', 'y', 'z',)); (x, y, z,) = H._first_ngens(3) >>> x*y == y*x True
- algebra_generators()[source]¶
Return the algebra generators of
self
.EXAMPLES:
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: P = A.g_algebra(relations={y*x:-x*y}, order='lex') sage: P.algebra_generators() Finite family {'x': x, 'y': y, 'z': z}
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> P = A.g_algebra(relations={y*x:-x*y}, order='lex') >>> P.algebra_generators() Finite family {'x': x, 'y': y, 'z': z}
- free_algebra()[source]¶
Return the free algebra of which this is the quotient.
EXAMPLES:
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: P = A.g_algebra(relations={y*x:-x*y}, order = 'lex') sage: B = P.free_algebra() sage: A == B True
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> P = A.g_algebra(relations={y*x:-x*y}, order = 'lex') >>> B = P.free_algebra() >>> A == B True
- gen(n=0)[source]¶
Return the
n
-th generator of this noncommutative polynomial ring.INPUT:
n
– nonnegative integer
EXAMPLES:
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: P = A.g_algebra(relations={y*x:-x*y}, order = 'lex') sage: P.gen(),P.gen(1) (x, y)
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> P = A.g_algebra(relations={y*x:-x*y}, order = 'lex') >>> P.gen(),P.gen(Integer(1)) (x, y)
Note that the generators are not cached:
sage: P.gen(1) is P.gen(1) False
>>> from sage.all import * >>> P.gen(Integer(1)) is P.gen(Integer(1)) False
- ideal(*gens, **kwds)[source]¶
Create an ideal in this polynomial ring.
INPUT:
*gens
– list or tuple of generators (or several input arguments)coerce
– boolean (default:True
); this must be a keyword argument. Only set it toFalse
if you are certain that each generator is already in the ring.side
– string (either “left”, which is the default, or “twosided”) Must be a keyword argument. Defines whether the ideal is a left ideal or a two-sided ideal. Right ideals are not implemented.
EXAMPLES:
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: P.<x,y,z> = A.g_algebra(relations={y*x:-x*y}, order = 'lex') sage: P.ideal([x + 2*y + 2*z-1, 2*x*y + 2*y*z-y, x^2 + 2*y^2 + 2*z^2-x]) Left Ideal (x + 2*y + 2*z - 1, 2*x*y + 2*y*z - y, x^2 - x + 2*y^2 + 2*z^2) of Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {y*x: -x*y} sage: P.ideal([x + 2*y + 2*z-1, 2*x*y + 2*y*z-y, x^2 + 2*y^2 + 2*z^2-x], side='twosided') Twosided Ideal (x + 2*y + 2*z - 1, 2*x*y + 2*y*z - y, x^2 - x + 2*y^2 + 2*z^2) of Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {y*x: -x*y}
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> P = A.g_algebra(relations={y*x:-x*y}, order = 'lex', names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3) >>> P.ideal([x + Integer(2)*y + Integer(2)*z-Integer(1), Integer(2)*x*y + Integer(2)*y*z-y, x**Integer(2) + Integer(2)*y**Integer(2) + Integer(2)*z**Integer(2)-x]) Left Ideal (x + 2*y + 2*z - 1, 2*x*y + 2*y*z - y, x^2 - x + 2*y^2 + 2*z^2) of Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {y*x: -x*y} >>> P.ideal([x + Integer(2)*y + Integer(2)*z-Integer(1), Integer(2)*x*y + Integer(2)*y*z-y, x**Integer(2) + Integer(2)*y**Integer(2) + Integer(2)*z**Integer(2)-x], side='twosided') Twosided Ideal (x + 2*y + 2*z - 1, 2*x*y + 2*y*z - y, x^2 - x + 2*y^2 + 2*z^2) of Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {y*x: -x*y}
- is_field(*args, **kwargs)[source]¶
Return
False
.EXAMPLES:
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: P = A.g_algebra(relations={y*x:-x*y}, order = 'lex') sage: P.is_field() False
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> P = A.g_algebra(relations={y*x:-x*y}, order = 'lex') >>> P.is_field() False
- monomial_all_divisors(t)[source]¶
Return a list of all monomials that divide
t
.Coefficients are ignored.
INPUT:
t
– a monomial
OUTPUT: list of monomials
EXAMPLES:
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: P = A.g_algebra(relations={y*x:-x*y}, order='lex') sage: P.inject_variables() Defining x, y, z sage: P.monomial_all_divisors(x^2*z^3) [x, x^2, z, x*z, x^2*z, z^2, x*z^2, x^2*z^2, z^3, x*z^3, x^2*z^3]
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> P = A.g_algebra(relations={y*x:-x*y}, order='lex') >>> P.inject_variables() Defining x, y, z >>> P.monomial_all_divisors(x**Integer(2)*z**Integer(3)) [x, x^2, z, x*z, x^2*z, z^2, x*z^2, x^2*z^2, z^3, x*z^3, x^2*z^3]
ALGORITHM: addwithcarry idea by Toon Segers
- monomial_divides(a, b)[source]¶
Return
False
ifa
does not divideb
andTrue
otherwise.Coefficients are ignored.
INPUT:
a
– monomialb
– monomial
EXAMPLES:
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: P = A.g_algebra(relations={y*x:-x*y}, order='lex') sage: P.inject_variables() Defining x, y, z sage: P.monomial_divides(x*y*z, x^3*y^2*z^4) True sage: P.monomial_divides(x^3*y^2*z^4, x*y*z) False
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> P = A.g_algebra(relations={y*x:-x*y}, order='lex') >>> P.inject_variables() Defining x, y, z >>> P.monomial_divides(x*y*z, x**Integer(3)*y**Integer(2)*z**Integer(4)) True >>> P.monomial_divides(x**Integer(3)*y**Integer(2)*z**Integer(4), x*y*z) False
- monomial_lcm(f, g)[source]¶
LCM for monomials. Coefficients are ignored.
INPUT:
f
– monomialg
– monomial
EXAMPLES:
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: P = A.g_algebra(relations={y*x:-x*y}, order='lex') sage: P.inject_variables() Defining x, y, z sage: P.monomial_lcm(3/2*x*y,x) x*y
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> P = A.g_algebra(relations={y*x:-x*y}, order='lex') >>> P.inject_variables() Defining x, y, z >>> P.monomial_lcm(Integer(3)/Integer(2)*x*y,x) x*y
- monomial_pairwise_prime(g, h)[source]¶
Return
True
ifh
andg
are pairwise prime.Both
h
andg
are treated as monomials.Coefficients are ignored.
INPUT:
h
– monomialg
– monomial
EXAMPLES:
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: P = A.g_algebra(relations={y*x:-x*y}, order='lex') sage: P.inject_variables() Defining x, y, z sage: P.monomial_pairwise_prime(x^2*z^3, y^4) True sage: P.monomial_pairwise_prime(1/2*x^3*y^2, 3/4*y^3) False
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> P = A.g_algebra(relations={y*x:-x*y}, order='lex') >>> P.inject_variables() Defining x, y, z >>> P.monomial_pairwise_prime(x**Integer(2)*z**Integer(3), y**Integer(4)) True >>> P.monomial_pairwise_prime(Integer(1)/Integer(2)*x**Integer(3)*y**Integer(2), Integer(3)/Integer(4)*y**Integer(3)) False
- monomial_quotient(f, g, coeff=False)[source]¶
Return
f/g
, where bothf
andg
are treated as monomials.Coefficients are ignored by default.
INPUT:
f
– monomialg
– monomialcoeff
– divide coefficients as well (default:False
)
EXAMPLES:
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: P = A.g_algebra(relations={y*x:-x*y}, order='lex') sage: P.inject_variables() Defining x, y, z sage: P.monomial_quotient(3/2*x*y,x,coeff=True) 3/2*y
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> P = A.g_algebra(relations={y*x:-x*y}, order='lex') >>> P.inject_variables() Defining x, y, z >>> P.monomial_quotient(Integer(3)/Integer(2)*x*y,x,coeff=True) 3/2*y
Note that \(\ZZ\) behaves differently if
coeff=True
:sage: P.monomial_quotient(2*x,3*x) 1 sage: P.monomial_quotient(2*x,3*x,coeff=True) 2/3
>>> from sage.all import * >>> P.monomial_quotient(Integer(2)*x,Integer(3)*x) 1 >>> P.monomial_quotient(Integer(2)*x,Integer(3)*x,coeff=True) 2/3
Warning
Assumes that the head term of f is a multiple of the head term of g and return the multiplicant m. If this rule is violated, funny things may happen.
- monomial_reduce(f, G)[source]¶
Try to find a
g
inG
whereg.lm()
dividesf
. If found(flt,g)
is returned,(0,0)
otherwise, whereflt
isf/g.lm()
.It is assumed that
G
is iterable and contains only elements in this polynomial ring.Coefficients are ignored.
INPUT:
f
– monomialG
– list/set of mpolynomials
EXAMPLES:
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: P = A.g_algebra(relations={y*x:-x*y}, order='lex') sage: P.inject_variables() Defining x, y, z sage: f = x*y^2 sage: G = [ 3/2*x^3 + y^2 + 1/2, 1/4*x*y + 2/7, 1/2 ] sage: P.monomial_reduce(f,G) (y, 1/4*x*y + 2/7)
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> P = A.g_algebra(relations={y*x:-x*y}, order='lex') >>> P.inject_variables() Defining x, y, z >>> f = x*y**Integer(2) >>> G = [ Integer(3)/Integer(2)*x**Integer(3) + y**Integer(2) + Integer(1)/Integer(2), Integer(1)/Integer(4)*x*y + Integer(2)/Integer(7), Integer(1)/Integer(2) ] >>> P.monomial_reduce(f,G) (y, 1/4*x*y + 2/7)
- ngens()[source]¶
Return the number of variables in this noncommutative polynomial ring.
EXAMPLES:
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: P.<x,y,z> = A.g_algebra(relations={y*x:-x*y}, order = 'lex') sage: P.ngens() 3
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> P = A.g_algebra(relations={y*x:-x*y}, order = 'lex', names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3) >>> P.ngens() 3
- relations(add_commutative=False)[source]¶
Return the relations of this g-algebra.
INPUT:
add_commutative
– boolean (default:False
)
OUTPUT:
The defining relations. There are some implicit relations: Two generators commute if they are not part of any given relation. The implicit relations are not provided, unless
add_commutative==True
.EXAMPLES:
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: H.<x,y,z> = A.g_algebra({z*x:x*z+2*x, z*y:y*z-2*y}) sage: x*y == y*x True sage: H.relations() {z*x: x*z + 2*x, z*y: y*z - 2*y} sage: H.relations(add_commutative=True) {y*x: x*y, z*x: x*z + 2*x, z*y: y*z - 2*y}
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> H = A.g_algebra({z*x:x*z+Integer(2)*x, z*y:y*z-Integer(2)*y}, names=('x', 'y', 'z',)); (x, y, z,) = H._first_ngens(3) >>> x*y == y*x True >>> H.relations() {z*x: x*z + 2*x, z*y: y*z - 2*y} >>> H.relations(add_commutative=True) {y*x: x*y, z*x: x*z + 2*x, z*y: y*z - 2*y}
- term_order()[source]¶
Return the term ordering of the noncommutative ring.
EXAMPLES:
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: P = A.g_algebra(relations={y*x:-x*y}, order = 'lex') sage: P.term_order() Lexicographic term order sage: P = A.g_algebra(relations={y*x:-x*y}) sage: P.term_order() Degree reverse lexicographic term order
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> P = A.g_algebra(relations={y*x:-x*y}, order = 'lex') >>> P.term_order() Lexicographic term order >>> P = A.g_algebra(relations={y*x:-x*y}) >>> P.term_order() Degree reverse lexicographic term order
- class sage.rings.polynomial.plural.NCPolynomial_plural[source]¶
Bases:
RingElement
A noncommutative multivariate polynomial implemented using libSINGULAR.
- coefficient(degrees)[source]¶
Return the coefficient of the variables with the degrees specified in the python dictionary
degrees
.Mathematically, this is the coefficient in the base ring adjoined by the variables of this ring not listed in
degrees
. However, the result has the same parent as this polynomial.This function contrasts with the function
monomial_coefficient()
which returns the coefficient in the base ring of a monomial.INPUT:
degrees
– can be any of: - a dictionary of degree restrictions - a list of degree restrictions (withNone
in the unrestricted variables) - a monomial (very fast, but not as flexible)
OUTPUT: element of the parent of this element
Note
For coefficients of specific monomials, look at
monomial_coefficient()
.EXAMPLES:
sage: A.<x,z,y> = FreeAlgebra(QQ, 3) sage: R = A.g_algebra(relations={y*x:-x*y + z}, order='lex') sage: R.inject_variables() Defining x, z, y sage: f=x*y+y+5 sage: f.coefficient({x:0,y:1}) 1 sage: f.coefficient({x:0}) y + 5 sage: f=(1+y+y^2)*(1+x+x^2) sage: f.coefficient({x:0}) z + y^2 + y + 1 sage: f.coefficient(x) y^2 - y + 1 sage: f.coefficient([0,None]) # not tested y^2 + y + 1
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'z', 'y',)); (x, z, y,) = A._first_ngens(3) >>> R = A.g_algebra(relations={y*x:-x*y + z}, order='lex') >>> R.inject_variables() Defining x, z, y >>> f=x*y+y+Integer(5) >>> f.coefficient({x:Integer(0),y:Integer(1)}) 1 >>> f.coefficient({x:Integer(0)}) y + 5 >>> f=(Integer(1)+y+y**Integer(2))*(Integer(1)+x+x**Integer(2)) >>> f.coefficient({x:Integer(0)}) z + y^2 + y + 1 >>> f.coefficient(x) y^2 - y + 1 >>> f.coefficient([Integer(0),None]) # not tested y^2 + y + 1
Be aware that this may not be what you think! The physical appearance of the variable x is deceiving – particularly if the exponent would be a variable.
sage: f.coefficient(x^0) # outputs the full polynomial x^2*y^2 + x^2*y + x^2 + x*y^2 - x*y + x + z + y^2 + y + 1 sage: A.<x,z,y> = FreeAlgebra(GF(389), 3) sage: R = A.g_algebra(relations={y*x:-x*y + z}, order='lex') sage: R.inject_variables() Defining x, z, y sage: f=x*y+5 sage: c=f.coefficient({x:0,y:0}); c 5 sage: parent(c) Noncommutative Multivariate Polynomial Ring in x, z, y over Finite Field of size 389, nc-relations: {y*x: -x*y + z}
>>> from sage.all import * >>> f.coefficient(x**Integer(0)) # outputs the full polynomial x^2*y^2 + x^2*y + x^2 + x*y^2 - x*y + x + z + y^2 + y + 1 >>> A = FreeAlgebra(GF(Integer(389)), Integer(3), names=('x', 'z', 'y',)); (x, z, y,) = A._first_ngens(3) >>> R = A.g_algebra(relations={y*x:-x*y + z}, order='lex') >>> R.inject_variables() Defining x, z, y >>> f=x*y+Integer(5) >>> c=f.coefficient({x:Integer(0),y:Integer(0)}); c 5 >>> parent(c) Noncommutative Multivariate Polynomial Ring in x, z, y over Finite Field of size 389, nc-relations: {y*x: -x*y + z}
AUTHOR:
Joel B. Mohler (2007-10-31)
- constant_coefficient()[source]¶
Return the constant coefficient of this multivariate polynomial.
EXAMPLES:
sage: A.<x,z,y> = FreeAlgebra(GF(389), 3) sage: P = A.g_algebra(relations={y*x:-x*y + z}, order='lex') sage: P.inject_variables() Defining x, z, y sage: f = 3*x^2 - 2*y + 7*x^2*y^2 + 5 sage: f.constant_coefficient() 5 sage: f = 3*x^2 sage: f.constant_coefficient() 0
>>> from sage.all import * >>> A = FreeAlgebra(GF(Integer(389)), Integer(3), names=('x', 'z', 'y',)); (x, z, y,) = A._first_ngens(3) >>> P = A.g_algebra(relations={y*x:-x*y + z}, order='lex') >>> P.inject_variables() Defining x, z, y >>> f = Integer(3)*x**Integer(2) - Integer(2)*y + Integer(7)*x**Integer(2)*y**Integer(2) + Integer(5) >>> f.constant_coefficient() 5 >>> f = Integer(3)*x**Integer(2) >>> f.constant_coefficient() 0
- degree(x=None)[source]¶
Return the maximal degree of this polynomial in
x
, wherex
must be one of the generators for the parent of this polynomial.INPUT:
x
– multivariate polynomial (a generator of the parent of self) If x is not specified (or isNone
), return the total degree, which is the maximum degree of any monomial.
OUTPUT: integer
EXAMPLES:
sage: A.<x,z,y> = FreeAlgebra(QQ, 3) sage: R = A.g_algebra(relations={y*x:-x*y + z}, order='lex') sage: R.inject_variables() Defining x, z, y sage: f = y^2 - x^9 - x sage: f.degree(x) 9 sage: f.degree(y) 2 sage: (y^10*x - 7*x^2*y^5 + 5*x^3).degree(x) 3 sage: (y^10*x - 7*x^2*y^5 + 5*x^3).degree(y) 10
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'z', 'y',)); (x, z, y,) = A._first_ngens(3) >>> R = A.g_algebra(relations={y*x:-x*y + z}, order='lex') >>> R.inject_variables() Defining x, z, y >>> f = y**Integer(2) - x**Integer(9) - x >>> f.degree(x) 9 >>> f.degree(y) 2 >>> (y**Integer(10)*x - Integer(7)*x**Integer(2)*y**Integer(5) + Integer(5)*x**Integer(3)).degree(x) 3 >>> (y**Integer(10)*x - Integer(7)*x**Integer(2)*y**Integer(5) + Integer(5)*x**Integer(3)).degree(y) 10
- degrees()[source]¶
Return a tuple with the maximal degree of each variable in this polynomial.
The list of degrees is ordered by the order of the generators.
EXAMPLES:
sage: A.<y0,y1,y2> = FreeAlgebra(QQ, 3) sage: R = A.g_algebra(relations={y1*y0:-y0*y1 + y2}, order='lex') sage: R.inject_variables() Defining y0, y1, y2 sage: q = 3*y0*y1*y1*y2; q 3*y0*y1^2*y2 sage: q.degrees() (1, 2, 1) sage: (q + y0^5).degrees() (5, 2, 1)
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('y0', 'y1', 'y2',)); (y0, y1, y2,) = A._first_ngens(3) >>> R = A.g_algebra(relations={y1*y0:-y0*y1 + y2}, order='lex') >>> R.inject_variables() Defining y0, y1, y2 >>> q = Integer(3)*y0*y1*y1*y2; q 3*y0*y1^2*y2 >>> q.degrees() (1, 2, 1) >>> (q + y0**Integer(5)).degrees() (5, 2, 1)
- dict()[source]¶
Return a dictionary representing
self
. This dictionary is in the same format as the generic MPolynomial: The dictionary consists ofETuple:coefficient
pairs.EXAMPLES:
sage: A.<x,z,y> = FreeAlgebra(GF(389), 3) sage: R = A.g_algebra(relations={y*x:-x*y + z}, order='lex') sage: R.inject_variables() Defining x, z, y sage: f = (2*x*y^3*z^2 + (7)*x^2 + (3)) sage: f.dict() {(0, 0, 0): 3, (1, 2, 3): 2, (2, 0, 0): 7} sage: f.monomial_coefficients() {(0, 0, 0): 3, (1, 2, 3): 2, (2, 0, 0): 7}
>>> from sage.all import * >>> A = FreeAlgebra(GF(Integer(389)), Integer(3), names=('x', 'z', 'y',)); (x, z, y,) = A._first_ngens(3) >>> R = A.g_algebra(relations={y*x:-x*y + z}, order='lex') >>> R.inject_variables() Defining x, z, y >>> f = (Integer(2)*x*y**Integer(3)*z**Integer(2) + (Integer(7))*x**Integer(2) + (Integer(3))) >>> f.dict() {(0, 0, 0): 3, (1, 2, 3): 2, (2, 0, 0): 7} >>> f.monomial_coefficients() {(0, 0, 0): 3, (1, 2, 3): 2, (2, 0, 0): 7}
- exponents(as_ETuples=True)[source]¶
Return the exponents of the monomials appearing in this polynomial.
INPUT:
as_ETuples
– boolean (default:True
); ifTrue
returns the result as an list of ETuples, otherwise returns a list of tuples
EXAMPLES:
sage: A.<x,z,y> = FreeAlgebra(GF(389), 3) sage: R = A.g_algebra(relations={y*x:-x*y + z}, order='lex') sage: R.inject_variables() Defining x, z, y sage: f = x^3 + y + 2*z^2 sage: f.exponents() [(3, 0, 0), (0, 2, 0), (0, 0, 1)] sage: f.exponents(as_ETuples=False) [(3, 0, 0), (0, 2, 0), (0, 0, 1)]
>>> from sage.all import * >>> A = FreeAlgebra(GF(Integer(389)), Integer(3), names=('x', 'z', 'y',)); (x, z, y,) = A._first_ngens(3) >>> R = A.g_algebra(relations={y*x:-x*y + z}, order='lex') >>> R.inject_variables() Defining x, z, y >>> f = x**Integer(3) + y + Integer(2)*z**Integer(2) >>> f.exponents() [(3, 0, 0), (0, 2, 0), (0, 0, 1)] >>> f.exponents(as_ETuples=False) [(3, 0, 0), (0, 2, 0), (0, 0, 1)]
- is_constant()[source]¶
Return
True
if this polynomial is constant.EXAMPLES:
sage: A.<x,z,y> = FreeAlgebra(GF(389), 3) sage: P = A.g_algebra(relations={y*x:-x*y + z}, order='lex') sage: P.inject_variables() Defining x, z, y sage: x.is_constant() False sage: P(1).is_constant() True
>>> from sage.all import * >>> A = FreeAlgebra(GF(Integer(389)), Integer(3), names=('x', 'z', 'y',)); (x, z, y,) = A._first_ngens(3) >>> P = A.g_algebra(relations={y*x:-x*y + z}, order='lex') >>> P.inject_variables() Defining x, z, y >>> x.is_constant() False >>> P(Integer(1)).is_constant() True
- is_homogeneous()[source]¶
Return
True
if this polynomial is homogeneous.EXAMPLES:
sage: A.<x,z,y> = FreeAlgebra(GF(389), 3) sage: P = A.g_algebra(relations={y*x:-x*y + z}, order='lex') sage: P.inject_variables() Defining x, z, y sage: (x+y+z).is_homogeneous() True sage: (x.parent()(0)).is_homogeneous() True sage: (x+y^2+z^3).is_homogeneous() False sage: (x^2 + y^2).is_homogeneous() True sage: (x^2 + y^2*x).is_homogeneous() False sage: (x^2*y + y^2*x).is_homogeneous() True
>>> from sage.all import * >>> A = FreeAlgebra(GF(Integer(389)), Integer(3), names=('x', 'z', 'y',)); (x, z, y,) = A._first_ngens(3) >>> P = A.g_algebra(relations={y*x:-x*y + z}, order='lex') >>> P.inject_variables() Defining x, z, y >>> (x+y+z).is_homogeneous() True >>> (x.parent()(Integer(0))).is_homogeneous() True >>> (x+y**Integer(2)+z**Integer(3)).is_homogeneous() False >>> (x**Integer(2) + y**Integer(2)).is_homogeneous() True >>> (x**Integer(2) + y**Integer(2)*x).is_homogeneous() False >>> (x**Integer(2)*y + y**Integer(2)*x).is_homogeneous() True
- is_monomial()[source]¶
Return
True
if this polynomial is a monomial.A monomial is defined to be a product of generators with coefficient 1.
EXAMPLES:
sage: A.<x,z,y> = FreeAlgebra(GF(389), 3) sage: P = A.g_algebra(relations={y*x:-x*y + z}, order='lex') sage: P.inject_variables() Defining x, z, y sage: x.is_monomial() True sage: (2*x).is_monomial() False sage: (x*y).is_monomial() True sage: (x*y + x).is_monomial() False
>>> from sage.all import * >>> A = FreeAlgebra(GF(Integer(389)), Integer(3), names=('x', 'z', 'y',)); (x, z, y,) = A._first_ngens(3) >>> P = A.g_algebra(relations={y*x:-x*y + z}, order='lex') >>> P.inject_variables() Defining x, z, y >>> x.is_monomial() True >>> (Integer(2)*x).is_monomial() False >>> (x*y).is_monomial() True >>> (x*y + x).is_monomial() False
- is_zero()[source]¶
Return
True
if this polynomial is zero.EXAMPLES:
sage: A.<x,z,y> = FreeAlgebra(QQ, 3) sage: R = A.g_algebra(relations={y*x:-x*y + z}, order='lex') sage: R.inject_variables() Defining x, z, y sage: x.is_zero() False sage: (x-x).is_zero() True
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'z', 'y',)); (x, z, y,) = A._first_ngens(3) >>> R = A.g_algebra(relations={y*x:-x*y + z}, order='lex') >>> R.inject_variables() Defining x, z, y >>> x.is_zero() False >>> (x-x).is_zero() True
- lc()[source]¶
Leading coefficient of this polynomial with respect to the term order of
self.parent()
.EXAMPLES:
sage: A.<x,y,z> = FreeAlgebra(GF(7), 3) sage: R = A.g_algebra(relations={y*x:-x*y + z}, order='lex') sage: R.inject_variables() Defining x, y, z sage: f = 3*x^1*y^2 + 2*y^3*z^4 sage: f.lc() 3 sage: f = 5*x^3*y^2*z^4 + 4*x^3*y^2*z^1 sage: f.lc() 5
>>> from sage.all import * >>> A = FreeAlgebra(GF(Integer(7)), Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> R = A.g_algebra(relations={y*x:-x*y + z}, order='lex') >>> R.inject_variables() Defining x, y, z >>> f = Integer(3)*x**Integer(1)*y**Integer(2) + Integer(2)*y**Integer(3)*z**Integer(4) >>> f.lc() 3 >>> f = Integer(5)*x**Integer(3)*y**Integer(2)*z**Integer(4) + Integer(4)*x**Integer(3)*y**Integer(2)*z**Integer(1) >>> f.lc() 5
- lm()[source]¶
Return the lead monomial of
self
with respect to the term order ofself.parent()
.In Sage, a monomial is a product of variables in some power without a coefficient.
EXAMPLES:
sage: A.<x,y,z> = FreeAlgebra(GF(7), 3) sage: R = A.g_algebra(relations={y*x:-x*y + z}, order='lex') sage: R.inject_variables() Defining x, y, z sage: f = x^1*y^2 + y^3*z^4 sage: f.lm() x*y^2 sage: f = x^3*y^2*z^4 + x^3*y^2*z^1 sage: f.lm() x^3*y^2*z^4 sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: R = A.g_algebra(relations={y*x:-x*y + z}, order='deglex') sage: R.inject_variables() Defining x, y, z sage: f = x^1*y^2*z^3 + x^3*y^2*z^0 sage: f.lm() x*y^2*z^3 sage: f = x^1*y^2*z^4 + x^1*y^1*z^5 sage: f.lm() x*y^2*z^4 sage: A.<x,y,z> = FreeAlgebra(GF(127), 3) sage: R = A.g_algebra(relations={y*x:-x*y + z}, order='degrevlex') sage: R.inject_variables() Defining x, y, z sage: f = x^1*y^5*z^2 + x^4*y^1*z^3 sage: f.lm() x*y^5*z^2 sage: f = x^4*y^7*z^1 + x^4*y^2*z^3 sage: f.lm() x^4*y^7*z
>>> from sage.all import * >>> A = FreeAlgebra(GF(Integer(7)), Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> R = A.g_algebra(relations={y*x:-x*y + z}, order='lex') >>> R.inject_variables() Defining x, y, z >>> f = x**Integer(1)*y**Integer(2) + y**Integer(3)*z**Integer(4) >>> f.lm() x*y^2 >>> f = x**Integer(3)*y**Integer(2)*z**Integer(4) + x**Integer(3)*y**Integer(2)*z**Integer(1) >>> f.lm() x^3*y^2*z^4 >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> R = A.g_algebra(relations={y*x:-x*y + z}, order='deglex') >>> R.inject_variables() Defining x, y, z >>> f = x**Integer(1)*y**Integer(2)*z**Integer(3) + x**Integer(3)*y**Integer(2)*z**Integer(0) >>> f.lm() x*y^2*z^3 >>> f = x**Integer(1)*y**Integer(2)*z**Integer(4) + x**Integer(1)*y**Integer(1)*z**Integer(5) >>> f.lm() x*y^2*z^4 >>> A = FreeAlgebra(GF(Integer(127)), Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> R = A.g_algebra(relations={y*x:-x*y + z}, order='degrevlex') >>> R.inject_variables() Defining x, y, z >>> f = x**Integer(1)*y**Integer(5)*z**Integer(2) + x**Integer(4)*y**Integer(1)*z**Integer(3) >>> f.lm() x*y^5*z^2 >>> f = x**Integer(4)*y**Integer(7)*z**Integer(1) + x**Integer(4)*y**Integer(2)*z**Integer(3) >>> f.lm() x^4*y^7*z
- lt()[source]¶
Return the leading term of this polynomial.
In Sage, a term is a product of variables in some power and a coefficient.
EXAMPLES:
sage: A.<x,y,z> = FreeAlgebra(GF(7), 3) sage: R = A.g_algebra(relations={y*x:-x*y + z}, order='lex') sage: R.inject_variables() Defining x, y, z sage: f = 3*x^1*y^2 + 2*y^3*z^4 sage: f.lt() 3*x*y^2 sage: f = 5*x^3*y^2*z^4 + 4*x^3*y^2*z^1 sage: f.lt() -2*x^3*y^2*z^4
>>> from sage.all import * >>> A = FreeAlgebra(GF(Integer(7)), Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> R = A.g_algebra(relations={y*x:-x*y + z}, order='lex') >>> R.inject_variables() Defining x, y, z >>> f = Integer(3)*x**Integer(1)*y**Integer(2) + Integer(2)*y**Integer(3)*z**Integer(4) >>> f.lt() 3*x*y^2 >>> f = Integer(5)*x**Integer(3)*y**Integer(2)*z**Integer(4) + Integer(4)*x**Integer(3)*y**Integer(2)*z**Integer(1) >>> f.lt() -2*x^3*y^2*z^4
- monomial_coefficient(mon)[source]¶
Return the coefficient in the base ring of the monomial
mon
inself
, wheremon
must have the same parent asself
.This function contrasts with the function
coefficient()
which returns the coefficient of a monomial viewing this polynomial in a polynomial ring over a base ring having fewer variables.INPUT:
mon
– a monomial
OUTPUT: coefficient in base ring
See also
For coefficients in a base ring of fewer variables, look at
coefficient()
EXAMPLES:
sage: A.<x,z,y> = FreeAlgebra(GF(389), 3) sage: P = A.g_algebra(relations={y*x:-x*y + z}, order='lex') sage: P.inject_variables() Defining x, z, y The parent of the return is a member of the base ring. sage: f = 2 * x * y sage: c = f.monomial_coefficient(x*y); c 2 sage: c.parent() Finite Field of size 389 sage: f = y^2 + y^2*x - x^9 - 7*x + 5*x*y sage: f.monomial_coefficient(y^2) 1 sage: f.monomial_coefficient(x*y) 5 sage: f.monomial_coefficient(x^9) 388 sage: f.monomial_coefficient(x^10) 0
>>> from sage.all import * >>> A = FreeAlgebra(GF(Integer(389)), Integer(3), names=('x', 'z', 'y',)); (x, z, y,) = A._first_ngens(3) >>> P = A.g_algebra(relations={y*x:-x*y + z}, order='lex') >>> P.inject_variables() Defining x, z, y The parent of the return is a member of the base ring. >>> f = Integer(2) * x * y >>> c = f.monomial_coefficient(x*y); c 2 >>> c.parent() Finite Field of size 389 >>> f = y**Integer(2) + y**Integer(2)*x - x**Integer(9) - Integer(7)*x + Integer(5)*x*y >>> f.monomial_coefficient(y**Integer(2)) 1 >>> f.monomial_coefficient(x*y) 5 >>> f.monomial_coefficient(x**Integer(9)) 388 >>> f.monomial_coefficient(x**Integer(10)) 0
- monomial_coefficients(copy=True)[source]¶
Return a dictionary representation of
self
with the keys the exponent vectors and the values the corresponding coefficients.INPUT:
copy
– ignored
EXAMPLES:
sage: A.<x,z,y> = FreeAlgebra(GF(389), 3) sage: R = A.g_algebra(relations={y*x:-x*y + z}, order='lex') sage: R.inject_variables() Defining x, z, y sage: f = (2*x*y^3*z^2 + (7)*x^2 + (3)) sage: d = f.monomial_coefficients(False); d {(0, 0, 0): 3, (1, 2, 3): 2, (2, 0, 0): 7} sage: d.clear() sage: f.monomial_coefficients() {(0, 0, 0): 3, (1, 2, 3): 2, (2, 0, 0): 7}
>>> from sage.all import * >>> A = FreeAlgebra(GF(Integer(389)), Integer(3), names=('x', 'z', 'y',)); (x, z, y,) = A._first_ngens(3) >>> R = A.g_algebra(relations={y*x:-x*y + z}, order='lex') >>> R.inject_variables() Defining x, z, y >>> f = (Integer(2)*x*y**Integer(3)*z**Integer(2) + (Integer(7))*x**Integer(2) + (Integer(3))) >>> d = f.monomial_coefficients(False); d {(0, 0, 0): 3, (1, 2, 3): 2, (2, 0, 0): 7} >>> d.clear() >>> f.monomial_coefficients() {(0, 0, 0): 3, (1, 2, 3): 2, (2, 0, 0): 7}
- monomials()[source]¶
Return the list of monomials in
self
.The returned list is decreasingly ordered by the term ordering of
self.parent()
.EXAMPLES:
sage: A.<x,z,y> = FreeAlgebra(GF(389), 3) sage: P = A.g_algebra(relations={y*x:-x*y + z}, order='lex') sage: P.inject_variables() Defining x, z, y sage: f = x + (3*2)*y*z^2 + (2+3) sage: f.monomials() [x, z^2*y, 1] sage: f = P(3^2) sage: f.monomials() [1]
>>> from sage.all import * >>> A = FreeAlgebra(GF(Integer(389)), Integer(3), names=('x', 'z', 'y',)); (x, z, y,) = A._first_ngens(3) >>> P = A.g_algebra(relations={y*x:-x*y + z}, order='lex') >>> P.inject_variables() Defining x, z, y >>> f = x + (Integer(3)*Integer(2))*y*z**Integer(2) + (Integer(2)+Integer(3)) >>> f.monomials() [x, z^2*y, 1] >>> f = P(Integer(3)**Integer(2)) >>> f.monomials() [1]
- reduce(I)[source]¶
EXAMPLES:
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: H.<x,y,z> = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) sage: I = H.ideal([y^2, x^2, z^2-H.one()],coerce=False)
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> H = A.g_algebra({y*x:x*y-z, z*x:x*z+Integer(2)*x, z*y:y*z-Integer(2)*y}, names=('x', 'y', 'z',)); (x, y, z,) = H._first_ngens(3) >>> I = H.ideal([y**Integer(2), x**Integer(2), z**Integer(2)-H.one()],coerce=False)
The result of reduction is not the normal form, if one reduces by a list of polynomials:
sage: (x*z).reduce(I.gens()) x*z
>>> from sage.all import * >>> (x*z).reduce(I.gens()) x*z
However, if the argument is an ideal, then a normal form (reduction with respect to a two-sided Groebner basis) is returned:
sage: (x*z).reduce(I) -x
>>> from sage.all import * >>> (x*z).reduce(I) -x
The Groebner basis shows that the result is correct:
sage: I.std() #random Left Ideal (z^2 - 1, y*z - y, x*z + x, y^2, 2*x*y - z - 1, x^2) of Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {z*x: x*z + 2*x, z*y: y*z - 2*y, y*x: x*y - z} sage: sorted(I.std().gens(),key=str) [2*x*y - z - 1, x*z + x, x^2, y*z - y, y^2, z^2 - 1]
>>> from sage.all import * >>> I.std() #random Left Ideal (z^2 - 1, y*z - y, x*z + x, y^2, 2*x*y - z - 1, x^2) of Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {z*x: x*z + 2*x, z*y: y*z - 2*y, y*x: x*y - z} >>> sorted(I.std().gens(),key=str) [2*x*y - z - 1, x*z + x, x^2, y*z - y, y^2, z^2 - 1]
- total_degree()[source]¶
Return the total degree of
self
, which is the maximum degree of all monomials inself
.EXAMPLES:
sage: A.<x,z,y> = FreeAlgebra(QQ, 3) sage: R = A.g_algebra(relations={y*x:-x*y + z}, order='lex') sage: R.inject_variables() Defining x, z, y sage: f=2*x*y^3*z^2 sage: f.total_degree() 6 sage: f=4*x^2*y^2*z^3 sage: f.total_degree() 7 sage: f=99*x^6*y^3*z^9 sage: f.total_degree() 18 sage: f=x*y^3*z^6+3*x^2 sage: f.total_degree() 10 sage: f=z^3+8*x^4*y^5*z sage: f.total_degree() 10 sage: f=z^9+10*x^4+y^8*x^2 sage: f.total_degree() 10
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'z', 'y',)); (x, z, y,) = A._first_ngens(3) >>> R = A.g_algebra(relations={y*x:-x*y + z}, order='lex') >>> R.inject_variables() Defining x, z, y >>> f=Integer(2)*x*y**Integer(3)*z**Integer(2) >>> f.total_degree() 6 >>> f=Integer(4)*x**Integer(2)*y**Integer(2)*z**Integer(3) >>> f.total_degree() 7 >>> f=Integer(99)*x**Integer(6)*y**Integer(3)*z**Integer(9) >>> f.total_degree() 18 >>> f=x*y**Integer(3)*z**Integer(6)+Integer(3)*x**Integer(2) >>> f.total_degree() 10 >>> f=z**Integer(3)+Integer(8)*x**Integer(4)*y**Integer(5)*z >>> f.total_degree() 10 >>> f=z**Integer(9)+Integer(10)*x**Integer(4)+y**Integer(8)*x**Integer(2) >>> f.total_degree() 10
- sage.rings.polynomial.plural.SCA(base_ring, names, alt_vars, order='degrevlex')[source]¶
Return a free graded-commutative algebra.
This is also known as a free super-commutative algebra.
INPUT:
base_ring
– the ground fieldnames
– list of variable namesalt_vars
– list of indices of to be anti-commutative variables (odd variables)order
– ordering to be used for the constructed algebra
EXAMPLES:
sage: from sage.rings.polynomial.plural import SCA sage: E = SCA(QQ, ['x', 'y', 'z'], [0, 1], order = 'degrevlex') sage: E Quotient of Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {y*x: -x*y} by the ideal (y^2, x^2) sage: E.inject_variables() Defining xbar, ybar, zbar sage: x,y,z = (xbar,ybar,zbar) sage: y*x -x*y sage: z*x x*z sage: x^2 0 sage: y^2 0 sage: z^2 z^2 sage: E.one() 1
>>> from sage.all import * >>> from sage.rings.polynomial.plural import SCA >>> E = SCA(QQ, ['x', 'y', 'z'], [Integer(0), Integer(1)], order = 'degrevlex') >>> E Quotient of Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {y*x: -x*y} by the ideal (y^2, x^2) >>> E.inject_variables() Defining xbar, ybar, zbar >>> x,y,z = (xbar,ybar,zbar) >>> y*x -x*y >>> z*x x*z >>> x**Integer(2) 0 >>> y**Integer(2) 0 >>> z**Integer(2) z^2 >>> E.one() 1
- sage.rings.polynomial.plural.new_CRing(rw, base_ring)[source]¶
Construct
MPolynomialRing_libsingular
fromRingWrap
, assuming the ground field to bebase_ring
.EXAMPLES:
sage: H.<x,y,z> = PolynomialRing(QQ, 3) sage: from sage.libs.singular.function import singular_function sage: ringlist = singular_function('ringlist') sage: ring = singular_function("ring") sage: L = ringlist(H, ring=H); L [0, ['x', 'y', 'z'], [['dp', (1, 1, 1)], ['C', (0,)]], [0]] sage: len(L) 4 sage: W = ring(L, ring=H); W <RingWrap> sage: from sage.rings.polynomial.plural import new_CRing sage: R = new_CRing(W, H.base_ring()) sage: R # indirect doctest Multivariate Polynomial Ring in x, y, z over Rational Field
>>> from sage.all import * >>> H = PolynomialRing(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = H._first_ngens(3) >>> from sage.libs.singular.function import singular_function >>> ringlist = singular_function('ringlist') >>> ring = singular_function("ring") >>> L = ringlist(H, ring=H); L [0, ['x', 'y', 'z'], [['dp', (1, 1, 1)], ['C', (0,)]], [0]] >>> len(L) 4 >>> W = ring(L, ring=H); W <RingWrap> >>> from sage.rings.polynomial.plural import new_CRing >>> R = new_CRing(W, H.base_ring()) >>> R # indirect doctest Multivariate Polynomial Ring in x, y, z over Rational Field
Check that Issue #13145 has been resolved:
sage: h = hash(R.gen() + 1) # sets currRing sage: from sage.libs.singular.ring import ring_refcount_dict, currRing_wrapper sage: curcnt = ring_refcount_dict[currRing_wrapper()] sage: newR = new_CRing(W, H.base_ring()) sage: ring_refcount_dict[currRing_wrapper()] - curcnt 2
>>> from sage.all import * >>> h = hash(R.gen() + Integer(1)) # sets currRing >>> from sage.libs.singular.ring import ring_refcount_dict, currRing_wrapper >>> curcnt = ring_refcount_dict[currRing_wrapper()] >>> newR = new_CRing(W, H.base_ring()) >>> ring_refcount_dict[currRing_wrapper()] - curcnt 2
Check that Issue #29311 is fixed:
sage: R.<x,y,z> = QQ[] sage: from sage.libs.singular.function_factory import ff sage: W = ff.ring(ff.ringlist(R), ring=R) sage: C = sage.rings.polynomial.plural.new_CRing(W, R.base_ring()) sage: C.one() 1
>>> from sage.all import * >>> R = QQ['x, y, z']; (x, y, z,) = R._first_ngens(3) >>> from sage.libs.singular.function_factory import ff >>> W = ff.ring(ff.ringlist(R), ring=R) >>> C = sage.rings.polynomial.plural.new_CRing(W, R.base_ring()) >>> C.one() 1
- sage.rings.polynomial.plural.new_NRing(rw, base_ring)[source]¶
Construct
NCPolynomialRing_plural
fromRingWrap
, assuming the ground field to bebase_ring
.EXAMPLES:
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: H = A.g_algebra({y*x:x*y-1}) sage: H.inject_variables() Defining x, y, z sage: z*x x*z sage: z*y y*z sage: y*x x*y - 1 sage: I = H.ideal([y^2, x^2, z^2-1]) sage: I._groebner_basis_libsingular() [1] sage: from sage.libs.singular.function import singular_function sage: ringlist = singular_function('ringlist') sage: ring = singular_function("ring") sage: L = ringlist(H, ring=H); L [ [0 1 1] [0 0 1] 0, ['x', 'y', 'z'], [['dp', (1, 1, 1)], ['C', (0,)]], [0], [0 0 0], [ 0 -1 0] [ 0 0 0] [ 0 0 0] ] sage: len(L) 6 sage: W = ring(L, ring=H); W <noncommutative RingWrap> sage: from sage.rings.polynomial.plural import new_NRing sage: R = new_NRing(W, H.base_ring()) sage: R # indirect doctest Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {y*x: x*y - 1}
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> H = A.g_algebra({y*x:x*y-Integer(1)}) >>> H.inject_variables() Defining x, y, z >>> z*x x*z >>> z*y y*z >>> y*x x*y - 1 >>> I = H.ideal([y**Integer(2), x**Integer(2), z**Integer(2)-Integer(1)]) >>> I._groebner_basis_libsingular() [1] >>> from sage.libs.singular.function import singular_function >>> ringlist = singular_function('ringlist') >>> ring = singular_function("ring") >>> L = ringlist(H, ring=H); L [ [0 1 1] [0 0 1] 0, ['x', 'y', 'z'], [['dp', (1, 1, 1)], ['C', (0,)]], [0], [0 0 0], <BLANKLINE> [ 0 -1 0] [ 0 0 0] [ 0 0 0] ] >>> len(L) 6 >>> W = ring(L, ring=H); W <noncommutative RingWrap> >>> from sage.rings.polynomial.plural import new_NRing >>> R = new_NRing(W, H.base_ring()) >>> R # indirect doctest Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {y*x: x*y - 1}
- sage.rings.polynomial.plural.new_Ring(rw, base_ring)[source]¶
Construct a Sage ring out of low level
RingWrap
, which wraps a pointer to a Singular ring.The constructed ring is either commutative or noncommutative depending on the Singular ring.
EXAMPLES:
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: H = A.g_algebra({y*x:x*y-1}) sage: H.inject_variables() Defining x, y, z sage: z*x x*z sage: z*y y*z sage: y*x x*y - 1 sage: I = H.ideal([y^2, x^2, z^2-1]) sage: I._groebner_basis_libsingular() [1] sage: from sage.libs.singular.function import singular_function sage: ringlist = singular_function('ringlist') sage: ring = singular_function("ring") sage: L = ringlist(H, ring=H); L [ [0 1 1] [0 0 1] 0, ['x', 'y', 'z'], [['dp', (1, 1, 1)], ['C', (0,)]], [0], [0 0 0], [ 0 -1 0] [ 0 0 0] [ 0 0 0] ] sage: len(L) 6 sage: W = ring(L, ring=H); W <noncommutative RingWrap> sage: from sage.rings.polynomial.plural import new_Ring sage: R = new_Ring(W, H.base_ring()); R Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {y*x: x*y - 1}
>>> from sage.all import * >>> A = FreeAlgebra(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3) >>> H = A.g_algebra({y*x:x*y-Integer(1)}) >>> H.inject_variables() Defining x, y, z >>> z*x x*z >>> z*y y*z >>> y*x x*y - 1 >>> I = H.ideal([y**Integer(2), x**Integer(2), z**Integer(2)-Integer(1)]) >>> I._groebner_basis_libsingular() [1] >>> from sage.libs.singular.function import singular_function >>> ringlist = singular_function('ringlist') >>> ring = singular_function("ring") >>> L = ringlist(H, ring=H); L [ [0 1 1] [0 0 1] 0, ['x', 'y', 'z'], [['dp', (1, 1, 1)], ['C', (0,)]], [0], [0 0 0], <BLANKLINE> [ 0 -1 0] [ 0 0 0] [ 0 0 0] ] >>> len(L) 6 >>> W = ring(L, ring=H); W <noncommutative RingWrap> >>> from sage.rings.polynomial.plural import new_Ring >>> R = new_Ring(W, H.base_ring()); R Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {y*x: x*y - 1}