# Weyl Algebras¶

AUTHORS:

• Travis Scrimshaw (2013-09-06): Initial version
class sage.algebras.weyl_algebra.DifferentialWeylAlgebra(R, names=None)

The 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) ring
• names – (default: None) if None and R is a polynomial ring, then the variable names correspond to those of R; otherwise if names is specified, then R is 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


We can call W.inject_variables() to give the polynomial ring variables, now as elements of W, 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


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


Todo

Implement the graded_algebra() as a polynomial ring once they are considered to be graded rings (algebras).

Element
algebra_generators()

Return the algebra generators of self.

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}

basis()

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)]

degree_on_basis(i)

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

differentials()

Return the differentials of self.

EXAMPLES:

sage: W.<x,y,z> = DifferentialWeylAlgebra(QQ)
sage: W.differentials()
Finite family {'dx': dx, 'dy': dy, 'dz': dz}

gen(i)

Return the i-th generator of self.

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]

ngens()

Return the number of generators of self.

EXAMPLES:

sage: R.<x,y,z> = QQ[]
sage: W = DifferentialWeylAlgebra(R)
sage: W.ngens()
6

one()

Return the multiplicative identity element $$1$$.

EXAMPLES:

sage: R.<x,y,z> = QQ[]
sage: W = DifferentialWeylAlgebra(R)
sage: W.one()
1

options(*get_value, **set_value)

Sets the global options for elements of the differential Weyl algebra class. The default is to have the factored representations turned off.

OPTIONS:

• factor_representation – (default: False) Controls whether to factor the differentials out or not in the output representations

If no parameters are set, then the function returns a copy of the options dictionary.

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: D.options.factor_representation = True
sage: x
(12*t^2 + 6) + (8*t^3 + 18*t)*dt + (t^4 + 9*t^2)*dt^2 + (t^3)*dt^3

sage: D.options._reset()


See GlobalOptions for more features of these options.

polynomial_ring()

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

sage: R.<x,y,z> = QQ[]
sage: W = DifferentialWeylAlgebra(R)
sage: W.polynomial_ring() == R
True

variables()

Return the variables of self.

EXAMPLES:

sage: W.<x,y,z> = DifferentialWeylAlgebra(QQ)
sage: W.variables()
Finite family {'x': x, 'y': y, 'z': z}

zero()

Return the additive identity element $$0$$.

EXAMPLES:

sage: R.<x,y,z> = QQ[]
sage: W = DifferentialWeylAlgebra(R)
sage: W.zero()
0

class sage.algebras.weyl_algebra.DifferentialWeylAlgebraElement(parent, monomials)

An element in a differential Weyl algebra.

factor_differentials()

Return a dict representing self with 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}

list()

Return self as 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 of self corresponding 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)]

monomial_coefficients(copy=True)

Return a dictionary which has the basis keys in the support of self as keys and their corresponding coefficients as values.

INPUT:

• copy – (default: True) if self is internally represented by a dictionary d, then make a copy of d; if False, then this can cause undesired behavior by mutating d

EXAMPLES:

sage: W.<x,y,z> = DifferentialWeylAlgebra(QQ)
sage: dx,dy,dz = W.differentials()
sage: elt = (dy - (3*x - z)*dx)
sage: sorted(elt.monomial_coefficients().items())
[(((0, 0, 0), (0, 1, 0)), 1),
(((0, 0, 1), (1, 0, 0)), 1),
(((1, 0, 0), (1, 0, 0)), -3)]

support()

Return the support of self.

EXAMPLES:

sage: W.<x,y,z> = DifferentialWeylAlgebra(QQ)
sage: dx,dy,dz = W.differentials()
sage: elt = dy - (3*x - z)*dx + 1
sage: sorted(elt.support())
[((0, 0, 0), (0, 0, 0)),
((0, 0, 0), (0, 1, 0)),
((0, 0, 1), (1, 0, 0)),
((1, 0, 0), (1, 0, 0))]

sage.algebras.weyl_algebra.repr_factored(w, latex_output=False)

Return a string representation of w with 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'


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

sage.algebras.weyl_algebra.repr_from_monomials(monomials, term_repr, use_latex=False)

Return a string representation of an element of a free module from the dictionary monomials.

INPUT:

• monomials – a list of pairs [m, c] where m is the index and c is the coefficient
• term_repr – a function which returns a string given an index (can be repr or latex, for example)
• use_latex – (default: False) if True then 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)]
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'>


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'>


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'>

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'>


Leading minus signs are dealt with appropriately:

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'>


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