The qubit, the fundamental unit of the quantum computer, the analog of the basic 1/0 bit in the classical computer. How to build it?
Well there are many ways to do that. You could do it with electrons, photons or a number of more exotic things. For example, consider an electron in a magnetic field. Every electron has a magnetic moment which comes from its quantum spin. Now this spin can be either aligned along the magnetic field (spin up) or opposite to the field (spin down). These 2 states would correspond to the 2 states of the qubit. Similarly, the polarization of a single photon can represent a qubit with its 2 states represented by horizontal and vertical polarization.
The key thing is that regardless of the hardware building the qubits, the behavior of all these ways are identical. So, let us look at that.
Now, a normal bit (think of the electronic registers on a computer chip or the magnetic regions on your hard disk) can store a 0 or a 1. So when we read what is stored in that bit, we get a 0 or a 1. A qubit also has 2 states denoted as |0> and |1> (we won’t delve into this notation here). When we measure the state of the qubit, we will only see one of these states, a |0> (corresponding to spin down or horizontal polarization in above examples) or a |1> (corresponding to spin up or vertical polarization in above examples).
So, let’s say we do a computation and read out the qubit and see that it is |0>. If we repeat the same computation again, it is not necessary that the qubit will be in |0> state. In fact, if we do the computation many times, we may see that some fraction of the time, we get |0> and some fraction of the time we get |1> state.
The qubit is therefore considered to be in a superposition of the 2 states. What this means is that upon measurement, we can get either of the 2 states with certain probabilities. Let us say that 64% of the time, we see |0> state on measuring the qubit and 36% of the time, we see |1>.
We can then represent the qubit in being in a superposition of |0> and |1> states. We can also sat that the probability amplitude (square root of probability) of the qubit along |0> state is 0.8 (0.8 = square root of 0.64) and the probability amplitude along |1> is 0.6 (0.6 = square root of 0.36).
This is written as:
0.8|0> + 0.6|1>
Note that these 2 numbers (0.8 and 0.6) represent everything we want to know about the qubit. The state of the qubit is captured by just these 2 numbers. But there are a few catches:
- The two numbers can be complex. So a qubit’s state can generally be represented as a|0> + b|1> where a and b are complex numbers.
- The square of the magnitude of the 2 complex numbers (|a|2 and |b|2) gives the probability of seeing the states |0> or |1> upon measurement.
- The numbers a and b must satisfy the constraint |a|2 + |b|2 = 1. This is just another way of saying that the sum of the probabilities of it being in one of the 2 states is 1.
Ok, so we have a qubit, that is something with a state that is represented as a|0> + b|1>, now what do we do with it?
With a normal bit, we could pass it through a gate to manipulate its value. We could combine 2 bits in an AND, OR or XOR gate or we could use a NOT gate and just flip a bit’s state from 0 to 1 or vice versa. For a qubit, there are quantum gates which change the state of the qubit.
Lets take an example of the Hadamard Gate. This is a gate which takes a quantum bit in the |0> state and puts it in the state (|0>+|1>)/sqrt(2)
Here sqrt() represents the square root.
Similarly, if a bit with the |1> state is passed through it, it comes out in the state (|0>-|1>)/sqrt(2).
|0> -> (|0>+|1>)/sqrt(2)
|1> -> (|0>-|1>)/sqrt(2)
To make sense of what this means, lets say we pass the bit we saw earlier through a Hadamard gate.
0.8|0> + 0.6|1>
Now, the input bit has the 1st term as 0.8|0>, and since a Hadamard gate converts |0> to (|0>+|1>)/sqrt(2), so this term become 0.8(|0>+|1>)/sqrt(2) when it comes out of the gate.
The 2nd term is 0.6|1>. THe Hadamard gate turns |1> into (|0>-|1>)/sqrt(2). So at the output, this term results in 0.6(|0>-|1>)/sqrt(2). This means the sum of both terms at the output is
0.8(|0>+|1>)/sqrt(2) + 0.6(|0>-|1>)/sqrt(2).
Lets open the brackets and simplify
(0.8|0> + 0.8|1> + 0.6|0> – 0.6|1>)/sqrt(2)
(1.4/sqrt(2)) |0> + (0.2/sqrt(2)) |1>
Thus if we feed a Hadamard gate with a qubit with the state (0.8|0> + 0.6|1>), it comes produces a qubit with the state ((1.4/sqrt(2)) |0> + (0.2/sqrt(2)) |1>). Note that if we measure the output bit, we are now 1.4*1.4/(0.2*0.2) = 49 times more likely to see a |0> state than a |1> state whereas earlier the ratio was 64/36 for getting |0> to |1>.
Also note that the output vector obeys the rule, |a|2 + |b|2 = 1.
|a|2 = 1.4*1.4/2 = 0.98
|b|2 = 0.2*0.2/2 = 0.02
1.4*1.4/2 + 0.2*0.2/2 = 1
The symbol for a Hadamard Gate
[Note: This post is part of my attempt to understand quantum computing and consciousness. I’ll stop here for now. Next time, quantum entanglement.]