Assume $A\in M_n(\mathbb{R})$ which means $A$ is an $n\times n$ matrix over field of real numbers. Define $C(A)=\{B\in M_n(\mathbb{R}) \mid AB=BA\}$. It can be shown that $C(A)$ is a vector space over real numbers field. In general, we can show $\text{dim } C(A)\geq n$. In a specific case, assume $A$ is a diagonal matrix that all entries on main diagonal are pairwise different. In this case, what is $\text{dim }C(A)$?
I suspect that dimension of $C(A)$ in this case is equal to $n$. We know all the diagonal matrices commute with this $A$. So we can introduce a basis with elements $E_1,\dots,E_n$ which $E_i$ is a matrix that its $(i,i)$ entry is one and all the other entries are zeros. So the dimension is $n$. But I'm not sure it's a correct answer, because maybe there are other matrices that commute with $A$ that can't be generated with a linear combination of $E_1,\dots,E_n$. Is this basis correct or no?
Please don't use minimal and characteristic polynomials of a matrix. I would be really thankful if you use reasonings as elemtary as I said.
Any help is so much appreciated!