Weyl Algebras¶
AUTHORS:
Travis Scrimshaw (2013-09-06): Initial version
Joseph McDonough (2025-06-13): Added
InfGenDifferentialWeylAlgebra
- class sage.algebras.weyl_algebra.DifferentialWeylAlgebra(R, names=None, n=None)[source]¶
Bases:
UniqueRepresentation,ParentThe differential Weyl algebra of a polynomial ring.
Let \(R\) be a commutative ring. The (differential) Weyl algebra \(W\) is the algebra generated by \(x_1, x_2, \ldots x_n, \partial_{x_1}, \partial_{x_2}, \ldots, \partial_{x_n}\) subject to the relations: \([x_i, x_j] = 0\), \([\partial_{x_i}, \partial_{x_j}] = 0\), and \(\partial_{x_i} x_j = x_j \partial_{x_i} + \delta_{ij}\). Therefore \(\partial_{x_i}\) is acting as the partial differential operator on \(x_i\).
The Weyl algebra can also be constructed as an iterated Ore extension of the polynomial ring \(R[x_1, x_2, \ldots, x_n]\) by adding \(x_i\) at each step. It can also be seen as a quantization of the symmetric algebra \(Sym(V)\), where \(V\) is a finite dimensional vector space over a field of characteristic zero, by using a modified Groenewold-Moyal product in the symmetric algebra.
The Weyl algebra (even for \(n = 1\)) over a field of characteristic 0 has many interesting properties.
It’s a non-commutative domain.
It’s a simple ring (but not in positive characteristic) that is not a matrix ring over a division ring.
It has no finite-dimensional representations.
It’s a quotient of the universal enveloping algebra of the Heisenberg algebra \(\mathfrak{h}_n\).
REFERENCES:
INPUT:
R– a (polynomial) ringnames– (default:None) ifNoneandRis a polynomial ring, then the variable names correspond to those ofR; otherwise ifnamesis specified, thenRis the base ring
EXAMPLES:
There are two ways to create a Weyl algebra, the first is from a polynomial ring:
sage: R.<x,y,z> = QQ[] sage: W = DifferentialWeylAlgebra(R); W Differential Weyl algebra of polynomials in x, y, z over Rational Field
>>> from sage.all import * >>> R = QQ['x, y, z']; (x, y, z,) = R._first_ngens(3) >>> W = DifferentialWeylAlgebra(R); W Differential Weyl algebra of polynomials in x, y, z over Rational Field
We can call
W.inject_variables()to give the polynomial ring variables, now as elements ofW, and the differentials:sage: W.inject_variables() Defining x, y, z, dx, dy, dz sage: (dx * dy * dz) * (x^2 * y * z + x * z * dy + 1) x*z*dx*dy^2*dz + z*dy^2*dz + x^2*y*z*dx*dy*dz + dx*dy*dz + x*dx*dy^2 + 2*x*y*z*dy*dz + dy^2 + x^2*z*dx*dz + x^2*y*dx*dy + 2*x*z*dz + 2*x*y*dy + x^2*dx + 2*x
>>> from sage.all import * >>> W.inject_variables() Defining x, y, z, dx, dy, dz >>> (dx * dy * dz) * (x**Integer(2) * y * z + x * z * dy + Integer(1)) x*z*dx*dy^2*dz + z*dy^2*dz + x^2*y*z*dx*dy*dz + dx*dy*dz + x*dx*dy^2 + 2*x*y*z*dy*dz + dy^2 + x^2*z*dx*dz + x^2*y*dx*dy + 2*x*z*dz + 2*x*y*dy + x^2*dx + 2*x
Or directly by specifying a base ring and variable names:
sage: W.<a,b> = DifferentialWeylAlgebra(QQ); W Differential Weyl algebra of polynomials in a, b over Rational Field
>>> from sage.all import * >>> W = DifferentialWeylAlgebra(QQ, names=('a', 'b',)); (a, b,) = W._first_ngens(2); W Differential Weyl algebra of polynomials in a, b over Rational Field
Todo
Implement the
graded_algebra()as a polynomial ring once they are considered to be graded rings (algebras).- Element[source]¶
alias of
DifferentialWeylAlgebraElement
- algebra_generators()[source]¶
Return the algebra generators of
self.See also
EXAMPLES:
sage: R.<x,y,z> = QQ[] sage: W = DifferentialWeylAlgebra(R) sage: W.algebra_generators() Finite family {'x': x, 'y': y, 'z': z, 'dx': dx, 'dy': dy, 'dz': dz}
>>> from sage.all import * >>> R = QQ['x, y, z']; (x, y, z,) = R._first_ngens(3) >>> W = DifferentialWeylAlgebra(R) >>> W.algebra_generators() Finite family {'x': x, 'y': y, 'z': z, 'dx': dx, 'dy': dy, 'dz': dz}
- basis()[source]¶
Return a basis of
self.EXAMPLES:
sage: W.<x,y> = DifferentialWeylAlgebra(QQ) sage: B = W.basis() sage: it = iter(B) sage: [next(it) for i in range(20)] [1, x, y, dx, dy, x^2, x*y, x*dx, x*dy, y^2, y*dx, y*dy, dx^2, dx*dy, dy^2, x^3, x^2*y, x^2*dx, x^2*dy, x*y^2] sage: dx, dy = W.differentials() sage: sorted((dx*x).monomials(), key=str) [1, x*dx] sage: B[(x*y).support()[0]] x*y sage: sorted((dx*x).monomial_coefficients().items()) [(((0, 0), (0, 0)), 1), (((1, 0), (1, 0)), 1)]
>>> from sage.all import * >>> W = DifferentialWeylAlgebra(QQ, names=('x', 'y',)); (x, y,) = W._first_ngens(2) >>> B = W.basis() >>> it = iter(B) >>> [next(it) for i in range(Integer(20))] [1, x, y, dx, dy, x^2, x*y, x*dx, x*dy, y^2, y*dx, y*dy, dx^2, dx*dy, dy^2, x^3, x^2*y, x^2*dx, x^2*dy, x*y^2] >>> dx, dy = W.differentials() >>> sorted((dx*x).monomials(), key=str) [1, x*dx] >>> B[(x*y).support()[Integer(0)]] x*y >>> sorted((dx*x).monomial_coefficients().items()) [(((0, 0), (0, 0)), 1), (((1, 0), (1, 0)), 1)]
- degree_on_basis(i)[source]¶
Return the degree of the basis element indexed by
i.EXAMPLES:
sage: W.<a,b> = DifferentialWeylAlgebra(QQ) sage: W.degree_on_basis( ((1, 3, 2), (0, 1, 3)) ) 10 sage: W.<x,y,z> = DifferentialWeylAlgebra(QQ) sage: dx,dy,dz = W.differentials() sage: elt = y*dy - (3*x - z)*dx sage: elt.degree() 2
>>> from sage.all import * >>> W = DifferentialWeylAlgebra(QQ, names=('a', 'b',)); (a, b,) = W._first_ngens(2) >>> W.degree_on_basis( ((Integer(1), Integer(3), Integer(2)), (Integer(0), Integer(1), Integer(3))) ) 10 >>> W = DifferentialWeylAlgebra(QQ, names=('x', 'y', 'z',)); (x, y, z,) = W._first_ngens(3) >>> dx,dy,dz = W.differentials() >>> elt = y*dy - (Integer(3)*x - z)*dx >>> elt.degree() 2
- diff_action()[source]¶
Left action of this Weyl algebra on the underlying polynomial ring by differentiation.
EXAMPLES:
sage: R.<x,y> = QQ[] sage: W = R.weyl_algebra() sage: dx, dy = W.differentials() sage: W.diff_action Left action by Differential Weyl algebra of polynomials in x, y over Rational Field on Multivariate Polynomial Ring in x, y over Rational Field sage: W.diff_action(dx^2 + dy + 1, x^3*y^3) x^3*y^3 + 3*x^3*y^2 + 6*x*y^3
>>> from sage.all import * >>> R = QQ['x, y']; (x, y,) = R._first_ngens(2) >>> W = R.weyl_algebra() >>> dx, dy = W.differentials() >>> W.diff_action Left action by Differential Weyl algebra of polynomials in x, y over Rational Field on Multivariate Polynomial Ring in x, y over Rational Field >>> W.diff_action(dx**Integer(2) + dy + Integer(1), x**Integer(3)*y**Integer(3)) x^3*y^3 + 3*x^3*y^2 + 6*x*y^3
- differentials()[source]¶
Return the differentials of
self.See also
EXAMPLES:
sage: W.<x,y,z> = DifferentialWeylAlgebra(QQ) sage: W.differentials() Finite family {'dx': dx, 'dy': dy, 'dz': dz}
>>> from sage.all import * >>> W = DifferentialWeylAlgebra(QQ, names=('x', 'y', 'z',)); (x, y, z,) = W._first_ngens(3) >>> W.differentials() Finite family {'dx': dx, 'dy': dy, 'dz': dz}
- gen(i)[source]¶
Return the
i-th generator ofself.See also
EXAMPLES:
sage: R.<x,y,z> = QQ[] sage: W = DifferentialWeylAlgebra(R) sage: [W.gen(i) for i in range(6)] [x, y, z, dx, dy, dz]
>>> from sage.all import * >>> R = QQ['x, y, z']; (x, y, z,) = R._first_ngens(3) >>> W = DifferentialWeylAlgebra(R) >>> [W.gen(i) for i in range(Integer(6))] [x, y, z, dx, dy, dz]
- gens()[source]¶
Return the algebra generators of
self.See also
EXAMPLES:
sage: R.<x,y,z> = QQ[] sage: W = DifferentialWeylAlgebra(R) sage: W.algebra_generators() Finite family {'x': x, 'y': y, 'z': z, 'dx': dx, 'dy': dy, 'dz': dz}
>>> from sage.all import * >>> R = QQ['x, y, z']; (x, y, z,) = R._first_ngens(3) >>> W = DifferentialWeylAlgebra(R) >>> W.algebra_generators() Finite family {'x': x, 'y': y, 'z': z, 'dx': dx, 'dy': dy, 'dz': dz}
- ngens()[source]¶
Return the number of generators of
self.EXAMPLES:
sage: R.<x,y,z> = QQ[] sage: W = DifferentialWeylAlgebra(R) sage: W.ngens() 6
>>> from sage.all import * >>> R = QQ['x, y, z']; (x, y, z,) = R._first_ngens(3) >>> W = DifferentialWeylAlgebra(R) >>> W.ngens() 6
- one()[source]¶
Return the multiplicative identity element \(1\).
EXAMPLES:
sage: R.<x,y,z> = QQ[] sage: W = DifferentialWeylAlgebra(R) sage: W.one() 1
>>> from sage.all import * >>> R = QQ['x, y, z']; (x, y, z,) = R._first_ngens(3) >>> W = DifferentialWeylAlgebra(R) >>> W.one() 1
- polynomial_ring()[source]¶
Return the associated polynomial ring of
self.EXAMPLES:
sage: W.<a,b> = DifferentialWeylAlgebra(QQ) sage: W.polynomial_ring() Multivariate Polynomial Ring in a, b over Rational Field
>>> from sage.all import * >>> W = DifferentialWeylAlgebra(QQ, names=('a', 'b',)); (a, b,) = W._first_ngens(2) >>> W.polynomial_ring() Multivariate Polynomial Ring in a, b over Rational Field
sage: R.<x,y,z> = QQ[] sage: W = DifferentialWeylAlgebra(R) sage: W.polynomial_ring() == R True
>>> from sage.all import * >>> R = QQ['x, y, z']; (x, y, z,) = R._first_ngens(3) >>> W = DifferentialWeylAlgebra(R) >>> W.polynomial_ring() == R True
- variables()[source]¶
Return the variables of
self.See also
EXAMPLES:
sage: W.<x,y,z> = DifferentialWeylAlgebra(QQ) sage: W.variables() Finite family {'x': x, 'y': y, 'z': z}
>>> from sage.all import * >>> W = DifferentialWeylAlgebra(QQ, names=('x', 'y', 'z',)); (x, y, z,) = W._first_ngens(3) >>> W.variables() Finite family {'x': x, 'y': y, 'z': z}
- class sage.algebras.weyl_algebra.DifferentialWeylAlgebraAction(G)[source]¶
Bases:
ActionLeft action of a Weyl algebra on its underlying polynomial ring by differentiation.
EXAMPLES:
sage: R.<x,y> = QQ[] sage: W = R.weyl_algebra() sage: dx, dy = W.differentials() sage: W.diff_action Left action by Differential Weyl algebra of polynomials in x, y over Rational Field on Multivariate Polynomial Ring in x, y over Rational Field
>>> from sage.all import * >>> R = QQ['x, y']; (x, y,) = R._first_ngens(2) >>> W = R.weyl_algebra() >>> dx, dy = W.differentials() >>> W.diff_action Left action by Differential Weyl algebra of polynomials in x, y over Rational Field on Multivariate Polynomial Ring in x, y over Rational Field
sage: g = dx^2 + x*dy sage: p = x^5 + x^3 + y^2*x^2 + 1 sage: W.diff_action(g, p) 2*x^3*y + 20*x^3 + 2*y^2 + 6*x
>>> from sage.all import * >>> g = dx**Integer(2) + x*dy >>> p = x**Integer(5) + x**Integer(3) + y**Integer(2)*x**Integer(2) + Integer(1) >>> W.diff_action(g, p) 2*x^3*y + 20*x^3 + 2*y^2 + 6*x
The action is a left action:
sage: h = dx*x + x*y sage: W.diff_action(h, W.diff_action(g, p)) == W.diff_action(h*g, p) True
>>> from sage.all import * >>> h = dx*x + x*y >>> W.diff_action(h, W.diff_action(g, p)) == W.diff_action(h*g, p) True
The action endomorphism of a differential operator:
sage: dg = W.diff_action(g); dg Action of dx^2 + x*dy on Multivariate Polynomial Ring in x, y over Rational Field under Left action by Differential Weyl algebra... sage: dg(p) == W.diff_action(g, p) == g.diff(p) True
>>> from sage.all import * >>> dg = W.diff_action(g); dg Action of dx^2 + x*dy on Multivariate Polynomial Ring in x, y over Rational Field under Left action by Differential Weyl algebra... >>> dg(p) == W.diff_action(g, p) == g.diff(p) True
- class sage.algebras.weyl_algebra.DifferentialWeylAlgebraElement[source]¶
Bases:
IndexedFreeModuleElementAn element in a differential Weyl algebra.
- diff(p)[source]¶
Apply this differential operator to a polynomial.
INPUT:
p– polynomial of the underlying polynomial ring
OUTPUT:
The result of the left action of the Weyl algebra on the polynomial ring via differentiation.
EXAMPLES:
sage: R.<x,y> = QQ[] sage: W = R.weyl_algebra() sage: dx, dy = W.differentials() sage: dx.diff(x^3) 3*x^2 sage: (dx*dy).diff(W(x^3*y^3)) 9*x^2*y^2 sage: (x*dx + dy + 1).diff(x^4*y^4 + 1) 5*x^4*y^4 + 4*x^4*y^3 + 1
>>> from sage.all import * >>> R = QQ['x, y']; (x, y,) = R._first_ngens(2) >>> W = R.weyl_algebra() >>> dx, dy = W.differentials() >>> dx.diff(x**Integer(3)) 3*x^2 >>> (dx*dy).diff(W(x**Integer(3)*y**Integer(3))) 9*x^2*y^2 >>> (x*dx + dy + Integer(1)).diff(x**Integer(4)*y**Integer(4) + Integer(1)) 5*x^4*y^4 + 4*x^4*y^3 + 1
- factor_differentials()[source]¶
Return a dict representing
selfwith the differentials factored out.EXAMPLES:
sage: R.<t> = QQ[] sage: D = DifferentialWeylAlgebra(R) sage: t, dt = D.gens() sage: x = dt^3*t^3 + dt^2*t^4 sage: x t^3*dt^3 + t^4*dt^2 + 9*t^2*dt^2 + 8*t^3*dt + 18*t*dt + 12*t^2 + 6 sage: x.factor_differentials() {(0,): 12*t^2 + 6, (1,): 8*t^3 + 18*t, (2,): t^4 + 9*t^2, (3,): t^3} sage: D.zero().factor_differentials() {} sage: R.<x,y,z> = QQ[] sage: D = DifferentialWeylAlgebra(R) sage: x, y, z, dx, dy, dz = D.gens() sage: elt = dx^3*x^3 + (y^3-z*x)*dx^3 + dy^3*x^3 + dx*dy*dz*x*y*z sage: elt x^3*dy^3 + x*y*z*dx*dy*dz + y^3*dx^3 + x^3*dx^3 - x*z*dx^3 + y*z*dy*dz + x*z*dx*dz + x*y*dx*dy + 9*x^2*dx^2 + z*dz + y*dy + 19*x*dx + 7 sage: elt.factor_differentials() {(0, 0, 0): 7, (0, 0, 1): z, (0, 1, 0): y, (0, 1, 1): y*z, (0, 3, 0): x^3, (1, 0, 0): 19*x, (1, 0, 1): x*z, (1, 1, 0): x*y, (1, 1, 1): x*y*z, (2, 0, 0): 9*x^2, (3, 0, 0): x^3 + y^3 - x*z}
>>> from sage.all import * >>> R = QQ['t']; (t,) = R._first_ngens(1) >>> D = DifferentialWeylAlgebra(R) >>> t, dt = D.gens() >>> x = dt**Integer(3)*t**Integer(3) + dt**Integer(2)*t**Integer(4) >>> x t^3*dt^3 + t^4*dt^2 + 9*t^2*dt^2 + 8*t^3*dt + 18*t*dt + 12*t^2 + 6 >>> x.factor_differentials() {(0,): 12*t^2 + 6, (1,): 8*t^3 + 18*t, (2,): t^4 + 9*t^2, (3,): t^3} >>> D.zero().factor_differentials() {} >>> R = QQ['x, y, z']; (x, y, z,) = R._first_ngens(3) >>> D = DifferentialWeylAlgebra(R) >>> x, y, z, dx, dy, dz = D.gens() >>> elt = dx**Integer(3)*x**Integer(3) + (y**Integer(3)-z*x)*dx**Integer(3) + dy**Integer(3)*x**Integer(3) + dx*dy*dz*x*y*z >>> elt x^3*dy^3 + x*y*z*dx*dy*dz + y^3*dx^3 + x^3*dx^3 - x*z*dx^3 + y*z*dy*dz + x*z*dx*dz + x*y*dx*dy + 9*x^2*dx^2 + z*dz + y*dy + 19*x*dx + 7 >>> elt.factor_differentials() {(0, 0, 0): 7, (0, 0, 1): z, (0, 1, 0): y, (0, 1, 1): y*z, (0, 3, 0): x^3, (1, 0, 0): 19*x, (1, 0, 1): x*z, (1, 1, 0): x*y, (1, 1, 1): x*y*z, (2, 0, 0): 9*x^2, (3, 0, 0): x^3 + y^3 - x*z}
- list()[source]¶
Return
selfas a list.This list consists of pairs \((m, c)\), where \(m\) is a pair of tuples indexing a basis element of
self, and \(c\) is the coordinate ofselfcorresponding to this basis element. (Only nonzero coordinates are shown.)EXAMPLES:
sage: W.<x,y,z> = DifferentialWeylAlgebra(QQ) sage: dx,dy,dz = W.differentials() sage: elt = dy - (3*x - z)*dx sage: elt.list() [(((0, 0, 0), (0, 1, 0)), 1), (((0, 0, 1), (1, 0, 0)), 1), (((1, 0, 0), (1, 0, 0)), -3)]
>>> from sage.all import * >>> W = DifferentialWeylAlgebra(QQ, names=('x', 'y', 'z',)); (x, y, z,) = W._first_ngens(3) >>> dx,dy,dz = W.differentials() >>> elt = dy - (Integer(3)*x - z)*dx >>> elt.list() [(((0, 0, 0), (0, 1, 0)), 1), (((0, 0, 1), (1, 0, 0)), 1), (((1, 0, 0), (1, 0, 0)), -3)]
- class sage.algebras.weyl_algebra.InfGenDifferentialWeylAlgebra(R, names=None)[source]¶
Bases:
UniqueRepresentation,ParentThe differential Weyl algebra of the polynomial ring in countably many variables.
Let \(R\) be a commutative ring, and \(\{x_i\}\) a countable family of indeterminants. The differential Weyl algebra \(W\) is an \(R\)-algebra generated by symbols \(x_i\), and \(\partial_{x_i}\), subject to the relations \([x_i,x_j] = [\partial_{x_i}, \partial_{x_j}] = 0\), and \([\partial_{x_i}, x_j] = \delta_{ij}\).
INPUT:
R– a commutative ringnames– length 1 tuple of strings denoting the prefix for the variable names
EXAMPLES:
We construct an infinite Weyl algebra by using
n=ooinDifferentialWeylAlgebra:sage: W.<y> = DifferentialWeylAlgebra(QQ, n=oo); W Differential Weyl algebra in countably many variables y over Rational Field
>>> from sage.all import * >>> W = DifferentialWeylAlgebra(QQ, n=oo, names=('y',)); (y,) = W._first_ngens(1); W Differential Weyl algebra in countably many variables y over Rational Field
Alternatively, one can first define an
InfinitePolynomialRing`and then define the differential Weyl algebra of that ring:sage: R.<x> = InfinitePolynomialRing(QQ) sage: W = DifferentialWeylAlgebra(R); W Differential Weyl algebra in countably many variables x over Rational Field
>>> from sage.all import * >>> R = InfinitePolynomialRing(QQ, names=('x',)); (x,) = R._first_ngens(1) >>> W = DifferentialWeylAlgebra(R); W Differential Weyl algebra in countably many variables x over Rational Field
Warning
Due to a bug in
InfinitePolynomialRing(Issue #36788) trying to define the infinite Weyl algebra of an infinite polynomial ring with coefficients in another infinite polynomial ring will result in unexpected behavior:sage: R.<x> = InfinitePolynomialRing(QQ) sage: R2.<y> = InfinitePolynomialRing(R) sage: W = DifferentialWeylAlgebra(R2); W # known bug Differential Weyl algebra in countably many variables y over Infinite polynomial ring in x over Rational Field
>>> from sage.all import * >>> R = InfinitePolynomialRing(QQ, names=('x',)); (x,) = R._first_ngens(1) >>> R2 = InfinitePolynomialRing(R, names=('y',)); (y,) = R2._first_ngens(1) >>> W = DifferentialWeylAlgebra(R2); W # known bug Differential Weyl algebra in countably many variables y over Infinite polynomial ring in x over Rational Field
To access the variables, we can call
W.inject_variables(). The symbols defined are families that allow you to access the \(i\)’th polynomial or differential generator for each nonnegative integer \(i\). Alternatively, we can access the families directly using thepolynomial_gens()anddifferentials()methods respectively:sage: W.inject_variables() Defining x, dx sage: dx Lazy family (dx(i))_{i in Non negative integers} sage: dx[1]*x[1] - x[1]*dx[1] 1 sage: (dx[1] + x[1]*dx[2])*(x[5]*dx[1] + 1) x[5]*dx[1]^2 + x[1]*x[5]*dx[1]*dx[2] + dx[1] + x[1]*dx[2]
>>> from sage.all import * >>> W.inject_variables() Defining x, dx >>> dx Lazy family (dx(i))_{i in Non negative integers} >>> dx[Integer(1)]*x[Integer(1)] - x[Integer(1)]*dx[Integer(1)] 1 >>> (dx[Integer(1)] + x[Integer(1)]*dx[Integer(2)])*(x[Integer(5)]*dx[Integer(1)] + Integer(1)) x[5]*dx[1]^2 + x[1]*x[5]*dx[1]*dx[2] + dx[1] + x[1]*dx[2]
- Element[source]¶
alias of
InfGenDifferentialWeylAlgebraElement
- basis()[source]¶
Return a basis for
self.EXAMPLES:
sage: W.<x> = DifferentialWeylAlgebra(QQ, n=oo) sage: B = W.basis(); B Lazy family (basis map(i))_{i in The Cartesian product of (Free abelian monoid indexed by Non negative integers, Free abelian monoid indexed by Non negative integers)} sage: idx = W._var_index sage: B[(idx.an_element(), idx.one())] x[0]*x[1]^2*x[2]^3*x[42]
>>> from sage.all import * >>> W = DifferentialWeylAlgebra(QQ, n=oo, names=('x',)); (x,) = W._first_ngens(1) >>> B = W.basis(); B Lazy family (basis map(i))_{i in The Cartesian product of (Free abelian monoid indexed by Non negative integers, Free abelian monoid indexed by Non negative integers)} >>> idx = W._var_index >>> B[(idx.an_element(), idx.one())] x[0]*x[1]^2*x[2]^3*x[42]
- degree_on_basis(x)[source]¶
- Return the degree of basis element indexed by
x. This is the total degree of the polynomial and differential parts of
x.
INPUT:
x– an index for a basis element
OUTPUT: A nonnegative integer
EXAMPLES:
sage: W.<x> = DifferentialWeylAlgebra(QQ, n=oo) sage: W.inject_variables(verbose=False); sage: f = x[2]*x[3]*dx[1]^2; f.degree() 4
>>> from sage.all import * >>> W = DifferentialWeylAlgebra(QQ, n=oo, names=('x',)); (x,) = W._first_ngens(1) >>> W.inject_variables(verbose=False); >>> f = x[Integer(2)]*x[Integer(3)]*dx[Integer(1)]**Integer(2); f.degree() 4
- Return the degree of basis element indexed by
- differential(i)[source]¶
Return the
i-th differential ofself.INPUT:
i– nonnegative integer
OUTPUT: The differential generator \(\partial_{x_i}\)
EXAMPLES:
sage: W.<x> = DifferentialWeylAlgebra(QQ, n=oo) sage: W.inject_variables() Defining x, dx sage: W.differential(1) dx[1] sage: W.differential(1) == dx[1] True
>>> from sage.all import * >>> W = DifferentialWeylAlgebra(QQ, n=oo, names=('x',)); (x,) = W._first_ngens(1) >>> W.inject_variables() Defining x, dx >>> W.differential(Integer(1)) dx[1] >>> W.differential(Integer(1)) == dx[Integer(1)] True
- differentials()[source]¶
Return the differential generators of
self.OUTPUT: A (lazy) family containing the differential generators \(\partial_{x_i}\)
EXAMPLES:
sage: W.<x> = DifferentialWeylAlgebra(QQ, n=oo) sage: dx = W.differentials(); dx Lazy family (dx(i))_{i in Non negative integers} sage: dx[3] == W.differential(3) True
>>> from sage.all import * >>> W = DifferentialWeylAlgebra(QQ, n=oo, names=('x',)); (x,) = W._first_ngens(1) >>> dx = W.differentials(); dx Lazy family (dx(i))_{i in Non negative integers} >>> dx[Integer(3)] == W.differential(Integer(3)) True
- gen(i)[source]¶
Return the
i-th polynomial generator ofself.INPUT:
i– nonnegative integer
OUTPUT: The polynomial generator \(x_i\)
EXAMPLES:
sage: W.<x> = DifferentialWeylAlgebra(QQ, n=oo) sage: W.gen(1) x[1] sage: W.gen(1) == x[1] True
>>> from sage.all import * >>> W = DifferentialWeylAlgebra(QQ, n=oo, names=('x',)); (x,) = W._first_ngens(1) >>> W.gen(Integer(1)) x[1] >>> W.gen(Integer(1)) == x[Integer(1)] True
- gens()[source]¶
Return the algebra generators of
self.OUTPUT: an ordered pair (x, dx) containing families indexing each set of generators.
EXAMPLES:
sage: R = InfinitePolynomialRing(QQ) sage: W = DifferentialWeylAlgebra(R, n=oo) sage: x, dx = W.gens()
>>> from sage.all import * >>> R = InfinitePolynomialRing(QQ) >>> W = DifferentialWeylAlgebra(R, n=oo) >>> x, dx = W.gens()
- one_basis()[source]¶
Return the multiplicative identity element \(1\) of
self.EXAMPLES:
sage: W.<x> = DifferentialWeylAlgebra(QQ, n=oo) sage: W.one_basis() == W.one().leading_support() True sage: x[1]*W.one() == x[1] True
>>> from sage.all import * >>> W = DifferentialWeylAlgebra(QQ, n=oo, names=('x',)); (x,) = W._first_ngens(1) >>> W.one_basis() == W.one().leading_support() True >>> x[Integer(1)]*W.one() == x[Integer(1)] True
- polynomial_gens()[source]¶
Return the polynomial generators of
self.OUTPUT: A (lazy) family containing the polynomial generators \(x_i\).
EXAMPLES:
sage: W.<x> = DifferentialWeylAlgebra(QQ, n=oo) sage: x = W.polynomial_gens(); x Lazy family (x(i))_{i in Non negative integers} sage: x[3] == W.gen(3) True
>>> from sage.all import * >>> W = DifferentialWeylAlgebra(QQ, n=oo, names=('x',)); (x,) = W._first_ngens(1) >>> x = W.polynomial_gens(); x Lazy family (x(i))_{i in Non negative integers} >>> x[Integer(3)] == W.gen(Integer(3)) True
- zero()[source]¶
Return the additive identity element \(0\) of
self.EXAMPLES:
sage: W.<x> = DifferentialWeylAlgebra(QQ, n=oo) sage: x[1] + W.zero() == x[1] True sage: x[1]*W.zero() == W.zero() True
>>> from sage.all import * >>> W = DifferentialWeylAlgebra(QQ, n=oo, names=('x',)); (x,) = W._first_ngens(1) >>> x[Integer(1)] + W.zero() == x[Integer(1)] True >>> x[Integer(1)]*W.zero() == W.zero() True
- class sage.algebras.weyl_algebra.InfGenDifferentialWeylAlgebraElement[source]¶
Bases:
IndexedFreeModuleElementAn element of an infinitely generated differential Weyl algebra.
EXAMPLES:
sage: W.<x> = DifferentialWeylAlgebra(QQ, n=oo) sage: W.inject_variables(verbose=False) sage: W.zero() == 0 True sage: W.one() == 1 True sage: W.zero() == 1 False sage: x[1] == 1 False sage: W(x[1]) == x[1] True sage: W(dx[1]) == dx[1] True sage: W(x[1] + dx[2]^2) == x[1] + dx[2]^2 True sage: x[1] == x[11] False sage: x[1] / 2 1/2*x[1] sage: W(2) / 2 1 sage: (x[1] + dx[1]) * (-4/3) -4/3*dx[1] - 4/3*x[1] sage: (-4/3) * (x[1] + dx[1]) -4/3*dx[1] - 4/3*x[1]
>>> from sage.all import * >>> W = DifferentialWeylAlgebra(QQ, n=oo, names=('x',)); (x,) = W._first_ngens(1) >>> W.inject_variables(verbose=False) >>> W.zero() == Integer(0) True >>> W.one() == Integer(1) True >>> W.zero() == Integer(1) False >>> x[Integer(1)] == Integer(1) False >>> W(x[Integer(1)]) == x[Integer(1)] True >>> W(dx[Integer(1)]) == dx[Integer(1)] True >>> W(x[Integer(1)] + dx[Integer(2)]**Integer(2)) == x[Integer(1)] + dx[Integer(2)]**Integer(2) True >>> x[Integer(1)] == x[Integer(11)] False >>> x[Integer(1)] / Integer(2) 1/2*x[1] >>> W(Integer(2)) / Integer(2) 1 >>> (x[Integer(1)] + dx[Integer(1)]) * (-Integer(4)/Integer(3)) -4/3*dx[1] - 4/3*x[1] >>> (-Integer(4)/Integer(3)) * (x[Integer(1)] + dx[Integer(1)]) -4/3*dx[1] - 4/3*x[1]
- list()[source]¶
Return
selfas a list.This list consists of pairs \((m, c)\) where \(m\) is a pair of
IndexedFreeAbelianMonoidelements indexing a basis element ofself, and \(c\) is the corresponding (nonzero) coefficient. The list is sorted using graded lex order on the differentials, followed by graded lex order on the polynomial generators.EXAMPLES:
sage: W.<x> = DifferentialWeylAlgebra(QQ, n=oo) sage: dx = W.differentials() sage: p = x[5] + dx[1]*x[1] sage: p.list() [((x[1], dx[1]), 1), ((x[5], 1), 1), ((1, 1), 1)]
>>> from sage.all import * >>> W = DifferentialWeylAlgebra(QQ, n=oo, names=('x',)); (x,) = W._first_ngens(1) >>> dx = W.differentials() >>> p = x[Integer(5)] + dx[Integer(1)]*x[Integer(1)] >>> p.list() [((x[1], dx[1]), 1), ((x[5], 1), 1), ((1, 1), 1)]
- sage.algebras.weyl_algebra.repr_factored(w, latex_output=False)[source]¶
Return a string representation of
wwith the \(dx_i\) generators factored on the right.EXAMPLES:
sage: from sage.algebras.weyl_algebra import repr_factored sage: R.<t> = QQ[] sage: D = DifferentialWeylAlgebra(R) sage: t, dt = D.gens() sage: x = dt^3*t^3 + dt^2*t^4 sage: x t^3*dt^3 + t^4*dt^2 + 9*t^2*dt^2 + 8*t^3*dt + 18*t*dt + 12*t^2 + 6 sage: print(repr_factored(x)) (12*t^2 + 6) + (8*t^3 + 18*t)*dt + (t^4 + 9*t^2)*dt^2 + (t^3)*dt^3 sage: repr_factored(x, True) (12 t^{2} + 6) + (8 t^{3} + 18 t) \frac{\partial}{\partial t} + (t^{4} + 9 t^{2}) \frac{\partial^{2}}{\partial t^{2}} + (t^{3}) \frac{\partial^{3}}{\partial t^{3}} sage: repr_factored(D.zero()) '0'
>>> from sage.all import * >>> from sage.algebras.weyl_algebra import repr_factored >>> R = QQ['t']; (t,) = R._first_ngens(1) >>> D = DifferentialWeylAlgebra(R) >>> t, dt = D.gens() >>> x = dt**Integer(3)*t**Integer(3) + dt**Integer(2)*t**Integer(4) >>> x t^3*dt^3 + t^4*dt^2 + 9*t^2*dt^2 + 8*t^3*dt + 18*t*dt + 12*t^2 + 6 >>> print(repr_factored(x)) (12*t^2 + 6) + (8*t^3 + 18*t)*dt + (t^4 + 9*t^2)*dt^2 + (t^3)*dt^3 >>> repr_factored(x, True) (12 t^{2} + 6) + (8 t^{3} + 18 t) \frac{\partial}{\partial t} + (t^{4} + 9 t^{2}) \frac{\partial^{2}}{\partial t^{2}} + (t^{3}) \frac{\partial^{3}}{\partial t^{3}} >>> repr_factored(D.zero()) '0'
With multiple variables:
sage: R.<x,y,z> = QQ[] sage: D = DifferentialWeylAlgebra(R) sage: x, y, z, dx, dy, dz = D.gens() sage: elt = dx^3*x^3 + (y^3-z*x)*dx^3 + dy^3*x^3 + dx*dy*dz*x*y*z sage: elt x^3*dy^3 + x*y*z*dx*dy*dz + y^3*dx^3 + x^3*dx^3 - x*z*dx^3 + y*z*dy*dz + x*z*dx*dz + x*y*dx*dy + 9*x^2*dx^2 + z*dz + y*dy + 19*x*dx + 7 sage: print(repr_factored(elt)) (7) + (z)*dz + (y)*dy + (y*z)*dy*dz + (x^3)*dy^3 + (19*x)*dx + (x*z)*dx*dz + (x*y)*dx*dy + (x*y*z)*dx*dy*dz + (9*x^2)*dx^2 + (x^3 + y^3 - x*z)*dx^3 sage: repr_factored(D.zero(), True) 0
>>> from sage.all import * >>> R = QQ['x, y, z']; (x, y, z,) = R._first_ngens(3) >>> D = DifferentialWeylAlgebra(R) >>> x, y, z, dx, dy, dz = D.gens() >>> elt = dx**Integer(3)*x**Integer(3) + (y**Integer(3)-z*x)*dx**Integer(3) + dy**Integer(3)*x**Integer(3) + dx*dy*dz*x*y*z >>> elt x^3*dy^3 + x*y*z*dx*dy*dz + y^3*dx^3 + x^3*dx^3 - x*z*dx^3 + y*z*dy*dz + x*z*dx*dz + x*y*dx*dy + 9*x^2*dx^2 + z*dz + y*dy + 19*x*dx + 7 >>> print(repr_factored(elt)) (7) + (z)*dz + (y)*dy + (y*z)*dy*dz + (x^3)*dy^3 + (19*x)*dx + (x*z)*dx*dz + (x*y)*dx*dy + (x*y*z)*dx*dy*dz + (9*x^2)*dx^2 + (x^3 + y^3 - x*z)*dx^3 >>> repr_factored(D.zero(), True) 0
- sage.algebras.weyl_algebra.repr_from_monomials(monomials, term_repr, use_latex=False)[source]¶
Return a string representation of an element of a free module from the dictionary
monomials.INPUT:
monomials– list of pairs[m, c]wheremis the index andcis the coefficientterm_repr– a function which returns a string given an index (can bereprorlatex, for example)use_latex– boolean (default:False); ifTruethen the output is in latex format
EXAMPLES:
sage: from sage.algebras.weyl_algebra import repr_from_monomials sage: R.<x,y,z> = QQ[] sage: d = [(z, 4/7), (y, sqrt(2)), (x, -5)] # needs sage.symbolic sage: repr_from_monomials(d, lambda m: repr(m)) # needs sage.symbolic '4/7*z + sqrt(2)*y - 5*x' sage: a = repr_from_monomials(d, lambda m: latex(m), True); a # needs sage.symbolic \frac{4}{7} z + \sqrt{2} y - 5 x sage: type(a) # needs sage.symbolic <class 'sage.misc.latex.LatexExpr'>
>>> from sage.all import * >>> from sage.algebras.weyl_algebra import repr_from_monomials >>> R = QQ['x, y, z']; (x, y, z,) = R._first_ngens(3) >>> d = [(z, Integer(4)/Integer(7)), (y, sqrt(Integer(2))), (x, -Integer(5))] # needs sage.symbolic >>> repr_from_monomials(d, lambda m: repr(m)) # needs sage.symbolic '4/7*z + sqrt(2)*y - 5*x' >>> a = repr_from_monomials(d, lambda m: latex(m), True); a # needs sage.symbolic \frac{4}{7} z + \sqrt{2} y - 5 x >>> type(a) # needs sage.symbolic <class 'sage.misc.latex.LatexExpr'>
The zero element:
sage: repr_from_monomials([], lambda m: repr(m)) '0' sage: a = repr_from_monomials([], lambda m: latex(m), True); a 0 sage: type(a) <class 'sage.misc.latex.LatexExpr'>
>>> from sage.all import * >>> repr_from_monomials([], lambda m: repr(m)) '0' >>> a = repr_from_monomials([], lambda m: latex(m), True); a 0 >>> type(a) <class 'sage.misc.latex.LatexExpr'>
A “unity” element:
sage: repr_from_monomials([(1, 1)], lambda m: repr(m)) '1' sage: a = repr_from_monomials([(1, 1)], lambda m: latex(m), True); a 1 sage: type(a) <class 'sage.misc.latex.LatexExpr'>
>>> from sage.all import * >>> repr_from_monomials([(Integer(1), Integer(1))], lambda m: repr(m)) '1' >>> a = repr_from_monomials([(Integer(1), Integer(1))], lambda m: latex(m), True); a 1 >>> type(a) <class 'sage.misc.latex.LatexExpr'>
sage: repr_from_monomials([(1, -1)], lambda m: repr(m)) '-1' sage: a = repr_from_monomials([(1, -1)], lambda m: latex(m), True); a -1 sage: type(a) <class 'sage.misc.latex.LatexExpr'>
>>> from sage.all import * >>> repr_from_monomials([(Integer(1), -Integer(1))], lambda m: repr(m)) '-1' >>> a = repr_from_monomials([(Integer(1), -Integer(1))], lambda m: latex(m), True); a -1 >>> type(a) <class 'sage.misc.latex.LatexExpr'>
Leading minus signs are dealt with appropriately:
sage: # needs sage.symbolic sage: d = [(z, -4/7), (y, -sqrt(2)), (x, -5)] sage: repr_from_monomials(d, lambda m: repr(m)) '-4/7*z - sqrt(2)*y - 5*x' sage: a = repr_from_monomials(d, lambda m: latex(m), True); a -\frac{4}{7} z - \sqrt{2} y - 5 x sage: type(a) <class 'sage.misc.latex.LatexExpr'>
>>> from sage.all import * >>> # needs sage.symbolic >>> d = [(z, -Integer(4)/Integer(7)), (y, -sqrt(Integer(2))), (x, -Integer(5))] >>> repr_from_monomials(d, lambda m: repr(m)) '-4/7*z - sqrt(2)*y - 5*x' >>> a = repr_from_monomials(d, lambda m: latex(m), True); a -\frac{4}{7} z - \sqrt{2} y - 5 x >>> type(a) <class 'sage.misc.latex.LatexExpr'>
Indirect doctests using a class that uses this function:
sage: R.<x,y> = QQ[] sage: A = CliffordAlgebra(QuadraticForm(R, 3, [x,0,-1,3,-4,5])) sage: a,b,c = A.gens() sage: a*b*c e0*e1*e2 sage: b*c e1*e2 sage: (a*a + 2) x + 2 sage: c*(a*a + 2)*b (-x - 2)*e1*e2 - 4*x - 8 sage: latex(c*(a*a + 2)*b) \left( -x - 2 \right) e_{1} e_{2} - 4 x - 8
>>> from sage.all import * >>> R = QQ['x, y']; (x, y,) = R._first_ngens(2) >>> A = CliffordAlgebra(QuadraticForm(R, Integer(3), [x,Integer(0),-Integer(1),Integer(3),-Integer(4),Integer(5)])) >>> a,b,c = A.gens() >>> a*b*c e0*e1*e2 >>> b*c e1*e2 >>> (a*a + Integer(2)) x + 2 >>> c*(a*a + Integer(2))*b (-x - 2)*e1*e2 - 4*x - 8 >>> latex(c*(a*a + Integer(2))*b) \left( -x - 2 \right) e_{1} e_{2} - 4 x - 8