1
$\begingroup$

I am trying to do some quantum algebra computations in Mathematica. Up to now I was able to make the noncommutative multiplication linear and to factorize powers. However, I still have some issues with associativity. In particular, I would like to be able to remove brackets expressions like a ** ( b ** c ) and get a ** b ** c. The reason for that is that I already have a procedure that substitutes a^2 ** b to a ** a ** b, but this doesn't work when I have brackets (a ** ( a ** b )).
Does anyone know how to overcome this problem?

$\endgroup$
  • 1
    $\begingroup$ Could you provide your procedure? Why do you use noncommutative multiplication ** only in the last formula? $\endgroup$ – ybeltukov Sep 24 '13 at 15:15
  • 5
    $\begingroup$ Take a look at the NCAlgebra package, like here $\endgroup$ – Szabolcs Sep 24 '13 at 15:19
  • $\begingroup$ I am sorry, that was a typo... I just corrected everything, it's noncommutative multiplication all along. $\endgroup$ – far Sep 29 '13 at 16:39
  • $\begingroup$ @user37905 Maybe there is * in the last formula? Otherwise I don't understand because a ** (a ** b) automatically converts to a ** a ** b. $\endgroup$ – ybeltukov Sep 29 '13 at 16:52
1
$\begingroup$

The problem (if I understand correctly) is that you want to make the following replacements:

a * (a * c)  ==> a * a * c   ==> a^2 * c
a * (a ** c) ==> a * a ** c  ==> a^2 ** c

The trick is that in the second line, a * a ** c is parenthesised as a * (a ** c), where a * a is not recognized as a^2. Use the following rule:

rep = (x_*(x_ ** y__) :> x^2 ** y);
a*(a ** c)                 (* ==>   a a ** c)        *)
a*(a ** c ** d) /. rep     (* ==>   a^2 ** c ** d    *)
a*(b ** a) /. rep          (* ==>   a b ** a     NC-ity is maintained    *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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