# When is AXB equal to BXA in the case of square matrices?

My question is motivated by the inverse of $A^{-1}+B^{-1}$.

$$A^{-1}+B^{-1}=A^{-1}(A+B)B^{-1}\implies(A^{-1}+B^{-1})^{-1}=B(A+B)^{-1}A$$

$$A^{-1}+B^{-1}=B^{-1}+A^{-1}=B^{-1}(A+B)A^{-1}\implies(A^{-1}+B^{-1})^{-1}=A(A+B)^{-1}B$$

$$B(A+B)^{-1}A=A(A+B)^{-1}B$$

Is this a special result due to the fact that $(A+B)^{-1}$ is sandwiched between $A$ and $B$, or does it hold for other cases as well, i.e. $AXB=BXA$ where $X$ has some special properties?

If it's the former, then some intuition for why it holds beyond the math mechanics that I have shown above would be appreciated.

• I'm not sure if I'd call it a duplicate, but related: math.stackexchange.com/questions/2852002/… – Theo Bendit Jul 16 '18 at 9:23
• Thanks for pointing that particular thread out. Searching in stackexchange isn't particularly great, else I would have probably left the above as a comment on the top answer on that thread. The second part of my question is to figure out all $X$ values for which this is true. This was not answered on that thread. I'm happy to merge this with the other question if needed though. – Amrit Prasad Jul 16 '18 at 9:45