3
$\begingroup$

Is the non-commutative product in NCAlgebra also not distributive? From the documentation it seems it should be. But here is an expression, that it does not seem to be able to simplify:

SetNonCommutative[A, B];
SetCommutingOperators[C1];
Commutator[x_, y_] = x ** y - y ** x;
SetCommutators = {Commutator[A, B] :> 1};
G1 = Commutator[A, B + C1];
NCReplaceAll[G1, SetCommutators]
(* A ** (B + C1) - (B + C1) ** A *)

However this should be simplified to 1, since the commutator $[A,B]=1$ and $[A,C1]=[B,C1]=0$.

On the other hand the bare commutator can be simplified correctly:

SetNonCommutative[A, B];
SetCommutingOperators[C1];
Commutator[x_, y_] = x ** y - y ** x;
SetCommutators = {Commutator[A, B] :> 1};
G1 = Commutator[A, B];
NCReplaceAll[G1, SetCommutators]
(* 1 *)

The behaviour in the first case is also obtained with a number instead of C1:

SetNonCommutative[A, B];
SetCommutingOperators[C1];
Commutator[x_, y_] = x ** y - y ** x;
SetCommutators = {Commutator[A, B] :> 1};
G1 = Commutator[A, B + 1];
NCReplaceAll[G1, SetCommutators]
(* A ** (1 + B) - (1 + B) ** A *)

So either the operation ** is not distributive or I am really confused why NCAlgebra can not simplify this expression. Maybe I am doing something wrong?

Formulated as a simple question: how can I get NCAlgebra to simplify the expression in the first code snippet to 1?

$\endgroup$
3
  • $\begingroup$ If it's relevant: I am using NCAlgebra 5.0.4 with Mathematica 12.0. $\endgroup$ Aug 21, 2019 at 8:20
  • $\begingroup$ Just use Distribute on ** or add an UpValue to NonCommutativeMultiply $\endgroup$
    – b3m2a1
    Aug 24, 2019 at 0:40
  • $\begingroup$ @b3m2a1 Thanks! I’d be happy to accept that as an answer if you provide a code snippet that works! And maybe a short explanation of why this is necessary (I thought for example that ** is distributive by default, but according to your comment that seems to be not the case) $\endgroup$ Aug 24, 2019 at 7:59

1 Answer 1

1
$\begingroup$

Mathematica does not have an automatic distributive property and for a good reason. If it existed it would be impossible to collect or simplify expressions into products of sums. In order to trigger the distributive property you should use the Expand function. For example, the following expression in Mathematica

(A + B) C - A (C + B C/A)

remains as written above. However,

(A + B) C - A (C + B C/A) // Expand

evaluates to 0.

Likewise, NCAlgebra has NCExpand, which in your case can be used in

NCReplaceAll[NCExpand[G1], SetCommutators]

to produces the desired value of 1.

$\endgroup$

Your Answer

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

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