By default, an expression like
NoncommutativeMultiply[x] does not simplify to
Plus[x]. My attempts to implement an automatic replacement e.g.:
Unprotect[NonCommutativeMultiply]; NonCommutativeMultiply /: NonCommutativeMultiply[x_] := x; Protect[NonCommutativeMultiply];
tend to go into infinite loops e.g. when typing
x**y. I understand why this is the case for a function like
NonCommutativeMultiply with attribute
Flat. However, I have been unable to find a way to overcome this behaviour and obtain replacements like for
Similarly, I also cannot find a way to automatically replace
1 without causing infinite loops (again,
Times work fine giving 0 and 1, respectively).
Any help would be greatly appreciated.