10
$\begingroup$

How does mathematica evaluate the following expression to zero:

-a ** (b ** c - c ** b) + b ** (a ** c - c ** a) - 
 c ** (a ** b - b ** a) + (a ** b - b ** a) ** 
  c - (a ** c - c ** a) ** b + (b ** c - c ** b) ** a

In the reference of the non commutative multiplication ** is stated that it is assumed to be associative and consequently the expression should be equal to zero. However just applying Simplify[] doesn't work for me.

$\endgroup$
5
  • $\begingroup$ The problem seems to be that Mathematica doesn't consider ** to be distributive: a**(b+c)-a**b-a**c doesn't evaluate to 0, not even with FullSimplify. $\endgroup$
    – celtschk
    Commented May 12, 2012 at 12:14
  • $\begingroup$ Ok. But if this is true, it should be considered as a bug, because in the context of rings the term 'multiplication' referees to something that is distributive and since '-' and '+' are there, too, we should think at least in terms of rings here. $\endgroup$ Commented May 12, 2012 at 12:17
  • $\begingroup$ @Mark This is not a bug. The system simply doesn't have many operations built-in for non-commutative operators. Simplify/Expand/etc. assume complex numbers, not general operators. $\endgroup$
    – Szabolcs
    Commented May 12, 2012 at 13:07
  • $\begingroup$ Have you looked at the NCAlgebra package that has been suggested in your last question? It looks like something exactly for this. $\endgroup$
    – Szabolcs
    Commented May 12, 2012 at 13:08
  • $\begingroup$ Ok I wasn't aware of the restrictions of Simplify ect. but on a first look I think the recommended package is what I need. $\endgroup$ Commented May 12, 2012 at 13:27

1 Answer 1

11
$\begingroup$

What you need here is actually expanding the expression (i.e. transforming all (a+b) ** c type expressions to a**c + b**c). There's no built-in support for this kind of manipulation of non-commutative expressions. You'd need to implement them yourself, which can be quite a bit of work.

However, instead of bothering with implementing all these simple operations yourself, I recommend using a dedicated package. @gpap suggested the NCAlgebra package in an answer to your previous question.

After installing NCAlgebra by placing the NC directory in my $UserBaseDirectory/Applications directory, I could do this:

<< NC`
<< NCAlgebra`

expr = -a ** (b ** c - c ** b) + b ** (a ** c - c ** a) - 
  c ** (a ** b - b ** a) + (a ** b - b ** a) ** 
   c - (a ** c - c ** a) ** b + (b ** c - c ** b) ** a

NCExpand[expr]

(* ==> 0 *)
$\endgroup$
9
  • $\begingroup$ Hmm wen I use the NC package I get NCExpand[Y01 ** Y10 - Y10 ** Y01] =0. Seems ** is interpreted differently here. $\endgroup$ Commented May 16, 2012 at 11:19
  • 1
    $\begingroup$ @Mark That is very strange. It seems Y01 ** Y10 - Y10 ** Y01 evaluates to 0 when using that package. a**b - b**a doesn't however. I am not familiar with the package, but I'll try to see what's going on. $\endgroup$
    – Szabolcs
    Commented May 16, 2012 at 11:23
  • 2
    $\begingroup$ @Mark Originally I suggested using expr //. e_NonCommutativeMultiply :> Distribute[e]. However, this won't work for an expression like a ** f[b ** (c + d)], so I'm removing it. $\endgroup$
    – Szabolcs
    Commented May 16, 2012 at 11:31
  • 1
    $\begingroup$ Using SetNonCommutative[] worked. I wrote a little program that put all the thousands of indexed variables into SetNonCommutative[] and then used NCExpand[] to do the job, which it did pretty well. Good package. Robust even on input data >1MB ... $\endgroup$ Commented May 18, 2012 at 16:05
  • 1
    $\begingroup$ The newest version of NCAlgebra supports Subscript. If the base symbol is noncommutative so will be its subscripted version. Things like: Subscript[x, 0, 1] ** Subscript[x, 1, 0] - Subscript[x, 1, 0] ** Subscript[x, 0, 1] will work out of the box. $\endgroup$ Commented Apr 19, 2017 at 16:13

Your Answer

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

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