The three U gates, , 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

where and . This demonstrated a one-to-one correspondence between qubit states () and the points on the surface of a unit sphere (). 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 unitary matrix The action of the quantum gate is found by multiplying the matrix representing the gate with the vector representing the quantum state.

A general unitary must be able to take the to the above state and . That is,

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

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

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

The second gate is , which has the form

From this gate, the Hadamard is done by . In IBM Quantum Experience, this is implemented by a pre- and post-frame change and a pulse.

The third gate is , which is just ; it is implemented using three frame changes and two pulses. A demonstration of the gate is shown in the script below. It illustrates how we can use the gate to create an arbitrary state, and the plot shows the projection onto the . A similar thing can be done with and .

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() 