# Exploit bilinearity of KroneckerProduct symbolic calculations and inconsistence (apparently)

Mathematica 10 recognizes the bilinearity of the trace and the Kronecker product, as well as Tr$$\otimes$$Tr$$(A\otimes B)=$$Tr($$A$$)Tr($$B$$). But I have issues trying to implement this in symbolic calculations:

• Kronecker Product:

As an example, consider

$$[(A^3- 2 t A^2) \otimes 1_n ]\cdot[(A+3t 1_n)\otimes 4 t A^2] \qquad t\in \mathbb C, A \, n\times n\, \text{matrix}$$

The code should be consistent with distributing, e.g. the first round parenthesis, but it seems it is not. For

$Assumptions = (t) ∈ Complexes && (A) ∈ Matrices[{n, n}]; Id = IdentityMatrix[n]; (* I evaluate an expression implying KroneckerProduct, and extract the cubic coefficient *) (KroneckerProduct[A.A.A, Id] + KroneckerProduct[-2 t A.A, Id]).KroneckerProduct[A + 3 t Id, 4 t A.A] // TensorExpand; Coefficient[%, t^3]  the result of this is 0. However, if I do not distribute, the result of KroneckerProduct[A.A.A - 2 t A.A, Id].KroneckerProduct[A + 3 t Id, 4 t A.A] // TensorExpand Coefficient[%, t^3]  is -24 KroneckerProduct[MatrixPower[A, 2], MatrixPower[A, 2]]  • Trace: The trace (Tr $$\otimes$$ Tr) of the Kronecker Product is the product of the traces. A second issue is that Tr $$\otimes$$ Tr$$[(1_n\otimes t A^2 -t A^2\otimes 1_n) (1_n \otimes 1_n)]$$ should vanish. But I cannot see Mathematica knows it: Tr[(KroneckerProduct[Id, t A.A] - KroneckerProduct[t A.A, Id]).(KroneckerProduct[Id, Id])//TensorExpand] === 0  yields False, under the same hypothesis as above. • Please include version number. I saw your 0 result in M11.1, but not in later versions. As for the second question, do you have a symbolic formula for the tensor contraction of the first two indices of a KroneckerProduct of higher rank tensors? That is, what is Tr[KroneckerProduct[A, B]] where one of A and B has a rank higher than 2. What about tensor contractions of the first and third, if the KroneckerProduct has a rank higher than 2? Jun 1 '20 at 16:26 • @I added the version, 10. To the second question: I have no formula: For me, the trace is Tr$\otimes$Tr, but important is what Mathematica says, which coincides with my definition: "The trace Tr for a Kronecker product satisfies Tr[a$\otimes$b]=Tr[a]Tr[b]" in "properties" of reference.wolfram.com/language/ref/KroneckerProduct.html – João Jun 2 '20 at 6:31 ## 1 Answer Similarly to my answer to your other question, it looks like support for recognizing this property was added in M11.2 or M11.3. In M11.1 I get: $Assumptions = t ∈ Complexes && A ∈ Matrices[{n,n}];
Id = IdentityMatrix[n];
(KroneckerProduct[A.A.A,Id]+KroneckerProduct[-2 t A.A,Id]).KroneckerProduct[A+3 t Id,4 t A.A]//TensorExpand;
Coefficient[%,t^3]


0

while in M11.3 I get:

\$Assumptions = t ∈ Complexes && A ∈ Matrices[{n,n}];
Id = IdentityMatrix[n];
(KroneckerProduct[A.A.A,Id]+KroneckerProduct[-2 t A.A,Id]).KroneckerProduct[A+3 t Id,4 t A.A]//TensorExpand;
Coefficient[%,t^3]


-24 KroneckerProduct[MatrixPower[A, 2], MatrixPower[A, 2]]

So, the simplest solution is to upgrade to a later version of Mathematica. I think it is possible to modify TensorExpand so it works properly in M10 as well, but I haven't investigated that possibility.

As for Tr support, I think the property you want is only valid for matrices, and not general tensors. For example:

X = RandomReal[1,{3,3,3}];
Y = RandomReal[2,{2,2}];

Tr[X] Tr[Y]
Tr[KroneckerProduct[X, Y]]


1.97249

1.2567

That being said, I think it is reasonable to write to support and ask for this to be supported in a future version of Mathematica. Again, I think it is possible to add support for this kind of operation in older versions of Mathematica as well.

• Sure, I'm not interested in tensors: Assuming[ t \[Element] Reals && (A) \[Element] Matrices[{n, n}] , Tr[(KroneckerProduct[Id, t A.A] - KroneckerProduct[t A.A, Id]).(KroneckerProduct[Id, Id]) // TensorExpand] === 0] yields False though.
– João
Jun 2 '20 at 15:14