I know that the two qubit gate generated by $H=X\otimes X$ is $\exp\{-\text{i}\theta X\otimes X\}=\cos{\theta} \mathbb1 \otimes \mathbb1 - \text{i} \sin{\theta} X \otimes X$, where $X$ is the $\sigma_x$ Pauli matrix. Now, if we moved to the Hamiltonian $H= X\otimes X + Y \otimes Y + Z \otimes Z$, how can we find the two qubit gate?


2 Answers 2


TL;DR: The two-qubit gate corresponding to the Hamiltonian is the SWAP gate.

For an operator $A$ that squares to identity $A^2=I$, we have $e^{i\theta A} = I\cos\theta +iA\sin\theta$. In our case the Hamiltonian does not square to identity

$$ (X\otimes X + Y\otimes Y + Z\otimes Z)^2 \ne I\otimes I. $$

However, we can tweak it by adding a constant term since this only affects the unobservable global phase. We note that

$$ \frac{I\otimes I + X\otimes X + Y\otimes Y + Z\otimes Z}{2} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix} = \text{SWAP} $$

does square to identity. Thus, we can write

$$ \exp\left(-\frac{i\gamma}{2}(I\otimes I + X\otimes X + Y\otimes Y + Z\otimes Z)\right) = I\cos\gamma -\text{SWAP}\, i\sin\gamma $$

which means that the Hamiltonian generates the fractional SWAP gate

$$ \exp\left(-\frac{i\gamma}{2}(X\otimes X + Y\otimes Y + Z\otimes Z)\right) = e^{\frac{i\gamma}{2}}(I\cos\gamma -\text{SWAP}\, i\sin\gamma). $$

When $\theta=\frac{\gamma}{2}=k\frac{\pi}{4}$ and $k$ is an odd integer then the evolution swaps the two qubits and when $k$ is an even integer then it acts as identity.

If SWAP is unavailable, the evolution generated by the Hamiltonian can also be implemented for example using two CNOTs and a controlled rotation

$$ \exp\left(-\frac{i\gamma}{2}(X\otimes X + Y\otimes Y + Z\otimes Z)\right) \\= C_2NOT_1 \circ C_1R_{2,x}(2\gamma) \circ (R_{1,z}(\gamma) \otimes I_2) \circ C_2NOT_1 $$

where we also use an $R_z$ gate to correct the phase of the central $2\times 2$ block of the matrix.

  • 1
    $\begingroup$ Very nice!! I like this approach. $\endgroup$
    – KAJ226
    Mar 19, 2021 at 2:08

Perhaps not surprisingly, the gate is $\exp(-i \theta (X \otimes X + Y \otimes Y + Z \otimes Z))$.

More usefully, the terms that are being summed happen to commute so you can decompose the problem into $\exp(-i \theta X \otimes X) \cdot \exp(-i \theta Y \otimes Y) \cdot \exp(-i \theta Z \otimes Z)$.

import cirq
from cirq import X, Y, Z
import math

theta = math.pi / 6
a, b = cirq.LineQubit.range(2)
xx = math.e**(-1j * theta * X(a)*X(b))
yy = math.e**(-1j * theta * Y(a)*Y(b))
zz = math.e**(-1j * theta * Z(a)*Z(b))
print(cirq.unitary(cirq.Circuit(xx, yy, zz)).round(4))
[[0.866-0.5j  0.   +0.j   0.   +0.j   0.   +0.j  ]
 [0.   +0.j   0.433+0.25j 0.433-0.75j 0.   +0.j  ]
 [0.   +0.j   0.433-0.75j 0.433+0.25j 0.   +0.j  ]
 [0.   +0.j   0.   +0.j   0.   +0.j   0.866-0.5j ]]
  • $\begingroup$ the operators don't commute. $\endgroup$
    – Nehad
    Mar 18, 2021 at 20:10
  • 6
    $\begingroup$ @Nehad @FaiyaxHasan No, the operators just commute. XX, YY, and ZZ all commute with each other. The fact that they commute is an important foundational reason that quantum error correction is possible. import cirq; a, b = cirq.LineQubit.range(2); assert cirq.commutes(cirq.X(a)*cirq.X(b), cirq.Y(a)*cirq.Y(b)). $\endgroup$ Mar 19, 2021 at 0:06
  • 1
    $\begingroup$ +1 @CraigGidney is right. $X\otimes X$ commutes with $Y\otimes Y$ because $X$ anticommutes with $Y$. Similarly for other pairs of Paulis. $\endgroup$ Mar 19, 2021 at 1:25
  • 1
    $\begingroup$ That's really nice. I hadn't realized this before. Then it seems that in general, if you have an even n, $\otimes_{i=1}^{n} X$ will commute with $\otimes_{i=1}^{n} Y$, since the negative signs from the anticommutation relation cancels. $\endgroup$ Mar 19, 2021 at 11:35

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.