Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)

share|improve this question
I would imagine that's because $b^2$ means b*b and not b**b. – bill s Sep 13 '13 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. – Ken Gonzales Sep 13 '13 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 '13 at 10:44
There is code for this sort of thing in the section "Some noncommutative algebraic manipulation" of the nb available here. – Daniel Lichtblau Sep 13 '13 at 15:13

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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