# If a matrix commutes with all diagonal matrices, must the matrix itself be diagonal?

I'm new to stackexchange so feel free to correct my style/format/logic etc.

The question is this: let's say $A$ is a square matrix of size $n$. I would like to show that $AD = DA$, for any diagonal matrix $D$ also of size $n$, if and only if $A$ is also diagonal.

I think I have some of the proof but am not very confident in it.

$\Leftarrow$: If A is diagonal, it is not too hard to show that $AD = DA$, because multiplying two diagonal matrices just amounts to multiplying the corresponding diagonal entries.

$\Rightarrow$: (i) $DA$ is found by multiplying each row in A with the corresponding entry along the diagonal in $D$. $AD$ is found by multiplying each column in $A$ with the corresponding entry along the diagonal in $D$. Since $AD = DA$, this product has to be symmetric.

(ii) Now suppose $A$ weren't a diagonal matrix. Then if we make the entries along the diagonal in $D$ all different, $AD$ won't be symmetric anymore (?). This contradicts (i), so we have shown both ways.

Does this work?

[edited]

• What if $D = I$? Dec 31, 2013 at 8:21
• edited to say that this should work for any D Dec 31, 2013 at 8:24
• To show the $\Rightarrow$ direction consider choosing for $D$ the matrices $D_i$, where $D_i$ is all zero except the element on the i-th diagonal is $1$. Then $A D_i$ has the $i$-th column equal to that of $A$ and the rest is zero. On the other hand $D_i A$ has the $i$-th row equal to that of $A$ and the rest is zero. If these two have to be equal then all non-diagonal elements of $A$ have to be zero. Proof by contradiction is not necessary. Dec 31, 2013 at 8:31
• ooh, nice. thanks! Dec 31, 2013 at 8:38

Here's a geometric formulation. If two matrices $A,D$ commute, then all eigenspaces for $D$ must be $A$-stable (if $v$ is eigenvector for $D$ and eigenvalue $\lambda$, then $DA\cdot v=AD\cdot v=A\cdot\lambda v=\lambda(A\cdot v)$, so $A\cdot v$ is eigenvector for $D$ and eigenvalue $\lambda$ as well). Now for every standard basis vector $e_i$ there is a diagonal matrix $D$ for which $\langle e_i\rangle$ is an eigenspace for $D$, for instance the elementary matrix $D=E_{i,i}$. Since $A$ must commute with all such $D$, it must stabilise every line $\langle e_i\rangle$, and this forces $A$ to be diagonal.
If your field has at least $n$ elements (in particular if it is infinite), you can arrange for a single $D$ to have every line $\langle e_i\rangle$ as eigenspace, and then just commuting with this single $D$ will force being diagonal.
Pick a $D$ so that all except one diagonal entry is zero, and the nonzero entry is $D_{ii}=1$
$$(D A)_{ij} = a_{ij}$$ and for $j \neq i$ $$(A D)_{ij} = 0$$ Hence $a_{ij}=0$.
Since $i$ and $j$ are arbitrary, $A$ has to be diagonal.
Alternate approach: Let $$D = \text{diag}(1,2,3,4,\cdots n)$$ then $$(DA)_{ij} = i \cdot a_{ij}, \text{ and } (AD)_{ij} = j \cdot a_{ij}$$ So if $i \neq j$, $a_{ij} =0$