1

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.

riba1122
  • 23
  • 1
  • 1
  • 4
  • 2
    If $B$ is invertible, this is true. If not, then it's not the case. What examples were you doing in Numpy? – Cameron Williams Jun 15 '14 at 03:56
  • 4
    Did you compute the matrix inverse of $B$ or merely take the reciprocal of each element in $B$? The first one is what you are supposed to do (assuming $B$ is invertible). – JimmyK4542 Jun 15 '14 at 03:58
  • 2
    Really, what you're supposed to do is something like np.linalg.solve(B.T, C.T).T, but if you did B**-1, you took the reciprocal of each element of B, which isn't what you want. – user2357112 Jun 15 '14 at 04:02
  • 2
    It seems I misinterpreted the function numpy.invert. I should have used numpy.linalg.inv. Thanks for pointing me to the solution – riba1122 Jun 15 '14 at 04:09

2 Answers2

2

Assuming $B$ is invertible, let $B^{-1}$ denote the matrix inverse. Then, $CB^{-1}=A$.

1

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).