# Matrix P to the power of 4, i.e $P^4$, is this the same as $P^2 \cdot P^2$?

Basically, what it says in the title.

I have a $5 \times 5$ matrix and I need to work out $P^4$, is it possible to just do $P^2$ and multiply this with itself?

-
This is the simplest case of binary "fast" exponentiation. For larger exponents than 4 there may be "chains" of multiplication (addition of exponents) that improve on the naive binary expansion. For more discussion see Algorithm for calculating $A^n$ with as few multiplications as possible. – hardmath Dec 14 '12 at 14:59
Yes.${}{}{}{}{}$ – Graphth Dec 15 '12 at 15:05

$P^4=P^2\times P^2$ for a matrix $P$. Multiplication of matrices is associative, so you can do that.

-
So I can do $P^2 \cdot P^2$? As $P^2$ is the same, it doesn't matter which way round it goes does it. – Kaish Dec 14 '12 at 14:48
Even if matrix multiplication was not associative the result still holds – Belgi Dec 14 '12 at 14:54
@Belgi Why? Note that if the multiplication was not associative, $A^4$ would be an abuse of notation. It could mean $((AA)A)A$ and also $(A(AA))A$ and $(AA)(AA)$ and $A(A(AA))$ and $A((AA)A)$.... Usually $A^n$ is defined as $A^{n-1}A$ so $A^4$ usually means $((AA)A)A$. Why is that the same as $(AA)(AA)$? – N. S. Dec 14 '12 at 15:02
@N.S. thanks for the note about the notation! – Belgi Dec 14 '12 at 15:31
@Belgi: Although associativity makes up for the lack of commutativity generally (in implying powers are well-defined & commute $P^a\cdot P^b=P^b\cdot P^a$), here's an example to show we need something like associativity. Consider a binary operation on $\{p,q\}$ where $p\cdot p=q\cdot p = q$ and $p\cdot q=q\cdot q = p$. Then $(p\cdot p)\cdot (p\cdot p) = q\cdot q = p$ but $((p\cdot p)\cdot p)\cdot p= q$. – hardmath Dec 14 '12 at 16:03

I have a $5 \times 5$ matrix and I need to work out $P^4$, is it possible to just do $P^2$ and multiply this with itself?

Yes, Why?: Because A square matrix always commutes with itself, under matrix multiplication.

$\quad\;\;$WHY? Because matrix multiplication (when well-defined) is associative. $$P\cdot (P \cdot (P\cdot P)) = P\cdot ((P \cdot P)\cdot P) = (P\cdot (P\cdot P)) \cdot P$$ $$= ((P\cdot P) \cdot P) \cdot P = (P\cdot P) \cdot (P \cdot P) = P^2\cdot P^2 = P^4.$$

But be careful.
Generally speaking, for square matrices $A, B$ such that $P = AB$, $$P^4 = (AB)^4 = (AB)^2\cdot (AB)^2 \ne A^2 \cdot A^2\cdot B^2 \cdot B^2 = A^4\cdot B^4$$ since here, we cannot assume that $A$ and $B$ commute.

-

What does $P^4$ mean to you? It might mean $$P\cdot P\cdot P\cdot P$$ but this is not exactly defined until you agree that matrix multiplication is asociative. Otherwise $P^4$ should mean something like $$((P\cdot P)\cdot P)\cdot P$$ Now if you believe that the multiplication is associative, then this is the same as $$(P\cdot P)\cdot (P\cdot P)$$ which is almost certainly what you would mean by $P^2\cdot P^2$.

-