0
$\begingroup$

I use the NCAlgebra Package. Now when I enter the square(so standard product) of a noncommuting variable Mathematica returns the variable with NonCommutativeMultiply:

p*p

returns

p**p

Product of two different variables just returns as expected

a*b

returns

ab

Anyone can reproduce this? I don't think this can be the desired behavior?

$\endgroup$
2
$\begingroup$

@lennart this is the default behavior starting with version 5 of NCAlgebra. Mixing Times and ** is a source of much trouble as it can easily generate expressions that cannot be correctly interpreted. Think a**b * c when a, b and c are all noncommutative. So, after much debate, we decided to start overloading Power for noncommutative symbols. It is done with UpValues so it should not be too intrusive.

This was however not an easy decision. Canonizing expressions is a much needed step in any symbolic computation and this is exactly why MMA also canonizes Times[p, p] as Power[p,2]! However, as you noticed, a * b is still Times[a, b]! Indeed, it is not possible to easily overload Times without been too intrusive. Think Times[b, a] that gets alphabetized as Times[a, b] before any rule can be applied. As a compromise we have introduced the command NCConsistentQ that will return True is an expression is a consistent NC expression.

$\endgroup$
2
  • $\begingroup$ Probably safer to leave both Times and Power alone, and document that Times should only be used with quantities that commute (or better, only use it when there are two operands, one of which is a scalar that commutes with everything). $\endgroup$ Dec 16 '18 at 15:43
  • $\begingroup$ As I said, not an easy decision. I should also say that version 5 brought overloading Power for another much stronger reason: making sure that symbols which print nicely with transpose and inverses were actually interpreted correctly. This allows one to copy from an output into an input without having to worry about garbage. This was not possible prior to v5 and is a much convenient feature. $\endgroup$ Dec 18 '18 at 6:20

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.