Advanced single-qubit gates

The three U gates, \{u1,u2,u3\} , are three physical single-qubit gates of IBM Quantum Experience that take in one, two, and three parameters respectively. These are the main single-qubit gates; the others we have mentioned are just special cases of these.

Another convenient representation of a single-qubit state is

\begin{split}|\psi\rangle = \cos(\theta/2)|0\rangle + \sin(\theta/2)e^{j\phi}|1\rangle,\end{split}

where 0 \leq \phi <2\pi and 0\leq \theta \leq \pi . This demonstrated a one-to-one correspondence between qubit states ( \mathbb{C}^2 ) and the points on the surface of a unit sphere ( \mathbb{R}^3 ). This is called the Bloch sphere representation of a qubit state (which will be discussed later).

As mentioned before, single-qubit gates are represented by a 2\times 2 unitary matrix U. The action of the quantum gate is found by multiplying the matrix representing the gate with the vector representing the quantum state.

\begin{split}|\psi'\rangle = U|\psi\rangle\end{split}

A general unitary must be able to take the |0\rangle to the above state and U^\dagger U = I . That is,

\begin{split}U = \begin{pmatrix} \cos(\theta/2) & -e^{j\lambda}\sin(\theta/2) \\ e^{j\phi}\sin(\theta/2) & e^{j\lambda+j\phi}\cos(\theta/2) \end{pmatrix}.\end{split}

This is the most general form of a single-qubit unitary.

The first physical gate, u1 , is the phase gate, and is given by

\begin{split}u1(\lambda) = U(0,0,\lambda) = \begin{pmatrix} 1 & 0 \\ 0 & e^{j\lambda} \end{pmatrix}.\end{split}

This gate allows us to program a continuous quantum phase \lambda . In previous sections the T , T^\dagger , S , S^\dagger , and Z are made using this gate. In IBM Quantum Experience, this is implemented as a frame change, and takes zero time.

The second gate is u2 , which has the form

\begin{split}u2(\phi,\lambda) = U(\pi/2,\phi,\lambda) = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 & -e^{j\lambda} \\ e^{j\phi} & e^{j\lambda+j\phi} \end{pmatrix}.\end{split}

From this gate, the Hadamard is done by H= U_2(0,\pi) . In IBM Quantum Experience, this is implemented by a pre- and post-frame change and a X_{\pi/2} pulse.

The third gate is u3 , which is just u3(\theta,\phi,\lambda) = U(\theta,\phi,\lambda) ; it is implemented using three frame changes and two X_{\pi/2} pulses. A demonstration of the u3 gate is shown in the script below. It illustrates how we can use the u3 gate to create an arbitrary state, and the plot shows the projection onto the |0\rangle . A similar thing can be done with u1 and u2 .

Qiskit example

# example_u3.py
import numpy as np
import matplotlib.pyplot as plt

from qiskit import QuantumCircuit, execute, Aer

# Build the circuits
circuits = []
middle = QuantumCircuit(1, 1)
meas = QuantumCircuit(1, 1)
meas.barrier()
meas.measure(0, 0)
exp_vector = range(0,50)
exp_theta = []
theta = 0.0
for exp_index in exp_vector:
    delta_theta = 2*np.pi/len(exp_vector)
    theta = theta + delta_theta
    exp_theta.append(theta)
    middle.u3(delta_theta,0,0,0)
    circuits.append(middle + meas)

# Execute the circuits
shots = 1024
job = execute(circuits, backend = Aer.get_backend('qasm_simulator'),
              shots=shots, seed_simulator=8)
result = job.result()

# Plot the result
exp_data = []
exp_error = []
for exp_index in exp_vector:
    data = result.get_counts(circuits[exp_index])
    try:
        p0 = data['0']/shots
    except KeyError:
        p0 = 0
    exp_data.append(p0)
    exp_error.append(np.sqrt(p0*(1-p0)/shots))

plt.errorbar(exp_theta, exp_data, exp_error)
plt.xlabel('theta')
plt.ylabel('Pr(0)')
plt.grid(True)
plt.show()
../../_images/advanced-single-qubit-gates_0_0.png