TITLE: If 2x2 real matrices $A$, $B$ and $A-B$ are all idempotent, does this imply $AB=BA$?
QUESTION [5 upvotes]: I am not sure if this is true. If $2 \times 2$ real matrices $A$, $B$ and $A-B$ are all idempotent, does this imply $AB=BA$?   I can't yet complete the proof nor find a counter example.

REPLY [7 votes]: Yes. Suppose $A$, $B$, and $A-B$ are idempotent. Then
$$A-B=(A-B)^2=A-AB-BA+B,$$ so $AB+BA=2B$, or $(A-1)B+B(A-1)=0$. 
Let $X=A-1$. Then we have that $XB=-BX$. 
Thus 
$$ XB = -BX = -BBX = BXB = -XBB = -XB = BX, $$
so $X$ and $B$ commute. I.e., $(A-1)B=B(A-1)$, or $AB-B=BA-B$. Thus $AB=BA$.
Side note
Note that $XB=-XB$, which implies that $XB=BX=0$, so in fact we have that $AB=BA=B$.