Simply explained, quantum computing consists of manipulating qubits and then measuring the outcome after applying gate transformations to them. Any manipulation of a qubit must be performed by a unitary operator in order for it to be implemented on a quantum computer.
What is a unitary operator?
A unitary operator can be represented as a matrix, in which its conjugate transpose is equal to its inverse, also written in the following form where I is the identity matrix:
The quantum gates must be unitary as these kinds of operations are reversible and preserve normalisation of the quantum states, allowing the states to remain on the surface of the Bloch sphere after the transformation (which we’ll see shortly).
Here, I will introduce the basic unitary operators used in quantum computing, outlining the mathematical operations, visualisation of their effect on the Bloch sphere as well as how they can be implemented on a quantum computer.
The simplest unitary gate is the Pauli X gate, which performs a bit flip operation, similar to the classical NOT gate. Its matrix representation is as follows:
When the X transform is applied to the standard basis, the results are simply the inverse of what was input.
This gate performs a rotation about the x axis by π radians, which is seen on the following Bloch sphere when applied to 0 basis state.
The circuit to implement the X transform consists of only the gate itself and a measurement gate. You can click on the circuit to go to the IBM Q composer where you can run the circuit on a quantum computer/simluator and view the results.
In contrast to the X gate, the Z gate is a phase flip operator, with no corresponding classical gate. It is represented in matrix form as:
Applying the Z gate to |0〉 and |1〉, we see that the gate has no effect on the |0〉 state and simply adds a negative sign in front of the |1〉 state:
The effects of the Z gate can be seen when applied to the |+〉 state in the following visualisation, where a rotation of π about the z axis occurs. After the transformation, the final state is |-〉, and when measured, still has an equal probability of being 0 or 1. The Z gate performs a rotation of π radians around the z axis.
The first circuit below executes the Z gate on a |0〉 state, and the second circuit on the superposition |+〉 state:
The Y gate can be written as the following matrix however can also be thought of as an execution of the X and Z gates consecutively.
Below, we apply the matrix representation as well as the X and Z combination to the |0〉 and |1〉 states to demonstrate that they yield the same result.
As implied in these calculations, the difference between the X and Y operations is simply just the phase (an additional Z transformation). The Y gate performs a π radian rotation about the Y axis.
The first circuit below is simply the Y gate operation and the second corresponds to the rotation witnessed in the animation above, where there is a 50/50 split of 0 and 1 recordings.
The Hadamard gate is extremely important as it is used to create states of superposition and is represented by the following matrix:
Performing a Hadamard transformation on a qubit creates a state of equal superposition between the two basis states, meaning that only when you choose to measure the qubit will its state be determined. This can be seen in the results from the circuit below: half of the shots will measure 0 and the other half as 1.
Applying the Hadamard operation on the |0〉 and |1〉 states result in the formation of a new superposition basis: |+〉 and |-〉.
The following animation illustrates two consecutive Hadamard transformations which equates to two rotations about the (x+z)⁄√2 axis by π radians. After the first, the position of the vector lies along the x axis at |+〉 and after the second transformation, the vector is back to where it started, which is what we expect.
This introduction has only scratched the surface of unitary operations used in quantum computing. There exists a plethora of gates that are far more complex or operate on multiple qubits at once, and altogether these allow for the development of many incredibly useful algorithms.
For more learning and developing resources for quantum computing see the awesome list.