$A,B$ are two $n \times n$ matrices. Prove that $(AB)^2 = A^2B^2$ if $AB=BA$.
We have $(AB)_{ij} = \displaystyle\sum_{k=1}^n A_{ik}B_{kj}$, so $(AB)^2_{ij} = \displaystyle\sum_{k=1}^n (AB)_{ik}(AB)_{kj}$.
$(A^2B^2)_{ij} = \displaystyle\sum_{k=1}^n A^2_{ik}B^2_{kj}$
I'm kind of stuck here, I don't know how to further develop this into something fruitful.
$\endgroup$ 21 Answer
$\begingroup$Doing things element-by-element is a pain, and I personally consider it a last-resort technique.
As others pointed out in comments, this holds:
$$(AB)^2=(AB)(AB)=ABAB=A(BA)B=A(AB)B=AABB=A^2B^2$$
Where I used parentheses to hopefully make clear when I used the hypothesis $AB=BA$.
$\endgroup$