<s>[INST] Calculate matrix by using Cayley-Hamilton theorem Calculate matrix $B = A^{10}-3A^9-A^2+4A$ using Cayley-Hamilton theorem on $A$.
$$A = \begin{pmatrix}
  2 & 2 & 2 & 5 \\
  -1 & -1 & -1 & -5 \\
  -2 & -2 & -1 & 0 \\
  1 & 1 & 3 & 3
 \end{pmatrix}$$
Now, I've calculated the characteristic polynomial of $A$:
$P_A(\lambda) = \lambda^4-3\lambda^3+\lambda^2-3\lambda$
So I know that $P(A) = 0 \rightarrow A^4-3A^3+A^2-3A = 0$, hereby $0$ is a $4 \times 4$ matrix.
$B = A^{10}-3A^9-A^2+4A = A^4 \cdot A^6 - 3A^3 \cdot A^6 + A^2 \cdot (-1) -3A + 7A $
Can I go further from here?
I tried doing polynomial division $B/P(A)$, but i stopped halfway since the numbers were getting too big and it didn't seem to get me to the right solution.
How do I transform $B$, so that I can use $P(A)=0$ and calculate B.
 [/INST] Hint: Since $A^4-3A^3=-(A^2-3A)$
$A^{10}-3A^9=A^6(A^4-3A^3)=-A^6(A^2-3A)=-A^4(A^4-3A^3)=A^4(A^2-3A)=A^2(A^4-3A^2)=-A^2(A^2-3A)=-(A^4-3A^2)=A^2-3A$
</s>