TITLE: The Dimension of Vector Space
QUESTION [6 upvotes]: Question:
Let $A$ be an $n×n$ complex matrix with $n$ distinct eigenvalues. Let $V$ be the set of all $n×n$ complex matrices $B$ that commute with $A$. Prove that V is a vector space and find its dimension (Justify your answer).
My Answer: I know how to show that V is a vector space, but I don't know how to find its dimension.
I tried showing that if v is an eigenvector corresponding to some eigenvalue, so is Bv, and got that for all B, Bv = kv for some scalar v. But I'm not sure if this helps.

REPLY [4 votes]: You have proved that $Bv_i = \mu_i v_i$ for all $i=1,\dots,n$.
Let $p$ be the polynomial such that $p(\lambda_i)=\mu_i$.
Then $p(A)v_i=p(\lambda_i)v_i=\mu_i v_i=Bv_i$.
Therefore, $B=p(A)$.
Thus, $V$ is exactly the subspace of all polynomials in $A$. What is the dimension of that subspace?