This is probably a pretty basic linear algebra question, but suppose we have two unitary operators $A$ and $B$, acting on the same $n$ qubits of $|\psi\rangle$, with $[A,B]=0$ - that is, $A$ and $B$ commute with each other.

As has been referenced many times, we can take their roots by performing controlled versions of each of them, rotating the ancillae, and performing a controlled inverse of each of them. Indeed, I'd like to consider using different ancillae for $A$ and $B$ so as to reduce the depth of my circuit.

But does it follow that $[\sqrt A,\sqrt B]=0$ if $[A,B]=0$?

In my particular application I also happen to know that $A^4=B^4=AB=BA=\mathbb I$, but that might be a red herring to the main question. The follow up would be whether $\sqrt A\sqrt B=\sqrt B\sqrt A=\mathbb I$ if $AB=BA=\mathbb I$, but I don't think that holds (it doesn't hold for $a,b\in\mathbb C$).


2 Answers 2


If $A$ and $B$ are any two diagonalizable matrices that commute, then for any matrix function $f$ (anything in the continuous functional calculus, such as square root), $f(A)$ and $f(B)$ will also commute.

[EDIT (thanks to Danylo Y): More specifically,$f:\mathbb{C}\rightarrow\mathbb{C}$ should be continuous on the spectra of $A$ and $B$ for the continuous functional calculus to be well-defined. When you say "square root" it's highly ambiguous: Craig Gidney points out that matrix square roots are not unique (e.g. $A(\theta):=\cos(\theta)X+\sin(\theta)Z$ satisfies $A(\theta)^2=I$ for all $\theta$, so there are infinitely many "square roots" of $I$). Usually one thinks about square roots of positive matrices, for which there is a unique positive root. But for unitaries, that's not true. In fact the square root isn't continuous on the complex unit circle.

In my "intuitive" answer, continuity isn't necessary as long as you define $f(A)$ exactly as I describe in terms of its diagonalization. And for a function expressible as a power series, that's the same as the "general" answer. However, without knowing exactly how you've defined $\sqrt{A}$ and $\sqrt{B}$, then this might not apply.

A more accurate summary of the situation: For any two diagonalizable, commuting matrices $A$ and $B$, you can define matrices $\sqrt{A}$ and $\sqrt{B}$ such that $\sqrt{A}^2=A$ and $\sqrt{B}^2=B$, and $[\sqrt{A},\sqrt{B}]=0$. The proof is that every complex number has a square root, so you diagonalize and then pick a square root of each eigenvalue. But that's not what my original answer said; sorry for misleading!]

Intuitive answer: We can define $f(A)$ by first diagonalizing $A$ as $A=VDV^*$ for some unitary $V$ and diagonal matrix $D$. The function $f$ can be applied to the diagonal entries of $D$ (e.g.: square root), to produce $f(D)$; then we define $f(A)=Vf(D)V^*$.

If $A$ and $B$ commute, they can be simultaneously diagonalized, so $A=VD_AV^*$ and $B=VD_BV^*$. Diagonal matrices definitely commute, so $f(D_A)f(D_B)=f(D_B)f(D_A)$. Thus:

$$f(A)f(B) = Vf(D_A)V^*Vf(D_B)V^*=Vf(D_B)f(D_A)V^* = f(B)f(A)$$

(skipping steps to cancel and restore $V^*V=I$).

More general answer: If $A$ and $B$ commute, any powers of $A$ and $B$ commute (you can just commute each instance of $A$ and $B$ one at a time).

Moreover, if $A_1,\dots A_n$ each commute with every one of $B_1,\dots,B_n$, then any linear combination of $A_1,\dots, A_n$ commutes with any linear combination of $B_1,\dots, B_n$.

Combining those two facts, we get that any polynomial of $A$ will commute with any polynomial of $B$. Then any function with a power series representation [EDIT: on the spectrum on $A$ and $B$!] (square roots, logarithms, exponentials, trigonemetric) will also commute, as they can be found as the limit of a sequence of polynomials.

  • 5
    $\begingroup$ This is wrong because 1) $\sqrt{A}$ is not unique. So that, if $A = VDV^\dagger$ then it's NOT true that $\sqrt{A} = V\sqrt{D}V^\dagger$. For example, take $V=\sqrt{D}=I$ and $\sqrt{A}=-I$. And 2) square root function $\sqrt{x}$ doesn't have power series expansion at point $x=0$. $\endgroup$
    – Danylo Y
    Feb 24, 2022 at 20:13
  • $\begingroup$ If $A=I$ and we want $\sqrt{A}=-I$, we could also take $\sqrt{D}=-I$ as well. But you're right and I'll edit the post. $\endgroup$
    – Sam Jaques
    Feb 25, 2022 at 9:23
  • 1
    $\begingroup$ Thanks and stay safe @DanyloY ! $\endgroup$ Feb 25, 2022 at 21:35

It's always possible to find some square roots that commute. But it's not guaranteed that all square roots commute.

If two operations commute, then you can find square roots that commute by eigendecomposing them and by applying consistent principle square roots to their eigenvalues.

But, if some of the eigenvalues are degenerate, you can create anticommuting effects within their degenerate eigenspaces. This can create anticommuting square roots. In fact, it can even be done when both starting operations are the same. For example, $X$ and $Y$ are square roots of the identity operation, because $X^2=Y^2=I$. And clearly $I$ commutes with $I$. But $X$ and $Y$ do not commute.

  • $\begingroup$ This is the correct answer $\endgroup$ Feb 25, 2022 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.