The s and s in classical computers are fairly useless by themselves. In order to represent meaningful computation we need to be able to manipulate them.
We achieve this using logic gates. The most simple logic gate is the gate which inverts the input sending → and → .
We can better represent the operation of this gate with something called a truth table. This is a table that shows all possible inputs and their corresponding outputs. For the gate this would look like:
A | NOT A |
---|---|
0 | 1 |
1 | 0 |
For the NOT gate this is fairly simple, but we will find this representation more useful as we introduce more gates later.
In order to represent more complicated circuits without needing crazy mathematical formula to solve, we have special symbols assigned to each gate that can be used in a circuit diagram. The gate is represented as:
From this one gate we can build a very simple circuit such as:
In circuit diagrams like this we can think of the bits as "flowing" from left to right. So in the above circuit we would read it as "apply the gate to the input, then apply another gate to the output of the first gate". Clearly this circuit implements the identity operation. That is, the operation that takes → and → .
A little thinking shows us there are only 4 possible single bit gates. The gate that we have already seen, the identity gate that we described above, a gate that maps all inputs to and a gate that maps all inputs to .
Just like in classical computation, we will have gates that allow us to manipulate qubits. Quantum gates are the quantum equivalent of classical logic gates. They take qubits as input and produce qubits as output. We can use these gates to perform complex algorithms and computations just like we can with their classical counterpart.
Now remember how we said our qubits will be represented as vectors? Well we know we can act on vectors with operators. We will use these operators to represent our gates!
Since qubits are more than just classical bits, we have a slightly more interesting set of single qubit gates to study. We've already seen some of these linear operator gates in a previous article, let's restate them here:
We will represent these gates in circuit diagrams very similar to the way we represent classical gates. For example a circuit where we apply the X gate followed by a Z gate would look like:
Note that quantum circuits can be a bit confusing since the mathematical definition of this circuit is and not . This is because we read circuits from left to right but apply operators from right to left.
Let's introduce a new single qubit gate we haven't seen before: the Hadamard gate (named after the mathematician Jacques Hadamard). This gate is useful for creating superpositions. It takes → and →.
We can define the Hadamard gates in terms of an outer product:
Sometimes it can be helpful to factor the bras out from the kets for operators like this:
This is a useful representation as it more clearly shows us what happens to the basis states.
Prove that the hadamard gate is its own inverse.
In other words show that .
Show that
Prove that the vectors and form an orthonormal basis for the single qubit state.
To recap that requires us to prove the following: