# Matrix multiplication: is C(AB) the same as (CA)B?

I would like to show that $(\mathbf{A} \mathbf{B})^{-1} = \mathbf{B}^{-1} \mathbf{A}^{-1}$, where $\mathbf{A}$ and $\mathbf{B}$ are $N \times N$ square matrices.

I think that this can be done as follows:

First, note that $(\mathbf{A}\mathbf{B})^{-1} (\mathbf{A} \mathbf{B}) = \mathbf{1}$ and also that $\mathbf{B}^{-1} \mathbf{A}^{-1} \mathbf{A} \mathbf{B} = \mathbf{B}^{-1} \mathbf{1} \mathbf{B} = \mathbf{B}^{-1} \mathbf{B} = \mathbf{1}$ (where $\mathbf{1}$ is the unit matrix). Thus

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

which implies that

$(\mathbf{A} \mathbf{B})^{-1} = \mathbf{B}^{-1} \mathbf{A}^{-1}$.

I am not sure that this is correct. It seems almost too easy! The correctness of my working is based on my assumption that $\mathbf{C} (\mathbf{A}\mathbf{B}) = (\mathbf{C} \mathbf{A}) \mathbf{B}$. Is this correct?

In normal linear algebra, this is the case. But is it the case in matrix multiplication? I am not sure whether the brackets result in a different order of multiplication and thus a different result.

-
That is not commutativity property but associativity you try to set straight. You can switch to index representation of matrices to see it for yourself i.e. $A_{ij},B_{ij},C_{ij}$ – user13838 Oct 11 '11 at 9:30
As @joriki pointed out in his answer, your reasoning is correct. However, I think you could work on writing mathematics better. $$\text{}(\mathbf{AB})^{−1}(\mathbf{AB})=\mathbf{1}\text{''}$$ Why write this first? Without any explanation it's just superfluous and only serves to make the reader think that the next line follows from this. – kahen Oct 11 '11 at 9:49
Your assumption that "$\mathbf{C} (\mathbf{A}\mathbf{B}) = \mathbf{C} (\mathbf{A} \mathbf{B})$" is correct, but not very substantial. I think you meant to put the brackets differently. ;-) – Hans Lundmark Oct 11 '11 at 10:21
@HansLundmark Yes, I have corrected that error now. – James Womack Oct 11 '11 at 10:23

Your reasoning is correct. However, it doesn't really make sense to ask whether $\mathbf C(\mathbf A\mathbf B)=\mathbf C\mathbf A\mathbf B$, since the right-hand side isn't defined unless either you already know that multiplication is associative or you've specified an order of evaluation (which is usual in programming languages but not in mathematics). The appropriate question is whether $\mathbf C(\mathbf A\mathbf B)=(\mathbf C\mathbf A)\mathbf B$, which is what you have in fact used in your derivation. This is called associativity; it holds for matrices; and it allows you to write $\mathbf C\mathbf A\mathbf B$ for either of the products.

-
Thank you for your clear answer. – James Womack Oct 11 '11 at 10:13
I've edited my question in line with your suggestions. – James Womack Oct 12 '11 at 9:12

As mentioned in the comments on my question, it is possible to demonstrate to yourself the property of associativity by switching to the index representation of matrices. I did this to verify to myself what was said above.

To show that $\mathbf{C}(\mathbf{A}\mathbf{B}) = (\mathbf{C} \mathbf{A}) \mathbf{B}$, note that

$(\mathbf{C}(\mathbf{A}\mathbf{B}))_{ij} = \sum_{l} C_{il}(\mathbf{A}\mathbf{B})_{lj} = \sum_{l}\sum_{k} C_{il}A_{lk}B_{kj}$

and similarly

$((\mathbf{C}\mathbf{A})\mathbf{B})_{ij} = \sum_{l} (\mathbf{C}\mathbf{A})_{il} B_{lj} = \sum_{l}\sum_{k} C_{ik}A_{kl}B_{lj}$.

Both double summations can be seen to run over the same range of terms, and so we can see that the matrix elements $(\mathbf{C}(\mathbf{A}\mathbf{B}))_{ij}$ and $((\mathbf{C}\mathbf{A})\mathbf{B})_{ij}$ are the same and thus $\mathbf{C}(\mathbf{A}\mathbf{B}) = (\mathbf{C} \mathbf{A}) \mathbf{B}$.

-
+1 for taking good advice to heart and working out the problem. Succinctly, associativity in the underlying field (e.g. $\mathbb{R}$) guarantees associativity of matrix multiplication: $$(a_{ij}b_{jk})c_{kl}=a_{ij}(b_{jk}c_{kl})\implies (AB)C=A(BC).$$ – anon Oct 12 '11 at 9:21

Another way to see that matrix multiplication is associative is to view it as function composition.

Since $((f\circ g) \circ h) (x)=(f\circ g) (h (x))=f(g(h (x)))= f ((g \circ h)(x))=(f\circ (g \circ h)) (x)$ and two functions are identical if they agree on all arguments, composition is always associative.

-