If I have matrices A, B, and C so that C = A * B, how can I get A from B and C?
This page ( http://mathworld.wolfram.com/MatrixInverse.html ) tells me that A sould be C*B^-1, but using python and numpy it seems it's not true.
If I have matrices A, B, and C so that C = A * B, how can I get A from B and C?
This page ( http://mathworld.wolfram.com/MatrixInverse.html ) tells me that A sould be C*B^-1, but using python and numpy it seems it's not true.
Assuming $B$ is invertible, let $B^{-1}$ denote the matrix inverse. Then, $CB^{-1}=A$.
Another answer has already provided the solution, but here is a demonstration of why it works because OP's initial thought was that this does not work.
Let $A, B, C \in \mathbb{M}_{2\times2}(\mathbb{R})$ such that $A\times{B}=C$. If $B$ is invertible; that is, $B^{-1}$ exists, then the following applies:
$A\times{B}=C$
$A\times{B}\times{B^{-1}}=C\times{B^{-1}}$ (multiply both sides on the right by $B^{-1}$)
$A\times{I}=C\times{B^{-1}}$ ($B\times{B^{-1}}=I$ by definition)
$A=C\times{B^{-1}}$ ($AI=IA=A$ by definition)
Thus, if and only if $B$ is invertible, this is the method to find one of the factors of a matrix given the other factor.
The same goes for $A\times{B}=C$ -> $B=A^{-1}\times{C}$ (note that here the inverse is written on the left side because matrix multiplication is not commutative).
np.linalg.solve(B.T, C.T).T, but if you didB**-1, you took the reciprocal of each element ofB, which isn't what you want. – user2357112 Jun 15 '14 at 04:02