An eigenvector of M\mathbf MM keeps its direction: Mv=λv\mathbf M\mathbf v=\lambda\mathbf vMv=λv, where λ\lambdaλ is the eigenvalue. Eigenvalues solve det(M−λI)=0\det(\mathbf M-\lambda\mathbf I)=0det(M−λI)=0. Putting eigenvectors in P\mathbf PP and eigenvalues in D\mathbf DD gives M=PDP−1\mathbf M=\mathbf{PDP}^{-1}M=PDP−1, so Mn=PDnP−1\mathbf M^n=\mathbf{PD}^n\mathbf P^{-1}Mn=PDnP−1.