Assume two commuting $n\times n$ complex matrices $A$ and $B$ are given. Then it is in general false that if $C$ is a square root of $A$, i.e., if $C^2=A$, then $C$ commutes with $B$ (the simplest counterexample is provided by $A$ the 2-by-two identity matrix and $C=diag(1,-1)$.


Yet, when $A$ is invertible, by using holomorphic functional calculus it is easy to show that there exist at least a square root of $A$ which commutes with $B$, i.e., there exist at least one $C$ such that $C^2=A$ and $[B,C]=0$.


Is there also an elementary (i.e., purely linear algebra) proof of this fact?



Square root of a complex matrix commuting with a given one
As in Geoff Robinson's answer, let us show that there exists a square root of $A$ which is a polynomial in $A$; then surely it commutes with $B$.


Let $\mu(x)$ be the minimal annihilating polynomial for $A$, $\mu(x)=\prod\_i(x-\lambda\_i)^{\alpha\_i}$. We need to find a polynomial $P(x)$ such that $P(x)^2\equiv x\pmod {\mu(x)}$ (then $P(A)$ is a desired square root). By the Chinese remainder theorem, it suffices to find such polynomial modulo each of $(x-\lambda\_i)^{\alpha\_i}$, which is the same as finding a square root of $t+\lambda\_i$ modulo $t^{\alpha\_i}$. This last root can be proved to exist either by simple lifting of exponent $\alpha\_i$, or by mentioning that the Taylor polynomial
$$
 P\_i(t)=\sqrt{\lambda\_i}\sum\_{n=0}^{\alpha\_i-1}
 \frac{\frac12\bigl(\frac12-1\bigr)\cdots\bigl(\frac12-n+1\bigr)}{n!}\biggl(\frac{t}{\lambda\_i}\biggr)^n
$$
for $(t+\lambda\_i)^{1/2}$ fits.


This proof works as well if $\mu(x)$ is divisible by $x$ (but not by $x^2$) since $0$ is a square root of $x$ modulo $x$. 


**EDIT.** As Geoff Robinson mentioned, my last statement was wrong, so the case when $\mu(x)$ is divisible by $x^2$ needs another methods. In this case, the desired claim is wrong. One may clearly use the statement that each operator commuting with all operators commuting with $A$ is a polynomial in $A$, but here is an explicit counterexample (surely inspired by Geoff).


Let $A=\pmatrix{0&0&1\\0&0&0\\0&0&0}$, $B=\pmatrix{1&0&0\\0&0&0\\0&0&1}$. Then $AB=BA$, and there exists a square root of $A$, for instance, $\pmatrix{0&1&0\\0&0&1\\0&0&0}$. On the other hand, since $B$ is the projector onto $\langle e\_1,e\_3\rangle$, each $C$ commuting with $B$ should have the form $C=\pmatrix{a&0&b\\0&c&0\\d&0&e}$. Now, if $C^2=A$ then $\pmatrix{a&b\\d&e}^2=\pmatrix{0&1\\0&0}$ which is impossible: otherwise we would obtain a $2\times 2$ matrix whose square is nonzero but the fourth power is zero.


