In our previous article Introduction to quantum computing, we saw that the real value of quantum computing lies in the fact that a quantum system can do processing while the qubits are in a superposition state. Hence, the operations defined by the quantum algorithms do not manipulate by example just 3 bits, they manipulate 23 probability values. One step in a quantum algorithm on a quantum computer with 3 qubits is therefore modifying 8 values. Adding one qubit doubles the processing capabilities of the quantum computer. This explains the term "exponential" that is often used together with quantum computing: adding N qubits adds processing power proportional to 2N .
If it should be clear by now that a quantum computer allows some kind of parallel processing, what does we mean more precisely by processing a qubit?
In classical computing, all the operations finally come down to a sequence of simple manipulations of the bits in the computer systems. Those low-level operations are achieved using gates. It can be shown that with a limited number of gates, all possible scenarios can be achieved.
A very simple classical gate is the NOT gate, also known as the inverter.This gate has one input bit, and one output bit. The output bit of the gate is the inverse of the input bit. If the input is "0", the output will be "1". If the input is "1", the output will be "0".
The behavior of gates is often explained via simple tables where the possible combinations of input bits are listed, and the resulting output is listed in the last column. The following table shows the behaviour of the NOT gate
When the input of the gate is '0', the output is '1'. When the input of the gate is '1', the output is '0'.
The NOT gate involves a single bit only, but other gates involve more bits. The XOR (or EXOR) gate , for example, takes the input of 2 bits, and outputs a value that is '1' in case exactly one of the 2 input bits is 1 and the other is '0'.
If we want to process data in quantum computing, we have to use gates as well. Quantum gates are the building blocks of quantum circuits, like classical logic gates are for conventional digital circuits.
But unlike many classical logic gates, quantum logic gates sould be reversible. That is, it should always be possible to apply another gate and go back to the state of the system before the first gate was applied. This restriction does not apply on classic gates. For example, the XOR gate is not reversible. If the result of an XOR gate is '1', it is impossible to know whether the first bit was '0', or whether it was the second bit.
In this article, we will only focus on quantum gates applying to single bits. We will present the quantum equivalent of the XOR gate in a later article, C-NOT gate, Bell State and Entanglement.
The Pauli-X Gate
The quantum equivalent of the NOT gate for classical computers is called the Pauli-X gate. It acts on a single qubit. If the qubit is in |0> or |1> states, the Pauli-X gate flips its value of |0> into |1> and vice and versa.
If we represent the two pure state |0> and |1> as two points opposite along the vertical axis
applying the Pauli-X gate is equivalent to a rotation of the state of the qubit of 180 degrees. Due to this nature, it is sometimes called the bit-flip.
As in classical computing, each quantum gate is represented by a symbol; below is how we usually represent the Pauli gate
Remark: We see immediately that this operation is reversible as applying twice a 180° rotation along the same axis leaves the state invariant.
Mathematical speaking, applying a quantum gate equates to manipulate a linear operator U in the form of a matrix.
For a single qubit, the operator is simply a 2 × 2 matrix.
The matrix representation of the Pauli-X gate, i.e the Pauli-X matrix is the following 2x2 matrix:
When applied to the pure states |0> and |1>, we see easily that |0> become |1> and vice-versa:
When applied to a mixed state |Φ> = α|0> + β|1> then applying the Pauli-X gate to the qubit equats to multiply the Pauli-X matrix to the vector of components α and β in the basis |0> and |1>
the components of the vector are swapped.
It can be shown that every qubit superposition state can be represented as a point on the surface of a unit sphere called the Bloch Sphere.
We thus understand why the Pauli-X gate is so called as we observe easily that flipping from state |0> to |1> can be visualized as a rotation around the X-axis.
More generally, if we define in spherical coordinates the angle θ as the traditional colatitude with respect to the z-axis (0≤θ≤π) and φ as the longitude with respect to the x-axis (0≤φ≤2π), we verify easily that for each point on the Bloch Sphere, the qubit state can be written as:
If the qubit is in the pure |0> state, the qubit is at the very top of the sphere, i.e. θ=0 and φ=0 and we verify that |0> = cos (0/2)|0> + sin (0/2) |1> = |0>
If the qubit is in the pure state |1>, the qubit is at the very bottom of the sphere, i.e.θ=180° and φ=0 and we verify that |1> = cos (90°)|0> + sin (90°) |1> = |1>
Remark: to be perfectly exact, it turns out that an arbitrary single qubit state can be written as eiγ times the above |state> expression. However, qubit states with arbitrary values of γ are all represented by the same point on the Bloch sphere because the factor of eiγ has no observable effects, and we can therefore effectively omit this term.
The Pauli-Y gate acts on a single qubit. It equates to a rotation around the Y-axis of the Bloch sphere by π radians. It maps |0> to i|1⟩ and |1⟩ to −i|0⟩. On the Bloch sphere i|1> will be the same point as |1> as per above remark (i|1> = eiγ|1> with γ=π/2) and -i|0> will have the same representation as |0> (-i|0> = e-iπ/2|0>)
The matrix representation of the Y gate is the following
When applied to a mixed state |Φ> = α|0> + β|1> the Pauli-Y gate gives Y|Φ> = Y(α|0> + β|1>) = -iβ|0> + iα|1>
The Pauli-Z gate acts on a single qubit as well. It equates to a rotation around the Z-axis of the Bloch sphere by π radians. It leaves the basis state |0> unchanged and maps |1> to −|1>.
The matrix representation of the Z gate is the following
When applied to a mixed state |Φ> = α|0> + β|1> the Pauli-Z gate leads to Z|Φ> = Z(α|0> + β|1>) = α|0> - β|1>.
Hadamard gate, the gate to superposition
Let's see what is happening if our qubit sits at the position with an angle of θ = π/2 and φ=0 (or in cartesian coordinates x=1, y=0, z=0).
Replacing the values in the above equation, the qubit state expands as:
We get a superposition state 1/√2(|0> + |1>) with equal weight of the computational basis states.
Applying the Hadamard gate to a qubit that is in state |0> brings the qubit in a |0> and |1> superposition state where the probability of measuring 0 is equal to the probability of measuring 1 (and equals to 1/√22=1/2)
Similarly, applying the Hadamard gate to the down state |1> brings the qubit to the superposition state 1/√2(|0> - |1>).
This is easy to spot when we write the Hadamard gate in its matrix form:
When applying this gate to the basis vectors |0> and |1>
Remark 1: we can verify easily that applying twice the Hadamard gate is a reversible process: if we apply the gate again on each of the previous state, it goes back to the original state again.
Remark 2: The circuit diagram symbol for the Hadamard gate is shown below:
Remark 3: We can use a Quirk, a terrific browser-based tool for experimenting with quantum circuits. It has a drag and drop interface, built-in support for many common gates, and the ability to easily share circuits by URL.
This is how the Hadamard gate applied to one qubit looks like in this environment. We verify that there is 50% of probability to measure the eigenvalue 0, corresponding to |0> eigenstate and 50% of probability to measure 1, corresponding to |1> state.
 Each probability is the probability that the state of the composed system collapses to one of the eight orthonormal basis vectors of the tensor product of the three qubit subsystems.
For quantum operators to be reversible in both directions, no information can be lost. Therefore, both the input and output must have the same number of qubits.
These two states are commonly refered to as |+⟩ and |-⟩ and on the Bloch sphere, they are located on the equator (respectively θ=π/2, φ=0 and θ=π/2, φ=π).