Solution (source code)

= Solution

Put $p(t)=\prod_{j=1}^m(t-\mu_j)$ and define the <Lagrange interpolation polynomials>
$$
\ell_j(t)=\prod_{k\ne j}\frac{t-\mu_k}{\mu_j-\mu_k}.
$$
Their denominators are nonzero and $\ell_j(\mu_i)=\delta_{ij}$. The <polynomial> $\sum_j\ell_j-1$ has degree at most $m-1$ and vanishes at all $m$ distinct <scalars>, so it is zero. Suppose condition (a) holds, and put $E_j=\ell_j(T)$. Since $(t-\mu_j)\ell_j(t)$ is a constant multiple of $p(t)$,
$$
(T-\mu_jI)E_j=0,\qquad\sum_jE_j=I.
$$
Thus each $E_jv$ lies in $V_j$, and every <vector> is a sum of such <vectors>. If $\sum_jv_j=0$ with $v_j\in V_j$, applying $E_i$ gives $v_i=0$, because $\ell_i(T)v_j=\ell_i(\mu_j)v_j$. Hence the sum is direct, proving (b). Conversely, on each $V_j$ the factor $T-\mu_jI$ vanishes; the factors commute, so $p(T)$ vanishes on every summand and therefore on $V$. This proves the equivalence \b[without invoking primary decomposition].

If $ST=TS$ and $v\in V_j$, then $(T-\mu_jI)Sv=S(T-\mu_jI)v=0$, so $S[V_j]\subseteq V_j$. Conversely, if each summand is preserved, then on $V_j$ both $ST$ and $TS$ act as $\mu_jS$. They agree on all summands and hence on $V$. Therefore
$$
\boxed{ST=TS\iff S[V_j]\subseteq V_j\text{ for every }j.}
$$