# Simplifying polynomials in non-commutative variables

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)

• I would imagine that's because $b^2$ means b*b and not b**b. Sep 13, 2013 at 3:29
• 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. Sep 13, 2013 at 6:13
• 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.
– gpap
Sep 13, 2013 at 10:44
• There is code for this sort of thing in the section "Some noncommutative algebraic manipulation" of the nb available here. Sep 13, 2013 at 15:13 