Show that $A=B$, provided that $A^2=B^2$ (and some other conditions are satisfied) I'm trying to do this question from an old past paper, no answers to look at and because it's from a previous year I'm not entirely sure I've even covered the material; here it is:

Let $A,B\in M_n(\mathbb R)$ be such that $A^2 = B^2,\, AB = BA$ and $\det(A + B) \ne 0$. Show that $A = B$.

I've been playing around with it for ages but can't get anything, from the determinant part I'm guessing I have to involve the extant inverse of $A+B$ but I've never done that before and from looking it up it seems abit beyond what I should be doing. Any ideas?
 A: Hint: Expand and simplify $(A-B)(A+B) = A^2 + AB - BA - B^2 = \cdots$
If you can show that $(A-B)(A+B) = 0$, then you can multiply both sides by $(A+B)^{-1}$. (The inverse of $A+B$ exists since $\det(A+B) \neq 0$.)
A: Here's a direct proof:
\begin{align*}
A&=(A+B)^{-1}(A+B)A\\
&=(A+B)^{-1}(A^2+BA)\\
&=(A+B)^{-1}(B^2+AB)\\
&=(A+B)^{-1}(A+B)B=B
\end{align*}
A: When $n=1$, this is immediate since $A$ and $B$ are nothing but real numbers:
$$
0=A^2-B^2=(A+B)(A-B)\tag{1}
$$
and $\det(A+B)\neq 0$ means $A+B\neq 0$ which allows one to cancel the $A+B$ term. 
For $n>1$, (1) is no true in general since matrices do not necessarily commute. But in this particular problem, one has $AB=BA$.
A: we have ,  $\det(A+B)\neq0 \implies (A+B)$ is non-singular matrix.
Now, 
$(A+B)(A-B)=A^2-AB+BA-B^2=A^2-B^2=O$  ( since, $AB=BA$ and $A^2=B^2 $ )
you should know that ,

If the product of two matrices is null , then either both will be
  singular or one of them must be null itself.

Therefore $A-B=O\implies A=B$ .
Hope it may helpful!
