Why can matrix exponentiation be done by squaring?

Matrix multiplication is not communative:
A*B != B*A
Then why can matrix exponentiation be done by squaring?

I have tried searching for special cases where this rule did not apply, but from what I've understood, none of it seemed to apply specifically to powers of two equal matrices.

For example a matrix M is raised to a 12, then which of the following is true?
M4 * M8 = M12 OR M8 * M4 = M12 ?

Do we need to follow a particular order while calculating matrix exponentiation by squaring ? If yes then how is the order determined and why does it lead to the correct exponentiation. If not then why doesn't the fact that matrix multiplication is not communative does not affect it?

Can this be explained this to me in plain english? Thanks in advance.

When squaring a matrix, the "order" in which you multiply them doesn't matter since every matrix commutes with itself. Using your example of $M^{12}$, it doesn't matter if we do $$M^{12} = M^{4}M^{8}$$ or $$M^{12} = M^8M^4$$ or any other way of grouping powers of $M$ which add up to $12$.

Edit: For cases when the exponent is greater than $2$, consider $M^4$ (higher powers will generalize this in a simple way). We can say $$M^4 = M\cdot M \cdot M \cdot M.$$ Now, matrix multiplication is associative, so we can group this in any way we want. Then we have $$M^4 = M\cdot M \cdot M \cdot M = (M^2) \cdot (M^2) = M\cdot (M^3) = (M^3) \cdot M.$$ The key here is that the associative property of matrix multiplication lets us choose any grouping of the matrices that we'd like.

• I don't understand why it doesn't matter when the exponent is > 2, clearly M^8 and M^4 are two different matrices. – 2147483647 Jan 21 '14 at 15:34
• @A.06 I've edited my post to add more detail. – yoknapatawpha Jan 21 '14 at 15:36
• For any matrix $M$ which is diagonalisable, we have $M^i$ and $M^j$, $i\in\mathbb{N}^+$, as simultaneously diagonalisable. Thus $M^i$ and $M^j$ commute. – David Simmons Jan 21 '14 at 15:40

Suppose $A$ is a square matrix and let $B = A$ (So we have two different names for the same thing). Then $AB = AA$, by substituting $B$ by $A$. Using the same process, we also have $AA = BA$. Thus, $AB = BA$ if $A=B$.

Next, the problem you have with $M^{12}$ has nothing to do with commutativity. You can regard it as a problem of associativity. Since matrix multiplication is associative, you have

$$M^{12} = \left(M^{4}M^{4}\right)M^{4} = M^{4}\left(M^{4}M^{4}\right)$$ and therefore $$M^{12} = \left(M^{8}\right)M^{4} = M^{4}\left(M^{8}\right)$$

For any matrix $M$ which is diagonalisable, we have $M^i$ and $M^j$, $i,j\in\mathbb{N}^+$, as simultaneously diagonalisable. Thus $M^i$ and $M^j$ commute.