I have this confusion related to matrix inverse. Lets say I have this equation
$AX=B$,
Then is it $X=A^{-1}B$ or $X=BA^{-1}$.
When I say A/B is it $A^{-1}B$ or $BA^{-1}$.
I have this confusion related to matrix inverse. Lets say I have this equation
$AX=B$,
Then is it $X=A^{-1}B$ or $X=BA^{-1}$.
When I say A/B is it $A^{-1}B$ or $BA^{-1}$.
Matrix multiplication is not in general commutative, so you have to pay attention to the order of the factors when you multiply. To solve the equation $AX=B$, you want to get rid of the $A$ by multiplying it by its inverse, so you have to multiply on the left: $A^{-1}(AX)=(A^{-1}A)X=IX=X$. As usual, you must do exactly the same thing to the other side of the equation, so you end up with $X=A^{-1}B$, not $X=BA^{-1}$.
You should not say $B/A$ at all: division of matrices is undefined, so that combination of symbols is meaningless.
You multiply by $A^{-1}$ to cancel the $A$. So, to cancel $A$ from $AX$, you need to multiply by $A^{-1}$ on the left side...
Your solution is basically the following:
$AX=B \Rightarrow A^{-1}AX=A^{-1}B \Rightarrow X= A^{-1}B $
Similarly, if you solve $XA=B$, to cancel $A$ you need to multiply to the right, thus in that case, $X=BA^{-1}$.
In Matlab, if your matrix is not square and you ask it to do division with it, it uses the least squares solution. That solution matrix will be of dimension of the transpose. So for example if your matrix is 4x3, dividing gives a 3x4 matrix.