What is the correct order when multiplying both sides of an equation by matrix inverses?

So my questions is let's say you were asked to solve for $A$, and you have something like this:

$$BAC=D$$ where B, C , and D are matrices. So the way I would solve this would be to multiply both sides by $B^{-1}$ and $C^{-1}$ (inverse of B and C), but since the order in the multiplication matters $A = DB^{-1}C^{-1}$ would be different than say $A = B^{-1}DC^{-1}$. My question (maybe stupid or I am just missing something) is how do you know which order is the correct one?


You must be sure to multiply on the correct side. To get rid of the $B$ in $BAC$, you must multiply on the left by $B^{-1}$, so you must do the same on the righthand side of the equation:

$$AC=B^{-1}BAC=B^{-1}D\;.$$

To get rid of the $C$ in $AC$, you must multiply $AC$ on the right by $C^{-1}$, so you must do the same thing on the other side of the equation:

$$A=ACC^{-1}=B^{-1}DC^{-1}\;.$$


You have to multiply $C^{-1}$ from the right ( on both sides) and $B^{-1}$ from the left ( on both sides). Which one you do first doesn't matter.