# $$q$$-Commuting Polynomials#

AUTHORS:

• Travis Scrimshaw (2022-08-23): Initial version

• Travis Scrimshaw (2023-02-10): Added Laurent polynomials

class sage.algebras.q_commuting_polynomials.qCommutingLaurentPolynomials(q, B, names)[source]#

The algebra of $$q$$-commuting Laurent polynomials.

Let $$R$$ be a commutative ring, and fix an element $$q \in R$$. Let $$B = (B_{xy})_{x,y \in I}$$ be a skew-symmetric bilinear form with index set $$I$$. Let $$R[I]_{q,B}$$ denote the Laurent polynomial ring in the variables $$I$$ such that we have the $$q$$-commuting relation for $$x, y \in I$$:

$y x = q^{B_{xy}} \cdot x y.$

This is a graded $$R$$-algebra with a natural basis given by monomials written in increasing order with respect to some total order on $$I$$.

EXAMPLES:

sage: q = ZZ['q'].fraction_field().gen()
sage: R.<x,y> = algebras.qCommutingLaurentPolynomials(q)

>>> from sage.all import *
>>> q = ZZ['q'].fraction_field().gen()
>>> R = algebras.qCommutingLaurentPolynomials(q, names=('x', 'y',)); (x, y,) = R._first_ngens(2)


We verify a case of the $$q$$-binomial theorem using inverse variables:

sage: f = (x^-1 + y^-1)^10
sage: all(f[b] == q_binomial(10, -b.list()[0]) for b in f.support())
True

>>> from sage.all import *
>>> f = (x**-Integer(1) + y**-Integer(1))**Integer(10)
>>> all(f[b] == q_binomial(Integer(10), -b.list()[Integer(0)]) for b in f.support())
True


We now do a computation with a non-standard $$B$$ matrix:

sage: B = matrix([[0,1,2],[-1,0,3],[-2,-3,0]])
sage: B
[ 0  1  2]
[-1  0  3]
[-2 -3  0]
sage: q = ZZ['q'].gen()
sage: R.<x,y,z> = algebras.qCommutingLaurentPolynomials(q, B)
sage: y^-1 * x
1/q*x*y^-1
sage: z^-1 * x
1/q^2*x*z^-1
sage: z^-1 * y^-1
q^3*y^-1*z^-1

sage: f = (x + z^-1)^10
sage: all(f[b] == q_binomial(10, b.list()[0], q^-2) for b in f.support())
True

sage: f = (y^-1 + z^-1)^10
sage: all(f[b] == q_binomial(10, -b.list()[1], q^3) for b in f.support())
True

>>> from sage.all import *
>>> B = matrix([[Integer(0),Integer(1),Integer(2)],[-Integer(1),Integer(0),Integer(3)],[-Integer(2),-Integer(3),Integer(0)]])
>>> B
[ 0  1  2]
[-1  0  3]
[-2 -3  0]
>>> q = ZZ['q'].gen()
>>> R = algebras.qCommutingLaurentPolynomials(q, B, names=('x', 'y', 'z',)); (x, y, z,) = R._first_ngens(3)
>>> y**-Integer(1) * x
1/q*x*y^-1
>>> z**-Integer(1) * x
1/q^2*x*z^-1
>>> z**-Integer(1) * y**-Integer(1)
q^3*y^-1*z^-1

>>> f = (x + z**-Integer(1))**Integer(10)
>>> all(f[b] == q_binomial(Integer(10), b.list()[Integer(0)], q**-Integer(2)) for b in f.support())
True

>>> f = (y**-Integer(1) + z**-Integer(1))**Integer(10)
>>> all(f[b] == q_binomial(Integer(10), -b.list()[Integer(1)], q**Integer(3)) for b in f.support())
True

class Element[source]#
one_basis()[source]#

Return the basis index of the element $$1$$.

EXAMPLES:

sage: q = ZZ['q'].fraction_field().gen()
sage: R.<x,y,z> = algebras.qCommutingPolynomials(q)
sage: R.one_basis()
1

>>> from sage.all import *
>>> q = ZZ['q'].fraction_field().gen()
>>> R = algebras.qCommutingPolynomials(q, names=('x', 'y', 'z',)); (x, y, z,) = R._first_ngens(3)
>>> R.one_basis()
1

product_on_basis(x, y)[source]#

Return the product of two monomials given by x and y.

EXAMPLES:

sage: q = ZZ['q'].fraction_field().gen()
sage: R.<x,y> = algebras.qCommutingLaurentPolynomials(q)
x*y
q*x*y

sage: x * y
x*y
sage: y * x
q*x*y
sage: y^2 * x
q^2*x*y^2
sage: y * x^2
q^2*x^2*y
sage: y^-2 * x
1/q^2*x*y^-2
sage: y * x^-2
1/q^2*x^-2*y
sage: x * y * x
q*x^2*y
sage: x * y * ~x
1/q*y
sage: y^2 * x^2
q^4*x^2*y^2
sage: y^-2 * x^2
1/q^4*x^2*y^-2
sage: y^-2 * x^-2
q^4*x^-2*y^-2
sage: (x + y)^4
x^4 + (q^3+q^2+q+1)*x^3*y + (q^4+q^3+2*q^2+q+1)*x^2*y^2 + (q^3+q^2+q+1)*x*y^3 + y^4

>>> from sage.all import *
>>> q = ZZ['q'].fraction_field().gen()
>>> R = algebras.qCommutingLaurentPolynomials(q, names=('x', 'y',)); (x, y,) = R._first_ngens(2)
x*y
q*x*y

>>> x * y
x*y
>>> y * x
q*x*y
>>> y**Integer(2) * x
q^2*x*y^2
>>> y * x**Integer(2)
q^2*x^2*y
>>> y**-Integer(2) * x
1/q^2*x*y^-2
>>> y * x**-Integer(2)
1/q^2*x^-2*y
>>> x * y * x
q*x^2*y
>>> x * y * ~x
1/q*y
>>> y**Integer(2) * x**Integer(2)
q^4*x^2*y^2
>>> y**-Integer(2) * x**Integer(2)
1/q^4*x^2*y^-2
>>> y**-Integer(2) * x**-Integer(2)
q^4*x^-2*y^-2
>>> (x + y)**Integer(4)
x^4 + (q^3+q^2+q+1)*x^3*y + (q^4+q^3+2*q^2+q+1)*x^2*y^2 + (q^3+q^2+q+1)*x*y^3 + y^4


With a non-standard $$B$$ matrix:

sage: B = matrix([[0,1,2],[-1,0,3],[-2,-3,0]])
sage: q = ZZ['q'].fraction_field().gen()
sage: R.<x,y,z> = algebras.qCommutingLaurentPolynomials(q, B=B)
sage: x * y
x*y
sage: y * x^2
q^2*x^2*y
sage: z^2 * x
q^4*x*z^2
sage: z^2 * x^3
q^12*x^3*z^2
sage: z^2 * y
q^6*y*z^2
sage: z^2 * y^3
q^18*y^3*z^2
sage: x * y^-1
x*y^-1
sage: y * x^-2
1/q^2*x^-2*y
sage: z^-2 * x
1/q^4*x*z^-2
sage: z^-2 * x^-3
q^12*x^-3*z^-2
sage: z^2 * y^-1
1/q^6*y^-1*z^2
sage: z^2 * y^-3
1/q^18*y^-3*z^2

>>> from sage.all import *
>>> B = matrix([[Integer(0),Integer(1),Integer(2)],[-Integer(1),Integer(0),Integer(3)],[-Integer(2),-Integer(3),Integer(0)]])
>>> q = ZZ['q'].fraction_field().gen()
>>> R = algebras.qCommutingLaurentPolynomials(q, B=B, names=('x', 'y', 'z',)); (x, y, z,) = R._first_ngens(3)
>>> x * y
x*y
>>> y * x**Integer(2)
q^2*x^2*y
>>> z**Integer(2) * x
q^4*x*z^2
>>> z**Integer(2) * x**Integer(3)
q^12*x^3*z^2
>>> z**Integer(2) * y
q^6*y*z^2
>>> z**Integer(2) * y**Integer(3)
q^18*y^3*z^2
>>> x * y**-Integer(1)
x*y^-1
>>> y * x**-Integer(2)
1/q^2*x^-2*y
>>> z**-Integer(2) * x
1/q^4*x*z^-2
>>> z**-Integer(2) * x**-Integer(3)
q^12*x^-3*z^-2
>>> z**Integer(2) * y**-Integer(1)
1/q^6*y^-1*z^2
>>> z**Integer(2) * y**-Integer(3)
1/q^18*y^-3*z^2

class sage.algebras.q_commuting_polynomials.qCommutingPolynomials(q, B, names)[source]#

The algebra of $$q$$-commuting polynomials.

Let $$R$$ be a commutative ring, and fix an element $$q \in R$$. Let $$B = (B_{xy})_{x,y \in I}$$ be a skew-symmetric bilinear form with index set $$I$$. Let $$R[I]_{q,B}$$ denote the polynomial ring in the variables $$I$$ such that we have the $$q$$-commuting relation for $$x, y \in I$$:

$y x = q^{B_{xy}} \cdot x y.$

This is a graded $$R$$-algebra with a natural basis given by monomials written in increasing order with respect to some total order on $$I$$.

When $$B_{xy} = 1$$ and $$B_{yx} = -1$$ for all $$x < y$$, then we have a $$q$$-analog of the classical binomial coefficient theorem:

$(x + y)^n = \sum_{k=0}^n \binom{n}{k}_q x^k y^{n-k}.$

EXAMPLES:

sage: q = ZZ['q'].fraction_field().gen()
sage: R.<x,y> = algebras.qCommutingPolynomials(q)

>>> from sage.all import *
>>> q = ZZ['q'].fraction_field().gen()
>>> R = algebras.qCommutingPolynomials(q, names=('x', 'y',)); (x, y,) = R._first_ngens(2)


We verify a case of the $$q$$-binomial theorem:

sage: f = (x + y)^10
sage: all(f[b] == q_binomial(10, b.list()[0]) for b in f.support())
True

>>> from sage.all import *
>>> f = (x + y)**Integer(10)
>>> all(f[b] == q_binomial(Integer(10), b.list()[Integer(0)]) for b in f.support())
True


We now do a computation with a non-standard $$B$$ matrix:

sage: B = matrix([[0,1,2],[-1,0,3],[-2,-3,0]])
sage: B
[ 0  1  2]
[-1  0  3]
[-2 -3  0]
sage: q = ZZ['q'].gen()
sage: R.<x,y,z> = algebras.qCommutingPolynomials(q, B)
sage: y * x
q*x*y
sage: z * x
q^2*x*z
sage: z * y
q^3*y*z

sage: f = (x + z)^10
sage: all(f[b] == q_binomial(10, b.list()[0], q^2) for b in f.support())
True

sage: f = (y + z)^10
sage: all(f[b] == q_binomial(10, b.list()[1], q^3) for b in f.support())
True

>>> from sage.all import *
>>> B = matrix([[Integer(0),Integer(1),Integer(2)],[-Integer(1),Integer(0),Integer(3)],[-Integer(2),-Integer(3),Integer(0)]])
>>> B
[ 0  1  2]
[-1  0  3]
[-2 -3  0]
>>> q = ZZ['q'].gen()
>>> R = algebras.qCommutingPolynomials(q, B, names=('x', 'y', 'z',)); (x, y, z,) = R._first_ngens(3)
>>> y * x
q*x*y
>>> z * x
q^2*x*z
>>> z * y
q^3*y*z

>>> f = (x + z)**Integer(10)
>>> all(f[b] == q_binomial(Integer(10), b.list()[Integer(0)], q**Integer(2)) for b in f.support())
True

>>> f = (y + z)**Integer(10)
>>> all(f[b] == q_binomial(Integer(10), b.list()[Integer(1)], q**Integer(3)) for b in f.support())
True

one_basis()[source]#

Return the basis index of the element $$1$$.

EXAMPLES:

sage: q = ZZ['q'].fraction_field().gen()
sage: R.<x,y,z> = algebras.qCommutingPolynomials(q)
sage: R.one_basis()
1

>>> from sage.all import *
>>> q = ZZ['q'].fraction_field().gen()
>>> R = algebras.qCommutingPolynomials(q, names=('x', 'y', 'z',)); (x, y, z,) = R._first_ngens(3)
>>> R.one_basis()
1

product_on_basis(x, y)[source]#

Return the product of two monomials given by x and y.

EXAMPLES:

sage: q = ZZ['q'].fraction_field().gen()
sage: R.<x,y> = algebras.qCommutingPolynomials(q)
x*y
q*x*y

sage: x * y
x*y
sage: y * x
q*x*y
sage: y^2 * x
q^2*x*y^2
sage: y * x^2
q^2*x^2*y
sage: x * y * x
q*x^2*y
sage: y^2 * x^2
q^4*x^2*y^2
sage: (x + y)^2
x^2 + (q+1)*x*y + y^2
sage: (x + y)^3
x^3 + (q^2+q+1)*x^2*y + (q^2+q+1)*x*y^2 + y^3
sage: (x + y)^4
x^4 + (q^3+q^2+q+1)*x^3*y + (q^4+q^3+2*q^2+q+1)*x^2*y^2 + (q^3+q^2+q+1)*x*y^3 + y^4

>>> from sage.all import *
>>> q = ZZ['q'].fraction_field().gen()
>>> R = algebras.qCommutingPolynomials(q, names=('x', 'y',)); (x, y,) = R._first_ngens(2)
x*y
q*x*y

>>> x * y
x*y
>>> y * x
q*x*y
>>> y**Integer(2) * x
q^2*x*y^2
>>> y * x**Integer(2)
q^2*x^2*y
>>> x * y * x
q*x^2*y
>>> y**Integer(2) * x**Integer(2)
q^4*x^2*y^2
>>> (x + y)**Integer(2)
x^2 + (q+1)*x*y + y^2
>>> (x + y)**Integer(3)
x^3 + (q^2+q+1)*x^2*y + (q^2+q+1)*x*y^2 + y^3
>>> (x + y)**Integer(4)
x^4 + (q^3+q^2+q+1)*x^3*y + (q^4+q^3+2*q^2+q+1)*x^2*y^2 + (q^3+q^2+q+1)*x*y^3 + y^4


With a non-standard $$B$$ matrix:

sage: B = matrix([[0,1,2],[-1,0,3],[-2,-3,0]])
sage: q = ZZ['q'].fraction_field().gen()
sage: R.<x,y,z> = algebras.qCommutingPolynomials(q, B=B)
sage: x * y
x*y
sage: y * x^2
q^2*x^2*y
sage: z^2 * x
q^4*x*z^2
sage: z^2 * x^3
q^12*x^3*z^2
sage: z^2 * y
q^6*y*z^2
sage: z^2 * y^3
q^18*y^3*z^2

>>> from sage.all import *
>>> B = matrix([[Integer(0),Integer(1),Integer(2)],[-Integer(1),Integer(0),Integer(3)],[-Integer(2),-Integer(3),Integer(0)]])
>>> q = ZZ['q'].fraction_field().gen()
>>> R = algebras.qCommutingPolynomials(q, B=B, names=('x', 'y', 'z',)); (x, y, z,) = R._first_ngens(3)
>>> x * y
x*y
>>> y * x**Integer(2)
q^2*x^2*y
>>> z**Integer(2) * x
q^4*x*z^2
>>> z**Integer(2) * x**Integer(3)
q^12*x^3*z^2
>>> z**Integer(2) * y
q^6*y*z^2
>>> z**Integer(2) * y**Integer(3)
q^18*y^3*z^2

class sage.algebras.q_commuting_polynomials.qCommutingPolynomials_generic(q, B, indices, names)[source]#

Base class for algebra of $$q$$-commuting (Laurent, etc.) polynomials.

Let $$R$$ be a commutative ring, and fix an element $$q \in R$$. Let $$B = (B_{xy})_{x,y \in I}$$ be a skew-symmetric bilinear form with index set $$I$$. Let $$R[I]_{q,B}$$ denote the polynomial ring in the variables $$I$$ such that we have the $$q$$-commuting relation for $$x, y \in I$$:

$y x = q^{B_{xy}} \cdot x y.$

This is a graded $$R$$-algebra with a natural basis given by monomials written in increasing order with respect to some total order on $$I$$.

algebra_generators()[source]#

Return the algebra generators of self.

EXAMPLES:

sage: q = ZZ['q'].fraction_field().gen()
sage: R.<x,y,z> = algebras.qCommutingPolynomials(q)
sage: R.algebra_generators()
Finite family {'x': x, 'y': y, 'z': z}

>>> from sage.all import *
>>> q = ZZ['q'].fraction_field().gen()
>>> R = algebras.qCommutingPolynomials(q, names=('x', 'y', 'z',)); (x, y, z,) = R._first_ngens(3)
>>> R.algebra_generators()
Finite family {'x': x, 'y': y, 'z': z}

degree_on_basis(m)[source]#

Return the degree of the monomial index by m.

EXAMPLES:

sage: q = ZZ['q'].fraction_field().gen()
sage: R.<x,y,z> = algebras.qCommutingPolynomials(q)
sage: R.degree_on_basis(R.one_basis())
0
sage: f = (x + y)^3 + z^3
sage: f.degree()
3

>>> from sage.all import *
>>> q = ZZ['q'].fraction_field().gen()
>>> R = algebras.qCommutingPolynomials(q, names=('x', 'y', 'z',)); (x, y, z,) = R._first_ngens(3)
>>> R.degree_on_basis(R.one_basis())
0
>>> f = (x + y)**Integer(3) + z**Integer(3)
>>> f.degree()
3

dimension()[source]#

Return the dimension of self, which is $$\infty$$.

EXAMPLES:

sage: q = ZZ['q'].fraction_field().gen()
sage: R.<x,y,z> = algebras.qCommutingPolynomials(q)
sage: R.dimension()
+Infinity

>>> from sage.all import *
>>> q = ZZ['q'].fraction_field().gen()
>>> R = algebras.qCommutingPolynomials(q, names=('x', 'y', 'z',)); (x, y, z,) = R._first_ngens(3)
>>> R.dimension()
+Infinity

gen(i)[source]#

Return the i-generator of self.

EXAMPLES:

sage: q = ZZ['q'].fraction_field().gen()
sage: R.<x,y,z> = algebras.qCommutingPolynomials(q)
sage: R.gen(0)
x
sage: R.gen(2)
z

>>> from sage.all import *
>>> q = ZZ['q'].fraction_field().gen()
>>> R = algebras.qCommutingPolynomials(q, names=('x', 'y', 'z',)); (x, y, z,) = R._first_ngens(3)
>>> R.gen(Integer(0))
x
>>> R.gen(Integer(2))
z

gens()[source]#

Return the generators of self.

EXAMPLES:

sage: q = ZZ['q'].fraction_field().gen()
sage: R.<x,y,z> = algebras.qCommutingPolynomials(q)
sage: R.gens()
(x, y, z)

>>> from sage.all import *
>>> q = ZZ['q'].fraction_field().gen()
>>> R = algebras.qCommutingPolynomials(q, names=('x', 'y', 'z',)); (x, y, z,) = R._first_ngens(3)
>>> R.gens()
(x, y, z)

q()[source]#

Return the parameter $$q$$.

EXAMPLES:

sage: q = ZZ['q'].fraction_field().gen()
sage: R.<x,y,z> = algebras.qCommutingPolynomials(q)
sage: R.q() == q
True

>>> from sage.all import *
>>> q = ZZ['q'].fraction_field().gen()
>>> R = algebras.qCommutingPolynomials(q, names=('x', 'y', 'z',)); (x, y, z,) = R._first_ngens(3)
>>> R.q() == q
True