I'm having a trouble with this proof (see bottom). At the last fourth line it says
$$tr(xy)=0 \implies \sum_{i=1}^na_if(a_i)=0$$
but $$tr(xy)=tr(sy)+tr(ny)=\sum_{i=1}^na_if(a_i)+tr(ny)$$
how do we know $tr(ny)=0$? The endomorphism $n$ is nilpotent and $y$ is diagonalizable but this only is not sufficient to infer $tr(ny)=0$. Maybe $n$ commutes with $y$?

Let's review where Jordan decompositions come from. Put $x$ into Jordan normal form with respect to some basis, then $s$ consists of its diagonal entries and $n$ of its non-diagonal entries. Then $n$ is strictly upper-triangular. The matrix $y$ is chosen to be diagonal in this basis. Therefore $ny$ is strictly upper-triangular, and so has trace zero.
Alternatively $xy$ is upper-triangular with diagonal entries $a_if(a_i)$ and so its trace is $\sum_i a_if(a_i)$.