I am using Mathematica 8. Is there any way to make a noncommutative tensor product calculation? For instance, I have the following relations :

$XY=YX; \ Xt=qtX; \ Yt=qtY$.

Is there any way to make a tensor product calculations, such as for examples

$(tY \otimes X)(Xt \otimes t)= tYXt \otimes Xt \\=tXYt \otimes Xt \\= (q^{-1}Xt)(qtY) \otimes qtX \\= Xt^{2}Y \otimes qtX \\= qXt^{2}Y \otimes tX$


$(tY\otimes t)(t^{2}\otimes Y^{2}+ X^{2}\otimes Xt )= tYt^{2}\otimes tY^{2}+tYX^{2}\otimes tXt \\= q^{2}t^{3}Y \otimes tY^{2}+tX^{2}Y\otimes q^{-1}Xt^{2}\\= q^{2}t^{3}Y \otimes tY^{2} + q^{-3}X^{2}tY \otimes Xt^{2}$

or any other calculations?

Thank you very much

  • $\begingroup$ I am not very knowledgeable on this topic, so I don't know if the following packages will help, but you may want to look at them ... math.ucsd.edu/~ncalg xact.es Mathematica 8 doesn't have built-in tensor calculation support. $\endgroup$
    – Szabolcs
    Sep 19, 2016 at 9:38
  • $\begingroup$ @Szabolcs : but is it possible to make such program in Mathematica 9? I know that Mathematica 8 doesn't support tensor calculation, so I'm thinking to use other computers which has Mathematica 9 $\endgroup$
    – R. Kasyfil
    Sep 19, 2016 at 11:02
  • $\begingroup$ You should include that in the main question. $\endgroup$
    – Szabolcs
    Sep 19, 2016 at 11:34

1 Answer 1


NCAlgebra does not have a native tensor product. Here is one definition that might need some refinement for prime time, but that might be useful:

NCKron[x_, middle___, (a_?CommutativeQ) y_, right___] := NCKron[a x, middle, y, right];
NonCommutativeMultiply[left___, NCKron[x__], NCKron[y__], right___] := NonCommutativeMultiply[left, NCKron @@ Thread[NonCommutativeMultiply[{x}, {y}]], right] /; Length[{x}] === Length[{y}];

With that definition and my interpretation of your example above you would have that

SetNonCommutative[X, Y, t]
expr = NCKron[t ** Y, X] ** NCKron[X ** t, t]

evaluates to

NCKron[t ** Y ** X ** t, X ** t]

Applying the rules

rules = {X ** Y -> Y ** X, X ** t -> q t ** X, Y ** t -> q t ** Y};
NCReplaceRepeated[expr, rules]

would lead to

NCKron[q^3 t ** t ** Y ** X, t ** X]


expr = NCKron[t ** Y, t] ** (NCKron[t^2, Y^2] + NCKron[X^2, X ** t])

is such that


evaluates to

NCKron[t ** Y ** t ** t, t ** Y ** Y] + NCKron[t ** Y ** X ** X, t ** X ** t]


NCReplaceRepeated[NCExpand[expr], rules]

evaluates to

NCKron[q^2 t ** t ** t ** Y, t ** Y ** Y] + NCKron[q t ** Y ** X ** X, t ** t ** X]


Your Answer

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

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