Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm constantly dealing with non-commutative algebras. ** is inbuilt, non-commutative and associative. That's good :-) But it is not distributive. Rats.

  • What is a simple way (I probably won't need much more) to have, say, (a1 + a2 + a3)**(b1 + b2 + b3) always expand to a1**b1 + ... + a3**b3, on the fly?
  • And if I like to add (also executed on the fly) laws like a1**b1 = c1 + d1?
  • And, last question, if I did and have a2**a1**b1 (with, say, a2**a1 = e1 forced), do (a2**a1)**b1 and a2**(a1**b1) substitute to e1**b1 and a2**(c1+d1), respectively, or both to e1**b1 due to flatness of **?
share|improve this question
    
Are you familiar with UpValues? The easiest thing to do would be to create your own symbol (to which you can set your own rules and infix). However, if it is important to still use NonCommutativeMultiply you can in theory unprotect it, then add UpValues, but that is frowned upon and a bit dangerous. –  VF1 Feb 28 '13 at 15:23
    
There is of course Distribute[(a1 + a2 + a3) ** (b1 + b2 + b3)] as well. –  chuy Feb 28 '13 at 16:20
    
For distribution you should consult the second application of NCM in Mathematica Documentation. –  Stefan Feb 28 '13 at 18:20

1 Answer 1

I recommend you try the NCAlgebra package if you are going to do these kinds of computations. It is a mature package that has been under development for many years. The function you are looking for is NCExpand.

share|improve this answer
    
I will never grow tired of upvoting an answer suggesting this package. +1 –  gpap Feb 28 '13 at 15:45
    
THX! Frankly, the existence of such a package doesn't surprise me in the least, but still being a MATHEMATICA n00b, I would have googled minutes for it :-) I'll give it a try. –  user6152 Mar 2 '13 at 15:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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