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 toa1**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
anda2**(a1**b1)
substitute toe1**b1
anda2**(c1+d1)
, respectively, or both toe1**b1
due to flatness of**
?
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 useNonCommutativeMultiply
you can in theory unprotect it, then addUpValues
, but that is frowned upon and a bit dangerous. $\endgroup$Distribute[(a1 + a2 + a3) ** (b1 + b2 + b3)]
as well. $\endgroup$