# How can I implement this unitary operation using CNOT and single qubit gates?

How can I implement the following unitary operation using CNOT and single qubit gates?

$$U =\begin{bmatrix}1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & e^{i \theta} \end{bmatrix}$$

• This looks like a CU1 gate -> qiskit.org/documentation/stubs/… . Its closely related to the controlled-Rz or CRz gate Commented Sep 8, 2023 at 22:33

As I mentioned in the comments the gate is a CU1 gate. For ease of visualisation I've used $$\theta=2a$$ as the rotation angle.

This $$\mathrm{CU1}$$ gate is equivalent to a controlled-Rz up to a global phase. An Rz gate is defined to be equal to $$\exp\big(-\frac{i a}{2} Z\big)$$ where $$Z$$ is the Pauli $$Z$$ operator.

A $$\mathrm{CU1}(2a)$$ can be decomposed into the following CX and Rz operations.

If we remove the Rz from the q[0] control qubit we have an implementation of Controlled-Rz instead of CU1.

To see that this is correct consider what happens when the control qubit is in the $$|0\rangle$$ or $$|1\rangle$$.

If the control qubit is $$|0\rangle$$ the first Rz will leave the state unchanged. The CX gates will also not flip the target qubit and the opposing Rz rotations on the q[1] target qubit will cancel out.

Can you work out what happens when the control is in the $$|1\rangle$$ state?