How to diagonalize a matrix $A$ and then compute $A^{10}$? 
Diagonalize the following matrix $$A = \begin{bmatrix} -2 & -8 & -12\\ 1 & 4 & 4\\ 0 & 0 & 1\end{bmatrix}$$ and compute $A^{10}$.


I have found that the eigenvalues of $A$ are $\lambda _1 = 0$, $\lambda _2 = 1$, $\lambda _1 = 2$. Then, I found the following eigenvectors who form my matrix $P$.
$$v_1=\left (\begin{matrix}1\\ 1\\ 1\end{matrix}  \right ), \qquad  v_2=\left (\begin{matrix}-1/4\\ 0\\ -1/2\end{matrix}  \right ), \qquad v_3=\left (\begin{matrix}0\\ -1/4\\ 0\end{matrix}  \right )$$
At the end my matrix
$$P=\left ( \begin{matrix}
1 & 1 &1 \\ 
 -\frac{1}{4}& 0 &-\frac{1}{2} \\ 
0 &-\frac{1}{4}  & 0
\end{matrix} \right )$$
In linear algebra, two $n$-by-$n$ matrices $A$ and $B$ are called similar if $B=P^{-1}AP$. I get that
$$B=\left ( \begin{matrix}
0 & 0 & 0\\ 
0 &1  &0 \\ 
 0& 0 & 2
\end{matrix} \right )$$
So is this all good? How can I use that to get value of $A^{10}$?

We have $x^{10} \equiv 511 x^2 - 510 x \bmod x(x-1)(x-2)$ and so $A^{10} = 511 A^2 - 510 A$ by the Cayley–Hamilton theorem.
