Using exponents when working with matrices I was working on the following problem when I stumbled upon an oddity.
If $X=P^{-1}AP$ and $A^3=I$, prove that $X^3=I$
My first approach was to cube both side which led to the following: 
$$X^3=(P^{-1}AP)^3$$
$$X^3=(P^{-1})^3A^3P^3$$
Since $A^3=I$
$$X^3=(P^{-1})^3I^3P^3$$
$$X^3=(P^{-1})^3P^3$$
$$X^3=(P^{-1}P)^3$$
$$X=I^3=I$$
However this method seemed to contradict what I had previously learned. Instead I tried this approach:
$$X=P^{-1}AP$$
Now premultiply each side by X and we get: $$X^2=P^{-1}APP^{-1}AP=P^{-1}AIAP=P^{-1}A^2P$$
We do this once more: $$X^3=P^{-1}A^2PP^{-1}AP=P^{-1}A^2IAP=P^{-1}A^3P$$
Since $A^3=I$ $$X^3=P^{-1}IP=P^{-1}P=I$$
Does anyone know which approach is correct?
 A: It is false in general that $(ABC)^3 = A^3B^3C^3$. This only holds if the elements commute. So you cannot go from
$$(P^{-1}AP)^3$$
to
$$(P^{-1})^3 A^3 P^3$$
in general, since the equality will not hold if $A$ does not commute with $P$.
Fortunately, in general we have that
$$(P^{-1}AP)^n = P^{-1}A^nP$$
is true for all positive integers $n$ (and even for negative ones, if $A$ is invertible). This can be shown by induction on $n$ for positive integers: it is true for $n=1$, since $P^{-1}AP = P^{-1}AP$. Assuming the result is true for $n$, we have
$$\begin{align*}
(P^{-1}AP)^{n+1} &= (P^{-1}AP)^n(P^{-1}AP)\\
&= (P^{-1}A^nP)(P^{-1}AP)\\
&= P^{-1}A^n(PP^{-1})AP\\
&= P^{-1}A^nAP\\
&= P^{-1}A^{n+1}P
\end{align*}$$
One can also see this by verify that the map $B\mapsto P^{-1}BP$ is actually a semigroup homomorphism on the multiplicative semigroup of matrices: for any $B$ and $C$, we have that
$$P^{-1}(BC)P = (P^{-1}BP)(P^{-1}CP),$$
as can easily be verified. In fact, it's a ring homomorphism, since
$$P{-1}(B+C)P = (P^{-1}BP) + (P^{-1}CP),$$
so conjugation behaves pretty well. But you cannot do what you did first.
A: The second approach is correct.
The identity $(AB)^n=A^nB^n$ holds if $AB=BA$, but not typically otherwise.  It coincidentally works out in this case that assuming $(ABC)^3=A^3B^3C^3$ leads to the same answer.  In general, $(P^{-1}AP)^n=P^{-1}A^nP$, not $(P^{-1})^nA^nP^n$.

I want to add a further note on the importance of commutativity and distinguishing between $(AB)^n$ versus $A^nB^n$.  Namely, if $A$ and $B$ are invertible, then $(AB)^2=A^2B^2$ if and only if $AB=BA$.  
In one direction, if $AB=BA$, then $(AB)^2=ABAB=A(BA)B=A(AB)B=A^2B^2$.  In the other direction, if $(AB)^2=A^2B^2$, then we have:
$\begin{align*}
ABAB&=AABB\\
A^{-1}(ABAB)B^{-1}&=A^{-1}(AABB)B^{-1}\\
IBAI&=IABI\\
BA&=AB.
\end{align*}$
It is important that $A$ and $B$ are invertible, not just to make the preceding proof work, but because it is possible for $(AB)^2=A^2B^2$ to hold when $A$ and $B$ do not commute.  An example of this is given by $A=\begin{bmatrix}0&1\\0&1\end{bmatrix}$ and $B=\begin{bmatrix}1&1\\0&0\end{bmatrix}$. But such cases are atypical, and in the absence of commutativity, for each $n>1$, $(AB)^n=ABABAB\cdots AB$ and $A^nB^n=AAA\cdots ABBB\cdots B$ cannot be considered equal unless proven so.
