Matrices $B$ that commute with every matrix commuting with $A$

Reference: Lagerstrom, Paco, A Proof of a Theorem on Commutative Matrices, Bulletin of AMS, Volume 51 (1945), 535-536.

This holds for any field $\mathbb{F}$.

Let $M^A$ denote the $\mathbb{F}[x]$-module structure on $\mathbb{F}^n$. We use rational canonical form-invariant factor form. Then we have $$ M^A \simeq \mathbb{F}[x]/P_1 \oplus\cdots \oplus \mathbb{F}[x]/P_r, $$ where $P_i=(p_i)$, $p_i|p_{i+1}$. This gives invariant subspace decomposition, $$ M^A =\bigoplus_{i=1}^r M_i, $$ where $M_i\simeq \mathbb{F}[x]/P_i$.

Let $\pi_i:M^A\longrightarrow M_i$ be the projection, and $\pi_{ij}:M_i\longrightarrow M_j$ be the natural projection for $i>j$. Extend $\pi_{ij}$ linearly to $M^A$ by assigning 0 on all $M_k(k\neq i)$. Then all $\pi_i$ and $\pi_{ij}$ commute with $A$, thus commute with $B$. Therefore, each $M_i$ is $A$-invariant, thus it is also $B$-invariant. Let $e_i\in M_i$ be the element corresponding to $1+P_i\in\mathbb{F}[x]/P_i$. We see that there is $p(x)\in\mathbb{F}[x]$ such that $Be_r=p(A)e_r$. We claim that $Be_i=p(A)e_i$ for all $i<r$, and hence $B=p(A)$. $$ Be_i=B\pi_{ri}e_r=\pi_{ri}Be_r=\pi_{ri}p(A)e_r=p(A)\pi_{ri}e_r=p(A)e_i. $$ This completes the proof.