Understanding what $XI_n - M$ is The following text from Serre's Matrices: Theory and Applications is confusing me.



Serre considers $XI_n-M$ as  a matrix with entries in $K[X]$, which is perfectly fine. Right after this, he substitutes the indeterminate $X$ with a matrix $N$. To my understanding, doing so requires that we consider $XI_n-M$ as a polynomial with coefficients in a commutative ring contained in $M_n(K)$. A natural choice for this commutative subring is the ring spanned by $M$ and $I_n$. But then, $NI_n - M\in M_n(K)$, whereas Serre says that $NI_n - M\in M_n(A)$ where $A$ is the ring spanned by $N$ and $I_n$ (so $NI_n - M$ is a matrix whose entries are matrices themselves) ...
Can someone clarify this ?
 A: It's a good question on a point that is often overlooked. A rigorous interpretation is the following : if you have a ring morphism $f:A\to B$ then you get a morphism $f^*: M_n(A)\to M_n(B)$ (just applying $f$ to the coefficients). Now if $B$ is any $K$-algebra and $b\in B$ is any element, there is a unique $K$-algebra morphism $f_b: K[X]\to B$ sending $X$ to $b$, that you can call "evaluating $X$ at $b$ in $B$".
Then if $P_m = XI_n - M \in M_n(K[X])$, evaluating $X$ at $N$ means to take $f_N^*(P_M)$, where $f_N$ is a ring morphism from $K[X]$ to $M_n(K)$, so $f_N^*$ is a ring morphism from $M_n(K[X])$ to $M_n(M_n(K))\simeq M_{n^2}(K)$.
This is indeed what he calls $P_M(N)$. Of course, you can call $A$ the subring of $M_n(K)$ generated by $N$ and say that $f_N$ takes values in $A$ so $f_N^*$ takes values in $M_n(A)\subset M_n(M_n(K))$ but this amounts to the same.

This is by opposition to the (wrong) interpretation that $P_M = XI_n -M$ lives in $M_n(K)[X]$ and that evaluating $P_M$ at $N$ means to take $f_N(P_M)$ where $f_N : M_n(K)[X] \to M_n(K)$ replaces $X$ by $N$. This would at the end give $P_M(N) = NI_n - M = N-M$ ; but this is not what we mean.
