I am running the code below in Macaulay2.
load "Dmodules.m2"
R = QQ[x_11,x_12,x_21,x_22]
D = makeWeylAlgebra R
a = x_11*dx_21 + x_12*dx_22
b = x_22*dx_22 + 2
a*b
matrix{{a}} * matrix{{b}}
The code is very straightforward of course. I am multiplying two elements of the Weyl algebra. The output when I do a*b is $$x_{11}x_{22}\partial x_{21}\partial x_{22} + x_{12}x_{22}\partial x_{22}^2 + 2x_{11}\partial x_{21} + 3x_{12}\partial x_{22},$$ whereas matrix{{a}} * matrix{{b}} gives $$x_{11}x_{22}\partial x_{21}\partial x_{22} + x_{12}x_{22}\partial x_{22}^2 + 2x_{11}\partial x_{21} + 2x_{12}\partial x_{22}.$$
Clearly, I am misunderstanding something because I expect the output of a*b when I do matrix{{a}}*matrix{{b}}, because that is what I get when I do it by hand. Should I be using some different syntax here? Any insight most appreciated.
EDIT:
matrix{{b}} * matrix{{a}}
gives $$x_{11}x_{22}\partial x_{21}\partial x_{22} + x_{12}x_{22}\partial x_{22}^2 + 2x_{11}\partial x_{21} + 3x_{12}\partial x_{22}.$$ This is consistent with other things I have observed. For instance, if I take a ideal with elements in the weyl algebra, and compute a free resolution, say x, and I do
x.dd_1 * x.dd_2,
then I get 0. But when I do
transpose(x.dd_2) * transpose(x.dd_1),
I don't get 0. So somehow, when multiplying matrices with elements from a Weyl algebra, the order is reversed?
This is a feature (albeit an unexpected one for many) not a bug: http://www2.macaulay2.com/Macaulay2/doc/Macaulay2-1.18/share/doc/Macaulay2/Macaulay2Doc/html/___Weyl_spalgebras.html
The wording in the current documentation seems to be imprecise: the order of matrices in multiplication is not reversed, but one should treat the entries of the matrices as if they are in the opposite algebra of the Weyl algebra.