I am starting to work with non-commutative algebra in Mathematica and had a look at the NCAlgebra package. I installed it and can use its functions. However, what I am struggling with is the SetCommutingOperators
command, described in I.4.6.4 of the documentation. Honestly, LeftQ
, SetCommutingFunctions
and SetCommutingOperators
just reference themselves in a cycle if I am not mistaken - which disallows me to fully understand the important note about using LeftQ
.
How do I properly define that two symbols a
and b
commute, such that a**b-b**a==0
. Some code with (as it appears) no effect of SetCommutingOperators
:
ClearAll["Global`*"];
<< NC`
<< NCAlgebra`
SetCommutingOperators[a, b]
a ** b == b ** a`
(* a ** b == b ** a *)
NCE[b ** a - a ** b]
(* -a ** b + b ** a *)
It is important, that a
and b
are not commutative in general.
Clarification
It was suggested in a comment to use SetCommutative[a,b]
which achieves the desired result in this case. However, this is the wrong approach as you can see if there is a second operator c
with that a
and b
should not commute:
SetCommutative[a, b]
a**c-c**a
(* 0 *)
This is not desired; it should be -c**a+a**c
. SetCommutative
sets a
and b
commutative in general, but they should only commute with each other.
SetCommutative[a, b]
. It works. $\endgroup$a
andb
commute with everything. See update $\endgroup$