# Arbitrary powers of NOT and SWAP

The square-root of not and square-root of swap gates are often singled out for discussion of gates displaying important properties relating to quantum computers.

• How do I define arbitrary (non-integer) powers of the square-root of NOT or square-root of SWAP?

• How do I find their unitary matrices?

• How might I implement these gates?

Let's start with some general theory. If you have a normal matrix $$A$$ (of which unitaries are a subset), you can define any function of that matrix $$f(A)$$. For example, $$A^{1/2}$$ or $$A^{\pi}$$. The most natural way to do this is via the spectral decomposition: if $$\{\lambda_i\}$$ are the eigenvalues of $$A$$ and $$U$$ is the matrix that diagonalises $$A$$: $$UAU^\dagger=\sum_i\lambda_i|i\rangle\langle i|:=D,$$ i.e. $$D$$ is a diagonal matrix with entries corresponding to the eigenvalues. Then, $$f(A)=U^\dagger\sum_if(\lambda_i)|i\rangle\langle i| U.$$ You can see why this works if you think about $$\sqrt{A}=U^\dagger\sqrt{D} U$$ (where $$\sqrt{D}$$ is just the same as $$D$$, but taking the square root on each of the diagonal entries), and we multiply it together: $$\sqrt{A}\cdot \sqrt{A}=U^\dagger\sqrt{D} UU^\dagger\sqrt{D} U=U^\dagger D U=A.$$

In this way, we can define arbitrary power of $$X$$. Effectively, we have $$X^{q}=|+\rangle\langle +|+e^{i\pi q}|-\rangle\langle -|=\frac{1}{2}\left(\begin{array}{cc} 1+e^{i\pi q} & 1-e^{i\pi q} \\ 1-e^{i\pi q} & 1+ e^{i\pi q} \end{array}\right)=e^{i\pi q/2}\left(\begin{array}{cc} \cos\frac{\pi q}{2} & -i\sin\frac{\pi q}{2} \\ -i\sin\frac{\pi q}{2} & \cos \frac{\pi q}{2} \end{array}\right)$$

There are several ways in which you might implement this gate. For example, as already mentioned here, you can think of it as a continuous time operator $$e^{i(\mathbb{I}-X)t}$$ for any $$t$$ that you want ($$t=\pi q/2$$). Another way, if you have arbitrary phase gates available, is just the sequence Hadamard - phase - hadamard, as the hadamards convert a z-rotation into an x-rotation.

As yet, I haven't mentioned the power of swap. Think about the swap gate. Clearly, two eigenvectors (of eigenvalue 1) are $$|00\rangle$$ and $$|11\rangle$$. These are unchanged by taking arbitrary powers. The bit that's affected is a $$2\times 2$$ subspace spanned by $$\{|01\rangle,|10\rangle\}$$. But when you look at just this subspace, the SWAP matrix is exactly the same as $$X$$. So, knowing about $$f(X)$$ immediately tells us about $$f(\mathrm{SWAP})$$. $$\mathrm{SWAP}^q=\left(\begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & e^{i\pi q/2}\cos\frac{\pi q}{2} & -ie^{i\pi q/2}\sin\frac{\pi q}{2} & \ \\ 0 & -ie^{i\pi q/2}\sin\frac{\pi q}{2} & e^{i\pi q/2}\cos \frac{\pi q}{2} & 0 \\ 0 & 0 & 0 & 1 \end{array}\right)$$

If you want a continuous-time implementation, then one can use $$e^{it(\mathbb{I}-Z\otimes Z -X\otimes X-Y\otimes Y)/2},$$ because this Hamiltonian, when restricted to the $$2\times 2$$ subspace is just $$\mathbb{I}-X$$, as we required before. As for a quantum circuit, that has been partially addressed here. That answer effectively conveys how any $$f(\mathrm{SWAP})$$ can be converted into a controlled-$$f(X)$$ gate. One simply has to get the angle of rotation correct, and sufficient information is conveyed in that answer.

• Excellent answer! How would controlled versions work? What are the advantages/disadvantages of controled vs not? (Thanks again for taking the time!) Jul 18 '18 at 10:51
• controlled versions are contained within the solution for $SWAP^q$ solution (just remove the controlled-not at either end of the circuit). Jul 18 '18 at 10:52
• Including a control or not makes a different gate with a different purpose. I'm not sure it makes sense to ask for advantages and disadvantages. Jul 18 '18 at 10:53
• I suppose the better question might be why you would want to use one vs. the other (which I will understand more as I learn more about them). Nice answer on 3d cX as well. Looking forward to looking thru links! Jul 18 '18 at 11:00

Here is a more general view of your question that might offer some clarity: An operator $$A$$ on a Hilbert space $$\mathcal{H}$$ is called normal if it commutes with its adjoint, $$AA^\dagger = A^\dagger A$$. Equivalently, any operator $$A$$ decomposes as $$A = B + iC$$, where $$B$$ and $$C$$ are self-adjoint, and $$A$$ is normal if and only if $$B$$ and $$C$$ commute. This means that $$B$$ and $$C$$ are simultaneously measurable, which means that you can interpret $$A$$ as a complex-valued measurable. In conclusion, normal operators are the same as complex-valued measurables. If $$A$$ is self-adjoint, that is the real-valued special case; if $$A$$ is unitary, that is the circle-valued special case.

If $$f$$ is any function from the complex numbers $$\mathbb{C}$$ to itself and $$A$$ is normal, then the usually inevitable definition of $$f(A)$$ is through spectral decomposition. I.e., you should replace each eigenvalue $$\lambda$$ with $$f(\lambda)$$ and let its eigenvector stay put. In this vast generality, this concept goes back to von Neumann. To be sure, there could also be other definitions of $$f(A)$$, but another definition is usually only credible when it agrees with the spectral definition. For instance, if $$f$$ has a power series whose domain of convergence contains the spectrum of $$A$$, for instance $$f(z) = e^z$$, then $$f(A)$$ can also be defined by a power series --- but you get the same answer as the spectral definition. A more fun case is the absolute value $$|A|$$, which doesn't have a good power series. The spectral definition says, duh, just replace each $$\lambda$$ by $$|\lambda|$$. This agrees with the more creative-looking formula $$|A| = \sqrt{A^\dagger A}$$.

With fractional powers, the problem that you run into is that the scalar fractional power function $$f(z) = z^\alpha$$ is multivalued in the complex plane, unless the exponent $$\alpha$$ is an integer. The paradox doesn't actually lie with operators, but just with complex numbers. Just as $$z^{1/2}$$ naturally has two values when $$z$$ is a general complex number, $$A^{1/2}$$ naturally has many values when $$A$$ is a general normal (or unitary) operator. (In fact more than two, since you can make a separate binary choice for each eigenvalue.) The standard solution in complex analysis, which is often more of a convention than truly a solution to anything, is to resolve $$f(z) = z^\alpha$$ to a single-valued function using a branch cut. If you do that, then $$f(A)$$ becomes a well-defined single-valued function as well, again assuming that $$A$$ is normal.

If you use the formula $$z^\alpha = e^{\alpha \ln z}$$, and if you use the standard branch cut for logarithm and apply the result to the SWAP gate, then I think you get exactly the answer that you gave. The SWAP gate has eigenvalue $$1$$ thrice and eigenvalue $$-1$$ once, and you are indeed moving the non-trivial eigenvalue in a counterclockwise arc around the unit circle from $$1$$ to $$-1$$.

This answer, which can be motivated by abstract mathematics, also has a nice property for quantum control, which might be your real motivation here. Namely, it is a shortest geodesic in the space of unitaries, a path where the Hamiltonian evolution does the least work. You can always use the $$z^\alpha = e^{\alpha \ln z}$$ formula together with the standard branch cut for the logarithm to achieve this. The main wrinkle is that if you do not care about global phase as you shouldn't, then you can adjust the global phase of $$A$$ to optimize for the best geodesic. But that would not improve the particular solution that you found for SWAP. Another wrinkle is that there are two shortest geodesics between $$1$$ and $$-1$$ on the unit circle, so that there is more than one optimal geodesic from the identity operator to a unitary operator with $$-1$$ eigenvalues.