3.3.2 CNOT and Multi-Qubit States
So far we have only considered a single qubit. The complex vector space of an n qubit system has a dimension equal to 2n which we denote C2n. The standard basis is the set of all binary strings for k∈{0,2n−1}. For example, the basis for 2 qubits is {|00⟩,|01⟩,|10⟩,|11⟩}; for 3 qubits, {|000⟩,|001⟩,|010⟩,|011⟩,|100⟩,|101⟩,|110⟩,|111⟩}; and for 4 qubits, {|0000⟩,|0001⟩,|0010⟩,|0011⟩,|0100⟩,|0101⟩,|0110⟩,|0111⟩,|1000⟩,|1001⟩,|1010⟩,|1011⟩,|1100⟩,|1101⟩,|1110⟩,|1111⟩}.
The number of terms increases exponentially. You can write them all out for five qubits (there will be 32 terms). Try writing them all out for 64 qubits! (This is like the famous wheat and chess board problem.) This exponential increase is one of the reasons why a quantum system is impossible to simulate on a conventional computer, but it is not simply because the number of terms grows exponentially.
A classical computer that has n -bits also has 2n possible configurations. However, at any one point in time, it is in one and only one of these configurations. For example, a classical computer takes an n bit number, say 00000, and performs operations on it, mapping the input though an n -bit intermediate state such as 00001, which is then output as an n -bit number 10101. Interestingly, the quantum computer also takes in an n -bit number and outputs an n -bit number; but because of the superposition principle and the possibility of entanglement, the intermediate state is very different. To describe it requires 2n complex numbers, giving a lot more room for maneuvering.
As an example, try running the "Random Classical Circuit" we have provided below. It takes the initial state |0⟩⊗n and it should produce the output |10101⟩. By using X operations (NOTs) you can take the |0⟩⊗n to any classical state. Test it out!
To do interesting things in the quantum world, we need gates that perform conditional logic. The conditional gate we have provided is the Controlled NOT, or CNOT. It is represented by the element
The CNOT gate's action on classical basis states is to flip (apply a NOT or X gate to) the target qubit if the control qubit is |1⟩; otherwise it does nothing. The CNOT plays the role of the classical XOR gate, but unlike the XOR, it is a two-output gate in order to be reversible (as all quantum gates must be). It is represented by the matrix
Try the "CNOT Circuits" below with different input states. Note that the X gates have prepared the qubits in a different configuration for each example. Here you can see the results we got when we ran these experiment on the processor:
Finally, many quantum algorithms use the Hadamard gate as the first step because they map n qubits prepared in state |0⟩⊗n to a superposition of all 2n orthogonal states with equal weight. Try out the five qubit version. You should see that it has made a quantum sphere that points in all directions with a small weight 1/(25). Try adding the CNOT gate and making your own new complicated quantum states. In the next sections we will show you examples of how quantum computers take advantage of strange states known as entangled states.
EXERCISE 1. Random Classical Circuit
Run the above random classical circuit using cache, we get the following results:
Distribution
Quantum Score file
qreg q,5; gate x, [[0,1],[1,0]];gate measure, [[1,0],[0,0.7071067811865476+0.7071067811865476i]]; x q[0];x q[2];x q[4];measure q[0];measure q[1];measure q[2];measure q[3];measure q[4];
Downloaded CSV says
{"error":{"name":"Error","status":401,"message":"Authorization Required","statusCode":401,"code":"AUTHORIZATION_REQUIRED"}}
For whatever reason – I am not an authorized user, yet!
At any rate, from the distribution you can see the highest probability is 10101’s 0.306. I believe all the probabilities shown can be added together to roughly 1, and it is actually 0.998 with my mind calculation. Note that the next two high values are 10011’s 0.199 and 10111’s 0.152. You cannot say because these two values “look similar” to 10101, since the definition of “look-alike” is not precise. You can say they are 14 and 18, which is closer to 16 (10101) in this distribution curve.
EXERCISE 2. CNOT (with input 00)
Run the above CNOT (with input 00), and the results are:
Distribution
Quantum Score file
qreg q,5; gate measure, [[1,0],[0,0.7071067811865476+0.7071067811865476i]];gate cx, [[1,0,0,0],[0,1,0,0],[0,0,0,1],[0,0,1,0]]; cx q[1], q[2];measure q[1];measure q[2];
Based on the following definition: |0⟩ is a shorthand for |00⟩ and |1⟩ is a shorthand for |11⟩ (Only in this way of definition I can interpret the vector-matrix multiplication).
Input 00 means Q1’s is [0 0] and Q2’s input is [0 0]. Together they form vector [0000], and the resulted product with CNOT is [0000]. So the output is 00 because Q1 has the first two element [0 0] and Q2 has the next two element [00].
Quantum Score file
qreg q,5; gate measure, [[1,0],[0,0.7071067811865476+0.7071067811865476i]];gate x, [[0,1],[1,0]];gate cx, [[1,0,0,0],[0,1,0,0],[0,0,0,1],[0,0,1,0]]; x q[2];cx q[1], q[2];measure q[1];measure q[2];
Based on the following definition: |0⟩ is a shorthand for |00⟩ and |1⟩ is a shorthand for |11⟩ (Only in this way of definition I can interpret the vector-matrix multiplication).
Input 01 means Q1 is [0 0] and Q2 is [0 0] too but after an X-bit-flip is [1 1]. Together they form vector [0011], and the resulted product with CNOT is [0011]. So the output is 01 because Q1 has the first two element [0 0] and Q2 has the next two element [11].
Quantum Score file
qreg q,5; gate x, [[0,1],[1,0]];gate measure, [[1,0],[0,0.7071067811865476+0.7071067811865476i]];gate cx, [[1,0,0,0],[0,1,0,0],[0,0,0,1],[0,0,1,0]]; x q[1];cx q[1], q[2];measure q[1];measure q[2];
Based on the following definition: |0⟩ is a shorthand for |01⟩ and |1⟩ is a shorthand for |10⟩ (Only in this way of definition I can interpret the vector-matrix multiplication).
Input 10 means Q1’s is [0 1] but after an X-bit-flip is [1 0]. Q2 is [0 1]. Together they form vector [1001], and the resulted product with CNOT is [1010]. So the output is 11 because Q1 has the first two element [1 0] and Q2 has the next two element [10].
Quantum Score file
qreg q,5; gate x, [[0,1],[1,0]];gate measure, [[1,0],[0,0.7071067811865476+0.7071067811865476i]];gate cx, [[1,0,0,0],[0,1,0,0],[0,0,0,1],[0,0,1,0]]; x q[1];x q[2];cx q[1], q[2];measure q[1];measure q[2];
Based on the following definition: |0⟩ is a shorthand for |01⟩ and |1⟩ is a shorthand for |10⟩. (Only in this way of definition I can interpret the vector-matrix multiplication)
Input 11 means: Q1’s is [0 1] but after an X-bit-flip is [1 0]; Q2 is [0 1] but after an X-bit-flip is [1 0]. Together they form vector [0101], and the resulted product with CNOT is [1010]. So the output is 10 because Q1 has the first two element [1 0] and Q2 has the next two element [01].
Run the above circuit with cache we get distribution
and the Quantum Score file is
qreg q,5; gate h, [[0.7071067811865476,0.7071067811865476],[0.7071067811865476,-0.7071067811865476]];gate measure, [[1,0],[0,0.7071067811865476+0.7071067811865476i]];gate cx, [[1,0,0,0],[0,1,0,0],[0,0,0,1],[0,0,1,0]]; h q[0];h q[1];h q[2];h q[3];h q[4];cx q[1], q[2];measure q[0];measure q[1];measure q[2];measure q[3];measure q[4];
I am interested if the simulation will give me an obvious result, so here is the simulation result (with ideal processor)
Quantum Score file is
h q[0];
h q[1];
h q[2];
h q[3];
h q[4];
cx q[1], q[2];
measure q[0];
measure q[1];
measure q[2];
measure q[3];
measure q[4];
Simulation result (with realistic processor) is
Quantum Score file is
h q[0];
h q[1];
h q[2];
h q[3];
h q[4];
cx q[1], q[2];
measure q[0];
measure q[1];
measure q[2];
measure q[3];
measure q[4];
When RUN this circuit, 10011 seems getting the highest probability. However, a simulation with ideal processor results in all 32 combinations have the same probability. Plus, simulation with realistic processor results in 01000 having the highest probability (0.041). So I think the conclusion should be: all 32 combinations have roughly the same probability. This matches the text “The execution has made a quantum sphere that points in all directions with a small weight 1/(25)”.
EXERCISE 7. Home-made Circuit 1 (Modified Complete Superposition Circuit)
According to the text, I tried to add CNOT gate everywhere in the diagram but it always get rejected.
Tried the above circuit by adding T gates (note that I forgot to measure Q0, so results have only 4 qubits), these added gates are accepted by the system. The simulation (ideal processor) result is
And quantum score file is
h q[0];
h q[1];
h q[2];
h q[3];
h q[4];
cx q[1], q[2];
measure q[1];
measure q[2];
t q[3];
t q[4];
measure q[3];
measure q[4];
Again the conclusion can be made: “The execution has made a quantum sphere that points in all directions with a small weight 1/(24)”.
EXERCISE 8. Home-made Circuit 2 (Drastically Modified Complete Superposition Circuit)
I modify the complete superposition circuit drastically as follows:
Simulate with realistic processor to give:
Executed on: May 18, 2016 10:28:16 AM
Results date: May 18, 2016 10:28:32 AM
Qubits:
Quantum Score file:
h q[0];
x q[1];
h q[3];
h q[4];
cx q[0], q[2];
x q[3];
x q[4];
bloch q[0];
bloch q[1];
bloch q[2];
bloch q[3];
bloch q[4];
Of cause, the modified circuits have no meaning. I replace the regular measurement with Bloch measurement. I now know the big Bloch sphere on the lower right corner is the combination of the Bloch spheres of all 5 qubits.