How to find the set of all matrices that commute with a given matrix? Is there any smart way to compute the set of all matrices that commute with a given matrix?
Smart way means that involves concept and intutition of linear and abstract algebra and does not involve any calculation. For example, given a matrix $A$ of order $n \times n$ we can solve for $X$ the matrix equation $$AX=XA$$ and get a condition on the entries of $X$. But I am not looking for such a method. I am looking for some smart approach like using linear transformations and visual understanding. Is there any way to do this?
I have searched for this question in stack exchange but the answers are out of scope of my present knowledge.
 A: In this website, the fashion is to explain what is the intuition which makes it possible to solve such or such problem (incidentally, it also earns points...). First of all, if you are just starting out or if you are not working on examples, you are unlikely to have an effective intuition; in other words, intuition is useful (and even, in some difficult cases, essential) only when you have understood a certain number of results and have accumulated experience.
Calculate the commutant $C(A)$ of a matrix $A\in M_n(K)$ is not obvious in the general case.
$\textbf{Proposition 1}$. Let $A=diag(A_1,\cdots,A_k)\in M_n(\mathbb{C})$ s.t., for every $i\not= j$, $spectrum(A_i)\cap spectrum(A_j)=\emptyset$. Then $B\in C(A)$ iff $B$ is in the form $diag(B_1,\cdots,B_k)$ where $A_iB_i=B_iA_i$.
$\textbf{Proposition 2}$. Let $A\in M_n(\mathbb{C})$ be cyclic (that is, its Jordan form has the form $Jordan(A)=diag(\lambda_1I_{i_1}+J_{i_1},\cdots,\lambda_kI_{i_k}+J_{i_k})$, where the $(\lambda_i)$ are distinct and $(J_p)$ is the nilpotent Jordan block of dimension $p$). Then $B\in C(A)$ iff $B$ is a polynomial in $A$ (note for @P. Quinton : in particular, $B\in C(\lambda_kI_{i_k}+J_{i_k})$ iff $B$ is a polynomial in $J_k$). Therefore, $dim(C(A)=n$.
$\textbf{Remarks}$. i)  Note that, in general when $n\geq 5$, we don't know how to calculate the Jordan form of a matrix (because we don't know how to calculate its eigenvalues).
ii) According to both previous propositions, $dim(C(A)\geq n$.
Moreover, to study $C(A)$, it suffices to consider the case when $A$ has only one eigenvalue and is not cyclic. Unfortunately (for your intuition), it's the difficult case; I'll just consider the following example
Let $A=diag(J_2,J_2)$. The matrices $B=diag(B_1,B_2)$ where $B_1,B_2\in  span(I_2,J_2)$ are in $C(A)$. Yet, $dim(C(A))\not= 4$. Indeed, $dim(C(A))=8$ -because $B\in C(A)$ is in the form
$\begin{pmatrix}a&b&c&d\\0&a&0&c\\e&f&g&h\\0&e&0&g\end{pmatrix}$-.
Conclusion: "Intuition is the anticipated vision of a truth: hypothesis for the scientist, reverie for the poet."
A: If we take the Jordan form $A=PJP^{-1}$ where $J=\begin{bmatrix}J_1&0&\cdots&0\\0&J_2&\cdots&0\\\vdots&\vdots&\ddots&\vdots\\0&0&\cdots&J_k\end{bmatrix}$ such that $J_i$ is a Jordan block of size $n_i\times n_i$ ($\sum_{i=1}^k n_i=n$) then all the matrices
\begin{align*}
X&=P\cdot J'\cdot P^{-1}
\end{align*}
where $J'=\begin{bmatrix}J_1'&0&\cdots&0\\0&J_2'&\cdots&0\\\vdots&\vdots&\ddots&\vdots\\0&0&\cdots&J_k'\end{bmatrix}$ and $J_i'$ are jordan blocks of size $n_i\times n_i$. Indeed
\begin{align*}
J_i\cdot J_i' &=\begin{bmatrix}
\lambda_i&1&0&\cdots&0\\0&\lambda_i&1&\cdots&0\\0&0&\lambda_i&\cdots&0\\\vdots&\vdots&\vdots&\ddots&\vdots\\0&0&0&\cdots&\lambda_i
\end{bmatrix}\cdot\begin{bmatrix}
\lambda_i'&1&0&\cdots&0\\0&\lambda_i'&1&\cdots&0\\0&0&\lambda_i'&\cdots&0\\\vdots&\vdots&\vdots&\ddots&\vdots\\0&0&0&\cdots&\lambda_i'
\end{bmatrix}\\
&=\begin{bmatrix}\lambda_i\lambda_i'&\lambda_i+\lambda_i'&1&\cdots&0\\0&\lambda_i\lambda_i'&\lambda_i+\lambda_i'&\cdots&0\\0&0&\lambda_i\lambda_i'&\cdots&0\\\vdots&\vdots&\vdots&\ddots&\vdots\\0&0&0&\cdots&\lambda_i\lambda_i'
\end{bmatrix}\\&=J_i'\cdot J_i
\end{align*}
Hence $J$ and $J'$ commute and so does $A$ and $X$.
