2
$\begingroup$

I want to manipulate expressions like

$$\big\{(aX+bY)\otimes Z \big\}\cdot \big\{U \otimes (c V+d W) \big\} $$

so that Mathematica (10) yields

$$ (aX U+bYU)\otimes(cZV+dZW) = acXU\otimes ZV+bcYU\otimes ZV+ adXU\otimes ZW +bd YU\otimes ZW$$

for finite matrices of the same size (in capitals) and scalars (lowercase).

In the this question TensorExpand is used in order to take the scalars out of the Dot product. (I actually was used to TeX-SE forum once, where one has to put the core of the code only, but I oversimplified the linked question, and I apologize)

Assuming[(a | b | c) ∈ Reals && (X | Y) ∈ 
   Matrices[{n, n}], 
 TensorExpand[
  KroneckerProduct[IdentityMatrix[n], a X].(b KroneckerProduct[c IdentityMatrix[n], Y])]] 
  (*...................................this ^ is culprit?...................*)
  • If I remove the b, the result is: $ac (1_n\otimes XY)$

  • But if b is there, only intermediate steps are shown, even though I used the TensorExpand as in that linked answer.

Why it does not work for Kronecker products?

Another remark is that substituting the b by a number, say $\pi$, then it does yield $ac\pi (1_n\otimes XY)$.

What am I missing for making Dot to simplify the computation?

P.S. I also tried the hint here, namely

Unprotect[Dot];
Dot[a___, d_?NumericQ b_, c___] := d Dot[a, b, c]
Protect[Dot];

but it does not help.

$\endgroup$
2
  • 2
    $\begingroup$ I think my answer at mathematica.stackexchange.com/a/165511 should help you. You can either define a new function that works well with symbolic expressions, or define a replacement rule for KroneckerProduct and Dot that pulls out scalars $\endgroup$ Commented Jun 3, 2020 at 3:40
  • $\begingroup$ @JulesLamers Yes, your linked answer is very promising and more instructive than upgrading my software! (since I'd need to implement the cyclicity of the product, which I would have on traces). $\endgroup$
    – João
    Commented Jun 3, 2020 at 9:27

1 Answer 1

4
$\begingroup$

It looks like support for recognizing this property was added in M11.2 or M11.3. In M11.1 I get:

Assuming[
    (a|b|c) ∈ Reals && (X|Y) ∈ Matrices[{n,n}],
    TensorExpand[
        KroneckerProduct[IdentityMatrix[n],a X].(b KroneckerProduct[c IdentityMatrix[n],Y])
    ]
]

KroneckerProduct[IdentityMatrix[n], a X].(b KroneckerProduct[c IdentityMatrix[n], Y])

while in M11.3 I get:

Assuming[
    (a|b|c) ∈ Reals && (X|Y) ∈ Matrices[{n,n}],
    TensorExpand[
        KroneckerProduct[IdentityMatrix[n],a X].(b KroneckerProduct[c IdentityMatrix[n],Y])
    ]
]

a b c KroneckerProduct[IdentityMatrix[n], X.Y]

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.

$\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.