Show that the collection of matrices which commute with every idempotent matrix are the scalar matrices

Solution 1:

Let $B$ be a matrix commuting with every idempotent matrix. Fix any vector $u$, I claim that $u$ and $Bu$ cannot be both nonzero and linearly independent.

If they were, then we could take $P$ to send $Bu$ to $u$, and $u$ to itself. But then $$ Bu = B(Pu) = P(Bu) = u, $$ contradicting that $u$ and $Bu$ were linearly independent.

This implies that $Bu = \lambda_u u$ for every $u \in \mathbb{R}^n$. I.e., every vector is an eigenvector of $B$.

Taking $u$ and $v$ to be any two linearly independent vectors, then $B(u + v) = \lambda_u u + \lambda_v v$ has to be a scalar multiple of $u + v$, and we conclude that $\lambda_u = \lambda_v$.

So there is a single scalar $\lambda$ such that $Bu = \lambda u$ for all $u$, which is what we wanted to show.