1
$\begingroup$

I want to do an operation like

$$ AA \otimes BB \times AA' \otimes BB' $$

and have

$$AA \times AA' \otimes BB \times BB' $$

without specifying the elements of $AA$s and $BB$s (and so are their primes).

pseudocode would be

term1 = TensorProduct[AA1,BB1];
term2 = TensorProduct[AA2,BB2];
term1.term2

however this returns:

$$ AA1\otimes BB1 . AA2\otimes BB2$$

$\endgroup$
4
  • $\begingroup$ The dot means: contraction over the last index of the left tensor and first index of the right tensor. It seems to me, that is not what you want. $\endgroup$ Aug 24, 2023 at 16:49
  • $\begingroup$ Yes, that is not what i want, but also * or Times doesn't do the trick either.... :( $\endgroup$
    – Tom
    Aug 25, 2023 at 7:45
  • $\begingroup$ Your notation is a bit confusing. Why use two capital letters? I.e. is this equivalent to replacing AA by A, BB by B, AA' by A', BB' by B'? The "circled X" is the common symbol for a tensor product, but what type of multiplication is the plain "X" supposed to be? If you were to do this simple case by hand, what type of "x" yields your expected result? You seem to want to distribute across the two terms, with stuff like BB x AA' + AA x BB' = 0; otherwise your identity doesn't seem to hold. $\endgroup$
    – user87932
    Aug 25, 2023 at 18:11
  • $\begingroup$ Does this answer to a similar question help? $\endgroup$
    – Carl Woll
    Aug 26, 2023 at 22:36

1 Answer 1

1
$\begingroup$
relations={
        (*CircleTimes[x_,k_?scalarQ*y_.]:>
            k CircleTimes[x,y],
        CircleTimes[k_?scalarQ*x_.,y_]:>
            k CircleTimes[x,y],
        CircleTimes[x_+y_,z_]:>
            CircleTimes[x,z]+CircleTimes[y,z], 
        CircleTimes[z_,x_+y_]:>
            CircleTimes[z,x]+CircleTimes[z,y],*)
        x_CircleTimes**y_CircleTimes:>
            Thread[x**y,CircleTimes]/;Length@x==Length@y    
    };

(*scalarQ[expr_]:=FreeQ[expr,Alternatives[a,b,a1,b1]];*)
(a⊗b)**(a1⊗b1)//.relations
(*a**a1⊗b**b1*)

This is a prototype example of tensor product.

I'd like to use NonCommutativeMultiply and CircleTimes without internal definitions, which makes the computation more controllable. You can change to TensorProduct.

For more complicated examples see How to `Thread` over lists with unequal lengths?

The commented codes implement the linearity of tensor product, and are irrelevant to this example.

$\endgroup$

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.