In this simple example, I have 2 lists, each of which contains 3 matrices。 $J$ here is also a matrix with the same dimension. What I want is $aJc+bJ(b+c)$, but if I use dot product, the result is as follows,
x = {a, b, b}; y = {c, b, c};
Sum[x[[i]] .J. y[[i]], {i, 1, 3}] // FullSimplify
(* return is a.J.c + b.J.b + b.J.c *)
When I use multiplication, then Mathematica goes too far:
x = {a, b, b}; y = {c, b, c};
Sum[x[[i]] *J* y[[i]], {i, 1, 3}] // FullSimplify
(* return is (b^2 + (a + b) c) J*)
So how to get what I want ?
Rule
s, maybe:Inner[#1.J.#2 &, x, y] /. Dot[x_, y_, z1_] + Dot[x_, y_, z2_] :> Dot[x, y, z1 + z2]
$\endgroup$