Intro to Quantum Computing (Notes)

advertisement
Introduction to Quantum Computing
[CBPrice Draft1 17th March 2012]
[CBPriceRev5 20th March 2012 10.00]
Introduction
Quantum Computers use atoms or molecules or photons of light to compute. These are all incredibly small
compared to classical objects such as billiard balls or integrated circuits, and so to understand how they are
designed, we need to understand quantum physics rather than classical physics since it is quantum physics
that describes these small entities. There’s some surprising behaviour to be had at this atomic scale as we
shall discover. As an aside, it is possible to compute anything, using billiard balls!
Let’s remind ourselves of a classical computer gate, the NAND gate. This is a fundamental gate since all
computing circuits (the CPU, memory etc.) can be constructed using only NAND gates. Here’s a NAND
gate with its associated truth table which explains how the outputs are generated from all possible inputs.
A
0
0
1
0
B
0
1
0
0
Op
1
1
1
0
This is simple to understand, each input consists of a bit which can either be in the state “1” (on) or “0” (off)
and the output bits are also either 1 or 0. When we are dealing with quantum computers, we also think in
terms of bits, we call these qubits (pronounced “kewbits”), though these are fundamentally different from
classical digital bits. The notation for a qubit is a little strange, the “on” and “off” qubits are represented
using the notation |1⟩ and |0⟩. These strange symbols are called “kets”, they are the right-hand bit of a “braket”. Whenever you see a ket, think qubits! Consider a single input quantum gate, the X-Gate which we
shall discuss shortly. It has a single qubit input and a single qubit output. But there’s something strange
about the output. Whereas the output of a classical gate has to be either 1 or 0, the output of a quantum gate
can be |0⟩ or |1⟩, but it can have any value in between, for example 0.7*|0⟩+0.7*|1⟩. This is really strange.
Even stranger is the fact that when we actually look at the output of the quantum gate, then this in-between
value will “collapse” into either |0⟩ or |1⟩. This will be explained in detail below.
An example may help. Let’s think of a quantum computer built using atoms. An atom can exist, e.g., in two
energy states, low and high. You could get the atom to move from a low to high state of energy in many
ways, you could zap it with a pulse of laser light, or you could put a load of atoms into a box and heat it up.
We could associate the low energy state with the value |0⟩ and the high energy state with the value |1⟩. But
the atom’s energy could be anywhere between the low and high states. Only when we observe the atom does
it jump into either the low or the high energy state. This is illustrated below.
Perhaps another example may help. This is drawn from some of my research into quantum thinking. [To
appear]
The Concept of Base States and Superpositions. A Single qubit.
Just like classical gates must have an output 0 or 1, quantum gates can have an output |0⟩ or |1⟩. These qubit
states are called the base states. But we mentioned that qubits can exist in any in between state. A good way
of representing the state of a qubit is as a position on a circle. This is shown below. The left circle shows the
location of the base states on the circle. State |0⟩ has coordinates (1 0) and state |1⟩ has coordinates (0 1).
These pairs of numbers are called vectors. The right circle shows a qubit |𝜓⟩ in a mixed state, half |0⟩
and half |1⟩. Remember that until we measure the output of a quantum gate, the output qubit’s value may
exist anywhere on the circle.
The coordinates of the mixed state are (𝑥 𝑦) =
1
√2
(1 0) +
1
√2
(0 1) where dividing by the square root of 2
keeps the point on the circle. Using the defined coordinates for the base states, we can write the new state as
a weighted sum of the base states like this
1
(|0⟩ + |1⟩)
|𝜓⟩ =
√2
This in-between state of the qubit is not a base state, we can refer to it as a mixed state. A quantum
computer contains quantum registers just like a classical computer. A classical computer’s registers contain
a load of bits which are binary digits, perhaps 32 or 64. A quantum computer’s register contains a load of
qubits. But of course these are not simple binary digits, since the qubit can be anywhere in between the base
states. So a quantum register does not use binary digits, a single qubit needs two digits to locate its position
on the circle. In fact is the coordinates (vector) of the cubit which is stored in the registers. So here’s the
register contents for the two base states and the mixed state discussed above.
State
|0⟩
Vector
(1 0)
Register
10
|1⟩
(0 1)
01
|𝜓⟩
(1 1)
11
The colors on the right show how our simulator indicates the register contents. You will need to remember
that red is 1, black is 0 and blue is -1.
Single quBit Gates
X-Gate
Let’s have a look at the X-gate. Its implementation in jQuantum is shown in Figure X, with both the input
and output situations depicted.
Here, there is a single qubit input |𝑥⟩ which has the value |0⟩. This a base state. The x-register shows the
initial qubit input |0⟩ with associated vector (1 0)𝑇 in the x-register (red is “1”, black is “0”). Following the
action of the gate, the gate’s output as indicated in the x-register is (0 1)𝑇 which is associated with the state
|𝑥⟩ = |1⟩. So what has the X-gate done? Looking at the register values it is clear that the X-Gate it is
performing the same function as the classical invertor or NOT gate. The qubit has been inverted!
H-Gate
Now let’s have a look at the H-gate (Hadamard gate). This is a single qubit gate which has a rather
interesting and fundamental effect on the input qubit. It is important that you understand the operation of this
gate, since it captures an important part of the essence of quantum computing. This is illustrated in Figure X
showing input and output for one specified input qubit (also shown).
The input qubit chosen here is |1⟩ = (0 1)𝑇 as indicated by the register (black red) values. But the output of
the gate is (red blue). What does this mean? Remember that blue represents -1. So our output register (red
blue) is |𝑥⟩ = (1 −1)𝑇 . This qubit output is a clearly a mixture of the base states |0⟩ = (1 0)𝑇 and |1⟩ =
(0 1)𝑇 ,
|𝑥⟩ =
1
√2
(|0⟩ − |1⟩)
The position of this qubit on the circle is shown below.
The other possible base-state input to the H-gate is which will appear as red – black in the register. The
output of the H-gate is red-red in the register which is the vector (1 1)𝑇 . This is clearly an additive mix of
the two base states
1
(|0⟩ + |1⟩)
|𝑥⟩ =
√2
which appears on the circle as shown above
Again we see that the Hadamard gate mixes a pure base state to produce a superposition of states. This
clearly demonstrates the nature of a qubit, how it differs from a classical bit. The qubit can exist in either of
the two “on-off” base states, but also anywhere in between!
H-Gate followed by an X-Gate
Here’s our first quantum circuit an H-Gate followed by the X-Gate. We know that the H-Gate provides a
mixture of the input base state qubit and we know that the X-Gate inverts an input qubit which is in either of
the base states. So let’s see what happens when the qubit is in a mixed state and is input to the X-Gate.
The diagram on the left shows the qubit in the mixed state |𝑥⟩ = (1 −1)𝑇 entering the X-gate. The output
of the X-gate is again a mixed state with vector |𝑥′⟩ = (−1 1)𝑇 . But look at the components of the two
vectors, they are both inverted! In other words the NOT gate has inverted both components of the qubit at
the same time. This is parallel processing and gives quantum computing its power!
Multiple qubit Gates
Just like a classical register can be made out of n individual bits, you can make a quantum register out of n
qubits. But there’s a difference. In a classical register each bit is separate, but the qubits in a quantum
register may in general exist in a mixed state, until the register is measured. To remind us of this fact we do
not write a the state of a 2-bit register as |0⟩|1⟩, but rather as |01⟩. There are four base states associated with
a 2 qubit system (see Appendix 1) and the register size must now be 4.
The Controlled NOT Gate
This gate is the quantum equivalent of the classical NOT gate which inverts the input (see Appendix 2 for a
reminder of classical gates and their truth tables). The symbol for the controlled not is illustrated below
The top qubit input is called the “target” and the bottom qubit input is called the “control”. If the input on
the control is 1, then the input on the target is inverted. Let’s run this through our simulator. First let’s
consider the input state |01⟩ . The first digit in this ket is the target and the second is the control, so here the
target is 0 and the control is 1. The associated state vector (check Appendix 1) is (0 1 0 0)𝑇 . This situation is
shown in our simulator, below on the left; look at the register and note that the black squares correspond to
the 0’s in the state vector and the red square corresponds to the 1’s.
Now let’s step through the gate and look at its output which is shown above on the right. The register now
holds the value (0 0 0 1)𝑇 which means we are in state |11⟩. The first digit in the ket is now 1, whereas in
the input ket this digit was 0. This digit is the target, so we have inverted the target and therefore have
achieved a NOT gate!
But this gate can actually achieve more than the simple NOT. When we allow both the input qubits to exist
in either base states (four possible inputs) then the output is an XOR (exclusive-or) gate. Here’s the inputs
and outputs and the classical XOR gate behaviour. Look at the leftmost qubit of the output which is the
XOR of the two input qubits.
Input
|00⟩ = |0⟩|0⟩
|01⟩ = |0⟩|1⟩
|10⟩ = |1⟩|0⟩
|11⟩ = |1⟩|1⟩
Output
|00⟩ = |0⟩|0⟩
|11⟩ = |1⟩|1⟩
|10⟩ = |1⟩|0⟩
|01⟩ = |0⟩|1⟩
A
0
0
1
1
B
0
1
0
1
out
0
1
1
0
The Controlled Controlled NOT gate.
This is a three qubit gate which has two control inputs (the lower two) and the target input (the top one),
drawn like this. Note that since we have three qubits, the register needs to have eight states since there are a
possible eight base states for three qubits (see Appendix 1). This CCN gate is sketched below (on the left)
with the input qubit set to the base state |111⟩ = (00000001)𝑇 . On the right you can see the output of the
gate which is |011⟩ = (00010000)𝑇 . The output of the target is 0 which is the NAND gate applies to the
control inputs 1 and 1. Perhaps we have constructed a quantum NAND gate?
Let’s look at the possible inputs to this gate when the input to the target is 1, then we find the following
input and output table.
Input
|100⟩ = |1⟩|0⟩|0⟩
|101⟩ = |1⟩|0⟩|1⟩
|110⟩ = |1⟩|1⟩|0⟩
|111⟩ = |1⟩|1⟩|1⟩
Output
|100⟩ = |1⟩|0⟩|0⟩
|101⟩ = |1⟩|0⟩|1⟩
|110⟩ = |1⟩|1⟩|0⟩
|011⟩ = |0⟩|1⟩|1⟩
A
0
0
1
1
B
0
1
0
1
out
1
1
1
0
It is clear from this table that the target qubit (the leftmost) is actually computing the NAND function of the
two control inputs. To see this look at the middle and right input qubits and the leftmost output qubit. You
should see the NAND function shown in the table on the right for the classical NAND gate. This is an
important result. Remember that all computer components (CPU, memory etc) can be constructed from a
shed-load of NAND gates. This makes the CCN gate universal since we can build an entire quantum
computer out of CCN gates.
Some Quantum Computational Circuits
The Half-Adder
The Qubit Swap Circuit
Meaurement
Let’s say we have a quantum computational circuit which we have designed and where the output qubits are
in a mixed state which reflects the results of our computations. As mentioned above, when we measure the
output qubit, we force the mixed state of the quibit to collapse into one of its base states. Which state does
the qubit choose to collapse into? Well the choice is made randomly, but the probability of collapsing into
base state |0⟩ or base state |1⟩ is determined by the relative amounts of each base state present in the mix.
For example in the case of the H-Gate followed by the X-gate discussed above, the output qubit was |𝑥′⟩ =
(−1 1)𝑇 which can be expressed (when normalised) as
(−1|0⟩ + 1|1⟩)⁄√2
ie
−1
√2
|0⟩ +
1
√2
|1⟩
To get the probabilities of collapsing into each base state, we square the weight of each base state in the mix.
In this case we get ½ for |0⟩ and ½ for |1⟩. So it’s equally likely to collapse into each base state. You can
test this by setting up the following circuit where a measurement gate M-Gate is added to the H-X gate
circuit like this.
When you run this circuit may times (using the two bottom green arrows in jQuantum) then measurement
gate will collapse the qubit into each base state, randomly, but with equal probability, so the number of
times you will each base state will be the same for a large number of runs. This is illustrated using the circle
representation above.
Quantum Computing and Parallel (Multicore) Processing
We have seen that the potential power of quantum computers lies in their ability to process each state of
each qubit in parallel, by processing mixed states. If we have 3 qubits, then one operation on this triple qubit
will in make 8 computations in parallel. The trick is to discover which algorithms can be expressed on a
quantum computer. There are three algorithms of note devised so far: (i) Shore’s algorithm to find the prime
factors of a given number, (ii) Grover’s algorithm to search for a particular number in a data set, (iii)
Deutsch’s algorithm [more here]
Grover’s algorithm.
This algorithm searches a list of numbers for a particular number, to see whether it is present or not. Let’s
take an example to search all the numbers in the range 0 to 255 for the number 151. Here we start with a
quantum register consisting of 8 qubits (needed for 256 numbers) and start with an initial state |𝑥⟩ =
|00000000⟩. We then take the Quantum Fourier Transform of this base state. Think of this as producing a
mixed state where all numbers are represented with equal weights. We then apply several Grover-Gate
operations. Each of these operations amplifies the searched value and weakens all other values. Finally we
apply a measurement gate M-Gate to collapse the mixed state into one of the 28 base states, which should be
the number we are searching for if it exists in the original data set. Here’s the situation shown in jQuantum.
Check out that you can identify the initial base state, The F-Gate, the G-gates and the final M-gate.
Here’s how the x-register changes with time when the quantum circuit is stepped through each stage
Initial State
after F-Gate
after 5 G-Gates
after 12 G-Gates
after M-Gate
You can clearly see the action of the F-Gate is to spread out the initial base state into a mixed state where all
values of the quantum register are equal, in other words all integers between 0 and 255 are present in the
original data set. Then you can see how the G-Gate selectively amplifies the value of the sought number
(151) in the mixed state. Finally the M-Gate collapses the mixed state and pulls out the number sought after.
What is the point of searching for a number in this way? The answer is speed. If you are searching a data set
of 256 numbers, then a classical search would involve scanning the data set element by element until your
sought number is found. This could take a maximum of 256 operations. Now look at the Grover circuit.
There are 12 G-Gates, one F-Gate and one M-Gate. That is 14 operations, which is significantly less than
256. This reduction in operations is due to the parallel processing possible on the mixed quantum states. It
has been shown that to search a list of N numbers requires an order of N operations, while the Grover
algorithm requires an order of √𝑁 operations. For N = 256, √256 = 16. For N = 1 million, √𝑁 = 1
thousand. That is a significant speedup!
Appendix 1. Base States, Vectors and quComputer Registers
A single qubit system has two base states which we write |0⟩ and |1⟩ with associated vectors
|0⟩ = (1 0)𝑇
|1⟩ = (0 1)𝑇
For a two qubit system we have four base states which we write |00⟩, |01⟩, |10⟩, |11⟩. The associated
vectors are
|00⟩ = (1 0 0 0)𝑇
|01⟩ = (0 1 0 0)𝑇
|10⟩ = (0 0 1 0)𝑇
|11⟩ = (0 0 0 1)𝑇
Finally, for a three qubit system we have eight base states with associated vectors
|000⟩ = (1 0 0 0 0 0 0 0)𝑇
|001⟩ = (0 1 0 0 0 0 0 0)𝑇
|010⟩ = (0 0 1 0 0 0 0 0)𝑇
|011⟩ = (0 0 0 1 0 0 0 0)𝑇
|100⟩ = (0 0 0 0 1 0 0 0)𝑇
|101⟩ = (0 0 0 0 0 1 0 0)𝑇
|110⟩ = (0 0 0 0 0 0 1 0)𝑇
|111⟩ = (0 0 0 0 0 0 0 1)𝑇
The vectors for multiple quibit systems are generated from the two single qubit systems by forming the
tensor product of the associated vectors. This is quite a messy maths operation, so we shall not explain it
here.
Download