1 Answer
1

Even ExpandAll[] won't separate the $"2 xy"$ into $"xy+yx"$. And this makes sense; what should it make of $"3xy"$? $"xy + yx + xy"$, or $"xy + yx +yx"$? And what about $"10 xy"$ (I don't want to think about $"10000 xy"$)?

J.M.'s solution

Distribute[(x + y) ** (x + y)] /. t_ ** t_ :> t^2

will give you the $2 x y$ as separate terms, but has to use the symbol for non-commutative multiplication (for example, x and y may be operators):

$ x^2 + y^2 + x ** y + y** x $

and Mathematica won't interpret it as commutative multiplication. Replacing x and y with numerical values

Mathematica is a registered trademark of Wolfram Research, Inc. While the mark is used herein with the limited permission of Wolfram Research, Stack Exchange and this site disclaim all affiliation therewith.