# How exactly do you calculate matrix $f(A)$ when $A$ is a matrix, $f$ a polynomial?

Let's say $$f \in \mathbb{Q}[X]$$ and $$A \in \mathbb{Q}^{2 \times 2}$$. Now let $$f$$ be $$f = X^3+2X^2+3X+4$$ and $$A$$ be $$A = \begin{pmatrix} 1 & -1 \\ 2 & 3 \end{pmatrix}$$ how do we calculate the matrix $$f(A)$$?

I know from the solution, that the $$(2,2)$$ entry of $$f(A)$$ is $$40$$. However, I don't see how we' d calculate that. I've tried reversing the solution but I did not come far.

• What is $A^2$? What is $A^3$?
– lulu
Jul 1, 2019 at 20:52

The simple approach is to follow the given calculation. Given $$A = \begin{pmatrix} 1 & -1 \\ 2 & 3 \end{pmatrix}$$ we have $$A^2 = \begin{pmatrix} 1 & -1 \\ 2 & 3 \end{pmatrix}^2=\begin{pmatrix} -1 & -4 \\ 9 & 7 \end{pmatrix}$$ One more matrix multiply gets you $$A^3$$, then you multiply by the scalars and add to get $$f(A)$$. For higher powers you can often express $$A=P^{-1}DP$$ with $$D$$ diagonal to make the calculations easier because then $$A^n=P^{-1}D^nP$$ and diagonal matrices are easy to raise to a power.
• If you are going to diagonalise $A$, chances are you are going to find an annihilating polynomial (like the characteristic one) along the way, any then you might as well reduce $f$ modulo that annihilating polynomial to reduce the degree. Jul 3, 2019 at 5:45
If $$f(x)=x^3+2x^2+3x+4,$$ then $$f(A)=A^3+2A^2+3A+4I.$$ Can you compute this?
Since$$3A=\begin{bmatrix}3 & -3 \\ 6 & 9\end{bmatrix},$$since$$2A^2=\begin{bmatrix}-2 & -8 \\ 16 & 14\end{bmatrix},$$and since$$A^3=\begin{bmatrix}-9 & -11 \\ 22 & 13\end{bmatrix},$$we have$$A^3+2A^2+3A+4\operatorname{Id}=\begin{bmatrix}-4 & -22 \\ 44 & 40\end{bmatrix}.$$