In quantum computing, quantum gates are the equivalent
of classical binary logic gates such as NOT, AND, etc.
Because of the continuous nature of qubits,
the number of possible quantum gates is uncountably infinite,
so we only consider the most important examples here.
One-qubit gates
As an example, consider the following most general single-qubit state ∣ψ⟩:
∣ψ⟩=α∣0⟩+β∣1⟩=[αβ]
Arguably the most famous and most fundamental quantum gates are the Pauli matrices:
X=[0110]Y=[0i−i0]Z=[100−1]
They have the following effect on ∣ψ⟩.
Note that X is equivalent to the classical NOT gate
(and is often given that name),
and Z is sometimes called the phase-flip gate:
X∣ψ⟩=[βα]Y∣ψ⟩=[−iβiα]Z∣ψ⟩=[α−β]
In fact, Z is a specific case of the phase shift gateRϕ,
which modifies the qubit’s phase without changing its amplitudes.
For an angle ϕ, it is given by:
Rϕ=[100eiϕ]
For ϕ=π, we recover the Pauli-Z gate.
In general, the action of Rϕ is as follows:
Rϕ∣ψ⟩=[αeiϕβ]
Two common special cases of Rϕ
are ϕ=π/2 and ϕ=π/4,
respectively called S and T:
S=Rπ/2=[100i]T=Rπ/4=21[2001+i]
Finally, we have the Hadamard gateH,
which is defined as follows:
H=21[111−1]
Its action consists of rotating the qubit
by π around the axis (X+Z)/2 of
the Bloch sphere:
H∣ψ⟩=21[α+βα−β]
Notably, it maps the eigenstates of X and Z to each other,
and is its own inverse (i.e. unitary):
H∣0⟩=∣+⟩H∣1⟩=∣−⟩H∣+⟩=∣0⟩H∣−⟩=∣1⟩
The Clifford gates are a set including X, Y, Z, H and S,
or more generally any gates that rotate
by multiples of π/2 around the Bloch sphere.
This set is not universal, meaning that if we start from ∣0⟩,
we can only reach ∣0⟩, ∣1⟩, ∣+⟩, ∣−⟩, ∣+i⟩∣−i⟩ using these gates.
If we add any non-Clifford gate, for example T,
then we can reach any point on the Bloch sphere,
which means that the set is universal.
However, there is a problem: a qubit has an uncountable infinity of states,
but a quantum circuit consists of a countably infinite sequence of gates, at most.
Therefore, technically, we can never reach the whole Bloch sphere,
but we can come up with circuits that approximate a target state to some degree ε.
This is the definition of universality:
any state can be approximated.
Two-qubit gates
As an example, let us consider
the following two pure one-qubit states ∣ψ1⟩ and ∣ψ2⟩:
Note that a two-qubit system may be entangled,
in which case the coefficients c00 etc. cannot be written as products,
i.e. ∣ψ2⟩ cannot be expressed separately from ∣ψ1⟩, and vice versa.
In other words, the action of a two-qubit gate
can be expressed in the basis of ∣00⟩, ∣01⟩, ∣10⟩ and ∣11⟩,
but not always in the basis of ∣0⟩1, ∣1⟩1, ∣0⟩2 and ∣1⟩2.
With this noted, the first two-qubit gate is SWAP,
which simply swaps ∣ψ1⟩ and ∣ψ2⟩:
SWAP=1000001001000001
This matrix is given in the basis of ∣00⟩, ∣01⟩, ∣10⟩ and ∣11⟩.
Note that SWAP cannot generate entanglement,
so if its input is separable, its output is too.
In any case, its effect is clear:
A set of gates is universal if all possible mappings
from n to n qubits can be approximated using only these gates.
A minimal universal set is {CNOT,T,S},
and there exist many others.