I am trying to obtain a power series expansion in some real parameter, but all the terms are arbitrary products of tensors. I.e. I want to expand an expression containing sums/products/powers of this parameter (say a) and arbitrary sums/products/powers of tensors as much as possible. For example
a((MatrixPower[X.Y + Y.X, 2] + a X.Y.Y.X))
should give
a(X.Y.X.Y + X.Y.Y.X + Y.X.X.Y + Y.X.Y.X) + a^2 X.Y.Y.X
After trying combinations of TensorExpand, TensorReduce, Distribute, Collect, Refine, Replace, .. I'm lost. For example I get a term like
$Assumptions = a \[Element] Reals && A1 \[Element] Matrices[{4, 4}] && A2 \[Element] Matrices[{4, 4}] && A3 \[Element] Matrices[{4, 4}] && A4 \[Element] Matrices[{4, 4}];
a^3 (A1.A2/2 + A1.A3/2 - A2.A1/2 + A2.A3/2 - A3.A1/2 - A3.A2/2
+ 1/12 A3.(a A1 + a A2 + 1/2 a^2 (A1.A2 - A2.A1) + 1/12 a^3 (A1.A1.A2
- 2 A1.A2.A1 + A2.A1.A1) + 1/12 a^3 (A1.A2.A2 - 2 A2.A1.A2 + A2.A2.A1)).
(a A1 + a A2 + 1/2 a^2 (A1.A2 - A2.A1) + 1/12 a^3 (A1.A1.A2 - 2 A1.A2.A1
+ A2.A1.A1) + 1/12 a^3 (A1.A2.A2 - 2 A2.A1.A2 + A2.A2.A1)))
after Collect, which is obviously not only a^3, but also a^4, a^5, a^6. I cannot get this into a form like
a^3(...) + a^4(...) + a^5(...) + a^6(...)
TensorExpand / TensorReduce do not do what I want because they write MatrixProduct[.., ..] whenever possible which still contains factors of a inside and then cannot be properly used for Collect. Distribute also works only in the simplest cases.
Is it somehow possible to do what I want?