# 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.

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$$
By polynomial division, we see that \begin{align} x^{10}-3x^9-x^2+4x = (x^4-3x^3+x^2-3x)(x^6-x^4+x^2+1)+x \end{align} which means \begin{align} A^{10}-3A^9-A^2+4A = (A^4-3A^3+A^2-3A)(A^6-A^4+A^2+1)+A = A. \end{align}
We know that $$A^4-3A^3=3A-A^2$$. Now, \begin{align*} B&=A^{10}-3A^9-A^2+4A\\ &=A^6(A^4-3A^3)-A^2+4A\\ &=A^6(3A-A^2)-A^2+4A\\ &=3A^7-A^8-A^2+4A\\ &=-A^4(A^4-3A^3)-A^2+4A\\ &=-A^4(3A-A^2)-A^2+4A\\ &=-3A^5+A^6-A^2+4A\\ &=A^2(A^4-3A^3)-A^2+4A\\ &=A^2(3A-A^2)-A^2+4A\\ &=-A^4+3A^3-A^2+4A\\ &=A \end{align*}