# Expanding tensors

This is a follow-up on / clarification of this thread.

I have the following in a notebook:

\$Assumptions = A ∈ Matrices[{3,3},Reals] && B ∈ Matrices[{3,3},Reals]
TensorExpand[(A+B).(A+B)]

(* MatrixPower[A + B, 2] *)


Apparently, TensorExpand does not expand the dot product if the two arguments of the dot product are equal. Is there any way I can expand these kinds of dot products of tensors in Mathematica, i.e. to get A.A + A.B + B.A + B.B in the above example?

• Please always post copyable code, not just screenshots. – Szabolcs Oct 16 '17 at 12:10
• You could try Distribute. – Szabolcs Oct 16 '17 at 12:13
• I'm not sure if MatrixPower works out of the box with Tensors. You could try building your own version, where you can build Dot in terms of TensorProduct and TensorContract as shown here in section Properties&Relations (search for: "TensorProduct, in combination with TensorContract, can be used to implement Dot:") – Thies Heidecke Oct 16 '17 at 12:19
• Added the copyable code. :) – arriopolis Oct 16 '17 at 12:32

For this specific case, Distribute will work.
Distribute[(A + B).(A + B)]

Keep in mind that Distribute is a purely structural operation without any mathematical smarts.