# Condition for commuting matrices

Let $A,B$ be $n \times n$ matrices over the complex numbers. If $B=p(A)$ where $p(x) \in \mathbb{C}[x]$ then certainly $A,B$ commute. Under which conditions the converse is true?

Thanks 🙂

#### Solutions Collecting From Web of "Condition for commuting matrices"

The usual condition I have seen is that matrices commute if and only if they have a common basis of generalized eigenvectors.

Another interpretation:

It has been pointed out that my first interpretation of the question is most likely wrong. The intended question is probably similar to this question. In that case, the answer would be that if a matrix $A$ has distinct eigenvalues, then $B$ commutes with $A$ if and only if $B=P(A)$ for some complex coefficient polynomial $P$. If $A$ is $n\times n$, then $P$ need be at most degree $n-1$.

Justification:

Suppose that $A$ has distinct eigenvalues, then it is diagonalizable with a basis of eigenvectors. Thus, we can write $A=ED_AE^{-1}$ where $D_A$ is a diagonal matrix whose diagonal entries are the distinct eigenvalues of $A$ and $E$ is a matrix whose columns are the eigenvectors of $A$.

Furthermore, suppose that $B$ commutes with $A$. Since $A$ shares its basis of eigenvectors with $B$, we have that $B=ED_BE^{-1}$, where $D_B$ is diagonal and the diagonal elements of $D_B$ are the eigenvalues of $B$.

Suppose $P$ is the degree $n-1$ polynomial that takes the $n$ distinct diagonal elements of $D_A$ to the $n$ diagonal elements of $D_B$. Then, because $D_A$ and $D_B$ are diagonal, $P(D_A)=D_B$, which then gives us
$$P(A)=P(ED_AE^{-1})=EP(D_A)E^{-1}=ED_BE^{-1}=B$$

THEOREM: The following are equivalent conditions about a matrix $A$ with entries in $\mathbb C$:

(I) $A$ commutes only with matrices $B = p(A)$ for some $p(x) \in \mathbb C[x]$

(II) The minimal polynomial and characteristic polynomial of $A$ coincide

(III) $A$ is similar to a companion matrix.

(IV) Each characteristic value of $A$ occurs in only one Jordan block. This includes the possibility that all eigenvalues are distinct, but allows for repetition if they all occur in one Jordan block.

The converse is true if the minimal polynom degree equal $n$

If $C(A)$ denote the space of matrix $B$ who commut with $A$. There is o formulla who gives the $C(A)$ dimension using the similarity invariants of $A$, thus : if $P_1|…|P_s$ is the similarity invariants sequence of $A$ then :
$$\dim (C(A))=\sum_{i=1}^{s} (2(s-i) + 1) d_i$$
where $d_i=\text{deg} P_i$

Since $\mathbb C[A] \subset C(A)$ this formula can help us to regard is convesly if minimal polynom degree equal $n$ thens $C(A)=\mathbb C[A]$