Q. If $A$ and $B$ are two matrices such that $A B=B$ and $B A=A$, then $A^{2}+B^{2}=$

Solution:

$A^{2}+B^{2}=A A+B B=A(B A)+B(A B)=(A B) A+(B A) B=B A+A B=A+B$