# Symbolic matrix tensor an identity without specifying the dimension?

I want to calculate an expression like $$\left( M_1\otimes I+I\otimes M_2 \right) ^l$$ with $$M_i$$'s symbolic matrices and $$I$$ the identity matrix with Mathematica. $$M_i$$'s are of the same dimension and my problem is how can I realize such an identity matrix without specifying the dimension of it, it should just work like a matrix multiply any matrix will still be the matrix itself(although it should be the same dimension as all the $$M_i$$)? Or is there some method that I can specify the dimension of the symbolic matrix $$M_i$$?

• After seeing the final edit, you can do something like this I guess. I forgot the exponent, but you get the general idea I think
– bmf
Feb 6 at 0:59
• @bmf Thanks very much. I mean, is there some method that I can do not see the component of the matrix? For example, for $\left( M_1\otimes I+I\otimes M_2 \right) ^2$, the result I hope to see is $M_{1}^{2}\otimes I+I\otimes M_{2}^{2}+2M_1\otimes M_2$. Feb 6 at 1:11
• I guess you could try some global assumptions on the matrices and then do MatrixPower and TensorExpand or their cousins, but I have not managed to make it work.
– bmf
Feb 6 at 2:48

I think you can use KroneckerProduct and TensorExpand. Define:

e = KroneckerProduct[M1, IdentityMatrix[d]] + KroneckerProduct[IdentityMatrix[d], M2];


Then:

TensorExpand[e . e, Assumptions -> (M1|M2) ∈ Matrices[{d, d}]]


2 KroneckerProduct[M1, M2] + KroneckerProduct[IdentityMatrix[d], MatrixPower[M2, 2]] + KroneckerProduct[MatrixPower[M1, 2], IdentityMatrix[d]]

• What about MatrixPower[e,l]? Feb 7 at 0:22
• @narip Can you be more specific about your question? Is it that you want to see M1 . M1 instead of MatrixPower[M1, 2]? Feb 7 at 0:30
• Oh, thanks. I mean, if I want to see e.e.e or more e.e.e.e, how can I do this? I try MatrixPower[e,3], but the result of Mathematica also contains MatrixPower[e,3]. Feb 7 at 1:19

Note that the symbol "[CircleTimes]" has not predefined meaning.Therefore, the terms are algebraically simply treated as one object. Further, "I" has built in meaning of Sqrt[-1], do not use it for a variable name. Therefore, by writing e.g.:

(M1⊗II + II⊗M2)^2 // Expand


you get: However, to get your expected result, you assume some properties that you did not declare.