# 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?

## 1 Answer

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(SWAP)$. $$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(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!) – meowzz 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). – DaftWullie 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. – DaftWullie 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! – meowzz Jul 18 '18 at 11:00