Solution (source code)

= Solution

Over the chosen scalar field, an $n$-by-$n$ <matrix> is <diagonalizable> if and only if it has $n$ <linearly independent> <eigenvectors>. Repeated eigenvalues are allowed provided all <eigenspaces> together supply a basis.

For the given matrix, the <characteristic polynomial> is $\lambda^2-4\lambda-5=(\lambda-5)(\lambda+1)$. One may choose
$$
\boxed{\lambda_1=5,\quad V_1=\begin{pmatrix}5\\1\end{pmatrix},\qquad\lambda_2=-1,\quad V_2=\begin{pmatrix}-1\\1\end{pmatrix}.}
$$
Taking these as columns gives the <change of basis>
$$
\boxed{P=\begin{pmatrix}5&-1\\1&1\end{pmatrix},\qquad P^{-1}=\frac16\begin{pmatrix}1&1\\-1&5\end{pmatrix},\qquad P^{-1}AP=\begin{pmatrix}5&0\\0&-1\end{pmatrix}.}
$$
\b[This is not a rotation matrix.] The PDF's terminology cannot hold literally: $A$ is real and nonsymmetric, whereas a real matrix orthogonally similar to a real diagonal matrix is symmetric. Also $V_1\cdot V_2=-4\ne0$, so scaling these eigenvectors cannot make an orthonormal rotation basis. A general invertible similarity is the valid construction.

Let $D=P^{-1}AP$. Inserting $PP^{-1}$ between successive factors gives $A^n=PD^nP^{-1}$, and hence
$$
\boxed{P^{-1}A^nP=\operatorname{diag}(5^n,(-1)^n).}
$$
To write $A^n=\alpha_nA+\beta_nI$, match its action on the two eigenspaces:
$$
5\alpha_n+\beta_n=5^n,\qquad-\alpha_n+\beta_n=(-1)^n.
$$
Solving gives the <matrix powers for a diagonalizable matrix with two eigenvalues>
$$
\boxed{A^n=\frac{5^n+(-1)^{n+1}}6A+\frac{5^n+5(-1)^n}6I,\qquad n\geq0.}
$$
The cases $n=0,1$ recover $I,A$, respectively. Equivalently the <spectral projections of a diagonalizable matrix> are $(A+I)/6$ and $(5I-A)/6$, and the power multiplies them by $5^n$ and $(-1)^n$.