I would like to be able to simplify a polynomial in two non commuting variables, the desired result being that in every term one variable occurs to the left of the other variable. An example would be the normal ordering of operators from the Weyl algebra.

In addition, I would like to be able to specify the commutation relation as well. Say, if the variables are $a$ and $b$, I would like to specify an equation involving $a$ and $b$ which is equal to zero. For example $ab-ba-1=0$ in the case of the Weyl algebra.

I've tried the non commutative multiplication $**$. It appears that this function is simply formal multiplication. I tried inputting $a**b**b$ but it's not even giving me $ab^2$. (2)

  • $\begingroup$ I would imagine that's because $b^2$ means b*b and not b**b. $\endgroup$
    – bill s
    Commented Sep 13, 2013 at 3:29
  • $\begingroup$ If the variables are the same, then $b^2=b*b=b**b$. My point being, if I use **, what Mathematica does is adjoin the variables and nothing else. $\endgroup$ Commented Sep 13, 2013 at 6:13
  • 1
    $\begingroup$ I have used the NCAlgebra package for similar calculations (calculating group function non-commutativity from the quantum yang baxter equation) and I highly recommend it for that sort of thing. $\endgroup$
    – gpap
    Commented Sep 13, 2013 at 10:44
  • $\begingroup$ There is code for this sort of thing in the section "Some noncommutative algebraic manipulation" of the nb available here. $\endgroup$ Commented Sep 13, 2013 at 15:13

1 Answer 1


There are several packages available to do what you want. Here I show a quick screenshot of how to do noncommutative algebra with FeynCalc. You can find documentation here, here and here

Mathematica graphics


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.