# Calculate $\sqrt{X}$ for the Pauli $X$ gate

I was trying to build a $$cccx$$ gate. According to this paper by Berenco et al., it requires a $$\sqrt{X}$$ gate. Furthermore, I found another paper by Muradian and Frias with this formula:

$$\sqrt A=\frac{1}{\sqrt{2i}}(iI+A).$$

From this I calculated $$\sqrt{X}$$, $$\sqrt{X} = \begin{bmatrix}{\frac{2+i}{2}}&{\frac{-i}{2}}\\{\frac{-i}{2}}&{\frac{2+i}{2}}\end{bmatrix}$$

I am not sure about the result at all! I used MATLAB to determine the fourth power of $$\sqrt{X}$$ matrix, but it doesn't give $$X$$ matrix. Also, I am confused because there should be four matrices, and I don't know how to implement them in Qiskit either.

• You used their Eq. (9) to compute the square root twice. This is not valid. This equation only holds for a self-inverse $A$, aka it only applies when $A^2=I$. That is true of $X$, but it is not true of $\sqrt{X}$, so you can't use Eq. (9) the second time to get the forth root. You instead need to directly use their Eq. (7). Apr 28, 2022 at 18:44
• Thanks! I guess I have found the solution! Apr 28, 2022 at 18:48
• @JahanClaes is eqn. (7) of Muradian and Frias really valid for $\sqrt X$, where we know that $\sqrt X^4=\mathbb I$? Muradian and Frias state that eqn. (7) is for self-inverse gates ($A^2=\mathbb I$), but I think, naively, the relation between $A$ and $e^{f(A)}$ is slightly different when $A^2\ne\mathbb I$ but $A^4=\mathbb I$. Apr 29, 2022 at 14:54
• @MarkS Eq. (7) is for self-inverse gates, but it is a formula for the $n$th root. So use $n=4$ on $X$, not $n=2$ on $\sqrt{X}$. Apr 29, 2022 at 17:35
• Got it. Thanks! But can Eq. (7) be generalized to other operators such as any old arbitrary fourth root of $I$? For example, a quarter-turn clockwise (or counterclockwise) rotation of a square? Apr 29, 2022 at 17:56

There are a couple of ways that you might do this calculation directly. I'd start by finding the spectral decomposition of $$X$$: $$X=|+\rangle\langle +|-|-\rangle\langle -|=e^{i0}|+\rangle\langle +|+e^{i\pi}|-\rangle\langle -|.$$ The fourth root of the operator is just the same thing but replacing the eigenvalues with their fourth roots: $$\sqrt{X}=e^{i0/4}|+\rangle\langle +|+e^{i\pi/4}|-\rangle\langle -|.$$ So, as a matrix, this is $$e^{i\pi/8}\left(\begin{array}{cc} \cos\frac{\pi}{8} & -i\sin\frac{\pi}{8} \\ -i\sin\frac{\pi}{8} & \cos\frac{\pi}{8} \end{array}\right).$$