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.
As an example, consider the following most general single-qubit state ∣ψ⟩:
Arguably the most famous and most fundamental quantum gates are the Pauli matrices:
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:
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:
For ϕ=π, we recover the Pauli-Z gate.
In general, the action of Rϕ is as follows:
Two common special cases of Rϕ
are ϕ=π/2 and ϕ=π/4,
respectively called S and T:
Finally, we have the Hadamard gateH,
which is defined as follows:
Its action consists of rotating the qubit
by π around the axis (X+Z)/2 of
the Bloch sphere:
Notably, it maps the eigenstates of X and Z to each other,
and is its own inverse (i.e. unitary):
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.
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⟩:
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: