TITLE: Proving two matrices are equal
QUESTION [5 upvotes]: A friend and I are having some trouble with a linear algebra problem:
Let $A$ and $B$ be square matrices with dimensions $n\times n$
Prove or disprove:
If $A^2=B^2$ then $A=B$ or $A=-B$
It seems to be true but the rest of my class insists it's false - I can't find an example where this isn't the case - can someone shed some light on this?
Thanks!

REPLY [4 votes]: All matrices $E_{ij}$  of the standard basis of $M_n(\mathbf R)$, defined with 
$$ a_{kl}=\begin{cases}
1&\text{if }(k,l)=(i,j)\\
0&\text{if }(k,l)\neq(i,j)
\end{cases}$$
satisfy the equation $\;E_{ij}^2=0$ if $i\neq j$.