Visualizing a function from the set of all $n\times n$ matrices to all $n\times n$ matrices Today in my maths class our teacher presented a question. The question said that $$f(x)=x^2+4x-1,$$ $$ A=\begin{bmatrix} 
3 & 2 \\
4 & 1 
\end{bmatrix}$$ Find $f(A)$. Now this question was aimed at purely computational aspects of matrices. But the question I had that if we have a set of all $[A]_{n\times n}$ matrices as the domain and the set of all $[B]_{n\times n}$ as the codomain, then how does one visualize $f: [A]_{n \times n} \to [B]_{n \times n}$ where $f$ is an $n$ degree polynomial with coefficients$(a_i\in \Bbb{Z}, \forall i )$in integers. By visualize I mean to say that how does one derive a geometric interpretation of the function 
 A: $\newcommand{\Reals}{\mathbf{R}}\DeclareMathOperator{\diag}{diag}$I'm not sure there's an illuminating geometric interpretation of the polynomial function $f$, but there is a geometric interpretation of the value $f(A)$.
First, suppose $D = \diag[a_{1}, a_{2}]$ were the diagonal matrix with diagonal entries $a_{1}$ and $a_{2}$. Clearly (or by induction on $n$),
$$
D^{n} = \diag[a_{1}^{n}, a_{2}^{n}]\qquad\text{for every positive integer $n$.}
$$
Consequently, if $f$ is an arbitrary polynomial, then
$$
f(D) = \diag[f(a_{1}), f(a_{2})]
\tag{1}
$$
is the diagonal matrices whose diagonal entries are the values of $f$ at $a_{1}$ and $a_{2}$. (Be sure you see why.)
Now, most square matrices $A$ aren't diagonal, but most (in a precise sense) are diagonalizable: There exists an invertible matrix $P$ such that $P^{-1}AP = D$ is diagonal. Geometrically, this means that for "most" $2 \times 2$ real matrices $A$, there exist vectors $v_{1}$  and $v_{2}$ in $\Reals^{2}$ and (complex) scalars $a_{1}$ and $a_{2}$ such that
$$
Av_{1} = a_{1}v_{1},\qquad
Av_{2} = a_{2}v_{2}.
$$
The matrix $P$ has the $v_{i}$ as columns, and may be viewed as the change of basis matrix from the standard basis $(e_{1}, e_{2})$ to $(v_{1}, v_{2})$. Geometrically, multiplication by $A$ acts diagonally on the "skewed Cartesian grid spanned by $v_{1}$ and $v_{2}$."
(Incidentally, the $v_{i}$ are called eigenvectors of $A$, and the $a_{i}$ are the corresponding eigenvalues. If you haven't seen these concepts yet, you will soon. It's impossible to over-emphasize their importance.)
Now, if $n$ is a positive integer, then
$$
(P^{-1}AP)^{n} = P^{-1}A^{n}P.
$$
For example, $(P^{-1}AP)^{2} = (P^{-1}AP)(P^{-1}AP) = P^{-1}A(PP^{-1})AP = P^{-1}A^{2}P$. This is not quite the usual law of exponents, because $P$ and $A$ do not generally commute. Instead, the "internal" factors of $P^{-1}$ and $P$ appear as adjacent pairs, and therefore cancel. It follows that if $f$ is a polynomial, then
$$
f(P^{-1}AP) = P^{-1}f(A)P,
$$
or
$$
f(A) = P\, f(P^{-1}AP)\, P^{-1}.
\tag{2}
$$
Finally, if we assume $D = P^{-1}AP$ is diagonal, (2) and (1) imply
$$
f(A) = P\, f(D)\, P^{-1} = P\, \diag[f(a_{1}), f(a_{2})]\, P^{-1}.
$$
That's your geometric explanation (since your matrix turns out to be diagonalizable, with eigenvalues $-1$ and $5$): In a skewed coordinate system whose axes are the eigenspaces of $A$, multiplication by the matrix $f(A)$ acts diagonally, scaling one axis by $f(a_{1})$ and the other by $f(a_{2})$.
