0
$\begingroup$

I want to verify that a matrix $R$ satisfies this equation $$ \left(R\otimes id\right)\left(id\otimes R\right)\left(R\otimes id\right)=\left(id\otimes R\right)\left(R\otimes id\right)\left(id\otimes R\right) $$ Are this lines correct?

R = ({{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 0, q}, {0, 0, q, 1 - q^2}});
id = IdentityMatrix[4];
r1 = KroneckerProduct[id, R]; 
r2 = KroneckerProduct[R, id]; 
r1.r2.r1 - r2.r1.r2 // MatrixForm

Of course the matrix R would be the one to check. The result in a positive case of course should be the zero matrix. Is the syntax correct?

$\endgroup$
  • 1
    $\begingroup$ What about using TensorProduct? $\endgroup$ – Henrik Schumacher Mar 10 '18 at 8:07
  • $\begingroup$ is it different? $\endgroup$ – Dac0 Mar 10 '18 at 10:22
  • $\begingroup$ Doesn't work with TensorProduct $\endgroup$ – Dac0 Mar 10 '18 at 10:24
  • 1
    $\begingroup$ Aha. You know that "it doesn't seem to work" is very useless problem description, do you? Moreover, this is not necessarily a problem with Mathematica but with the matrix R... $\endgroup$ – Henrik Schumacher Mar 10 '18 at 11:10
  • 1
    $\begingroup$ You know, context is important... $\endgroup$ – Henrik Schumacher Mar 10 '18 at 11:21
1
$\begingroup$

What is you definition of the multiplication in $(A \otimes B) \cdot (C \otimes D)$? Probably it does not coincide with Mathematica's Dot. Honestly, I am not entirely sure what KroneckerProduct does with matrices and how this interacts with Dot (personally, I use KroneckerProduct solely for vector-vector pairs). So I try to boil things down to TensorProduct and TensorContract.

As can be read off from the documentation, Dot merely contracts the last slot of the first argument with the first slot of the second argument. So that would be

$$(A \otimes B) . (C \otimes D) = A \otimes (B \cdot C) \otimes D.$$

In Mathematica syntax, Dot is equivalent on pairs of 4-tensors to the following function:

dot[S_?(TensorRank[#] == 4 &), T_?(TensorRank[#] == 4 &)] := 
  TensorContract[S\[TensorProduct]T, {4, 5}];

This is why $(A \otimes B) . (C \otimes D)$ is a tensor of rank 6 and not of rank 4.

I guess you think in terms of matrix algebras, so maybe you mean

$$(A \otimes B) \cdot (C \otimes D) = (A \cdot C) \otimes (B \cdot D).$$

I think the desired product can be expressed unambiguously by the following function:

newdot[S_?(TensorRank[#] == 4 &), T_?(TensorRank[#] == 4 &)] := 
  TensorContract[S\[TensorProduct]T, {2, 5, 4, 7}];
$\endgroup$
  • $\begingroup$ thank you, could you add also the correct syntax? $\endgroup$ – Dac0 Mar 10 '18 at 11:27
  • $\begingroup$ I'm not sure I followed you until the end... I mean what is the problem if I first calculate the matrices KroneckerProduct and then I multiply them? $\endgroup$ – Dac0 Mar 10 '18 at 11:34
  • $\begingroup$ Sorry about the mess with KroneckerProduct. I edited the post with hopefully correct code. $\endgroup$ – Henrik Schumacher Mar 10 '18 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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