# Question: Expansion of algebra in matrices

I have a problem that I would like to check:

Expand $(A+B)^3$ where $A$ and $B$ are matrices.

Is this right? $$A^3+A^2B+ABA+AB^2+BA^2+BAB+B^2A+B^3$$ Thanks.

-

It is probably easiest to start off with $$(A+B)^2=A(A+B)+B(A+B)=A^2+AB+BA+B^2.$$ From here, we find $$(A+B)^3=(A+B)(A^2+AB+BA+B^2)=A^3+A^2B+ABA+AB^2+BA^2+BAB+B^2A+B^3,$$ as you claimed.