Non-trivial Commuting matrices Going through some physics problems it occured to be the following question:
Given a real-coefficient $n$ x $n$ matrix $A$, is there any necessary and sufficient condition upon $A$ that ensures that there exists another matrix $B$ such that $A$ and $B$ are commutable?
Note: obviously, any multiple of the identity matrix and any multiple of the matrix itself are solutions. I am asking if there always exists a non-trivial solution.
 A: Let $L(B) = AB-BA$, then you are looking for non trivial elements of $\ker L$.
Let $u, v$ be a left and right eigenvector of $A$ corresponding to some eigenvalue $\lambda$, then $L(vu^*) = 0$. (Note that since $v u^* \neq 0$ 
has rank one, it cannot be a non zero multiple of the identity.)
More generally, the eigenvalues of $L$ are $\lambda_i - \lambda_j$, where 
$\lambda_k$ are the eigenvalues of $A$.
A: Given a matrix $A \in M_n(\mathbb{R})$, consider the set
$$ C(A) = \{ B \in M_n(\mathbb{R}) \, | \, AB = BA \} $$
consisting of all matrices that commute with $C(A)$. Being the solution space of the homogeneous equation $AX - XA = 0_{n \times n}$, this set is a subspace of $M_n(\mathbb{R})$ and one can show that $\dim C(A) \geq n$. 
To see why this is plausible, consider the case in which $A$ is diagonalizable with eigenvalues $\lambda_1, \dots, \lambda_k$ and let $V_i = \ker(A - \lambda_i I)$ be the eigenspaces of $A$ associated to the eigenvalues $\lambda_i$. If $B$ commutes with $A$ then $B$ will also commute with $A - \lambda_i I$ and so if $v \in V_i$ we have
$$ (A - \lambda_i I)(Bv) = B((A - \lambda_i I)v) = B\cdot 0 = 0 $$
which shows that $Bv \in V_i$. Thus, a necessary condition for $B$ to commute with $A$ is that the eigenspaces of $A$ are $B$-invariant. This observation doesn't require $A$ to be diagonalizable but if $A$ is diagonalizable, you can easily check that this condition is also sufficient and so
$$ C(A) = \{ B \in M_n(\mathbb{R}) \, | \, BV_i \subseteq V_i \} $$
and 
$$ \dim C(A) = \sum_{i=1}^k (\dim V_i)^2 \geq \sum_{i=1}^k \dim V_i = n $$
and you'll get the equality $\dim C(A) = n$ when $A$ has $n$ distinct eigenvalues.
The general case is more difficult and obtained by analyzing the possible canonical forms of $A$. For details, see here.
