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.
 A: 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}$.
A: 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.
A: 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.
