3.2.4 Superposition
Now that we've got the |0⟩ and |1⟩ states under our belt, let's explore superposition, which is the concept that adding quantum states together (similar to overlaying two waves) results in a new quantum state. To make superpositions we need to expand our set of gates to include {H,S,S†} . In the Quantum Composer these are the blue set of gates and are represented by the matrices
(1) Applying Diagonal Basis (H gate (state is |+⟩), together with H then Z (state is |−⟩)) to get measured results: half-time |0⟩ and half-time |1⟩ : Equal and Uniform outcome
In the first score below, we apply H , known as the Hadamard gate, on one of the qubits that has been prepared in the |0⟩ state and then followed by the standard measurement. Run the circuit and observe the result. The qubit should spend half its time in the |0⟩ state and the other half in the |1⟩ state. Before the measurement forced it to choose, the qubit was in both states at once. This is part of the reason for the often-misused analogy that a quantum computer does everything at once.
What is happening here?
Applying the H gate to |0⟩ does a size-2 discrete Fourier transform, making the state |+⟩=1√2(|0⟩+|1⟩) . This is the standard representation of a superposition state.
We can define the state |−⟩=1√2(|0⟩−|1⟩) , which with |+⟩ forms a new basis called the diagonal (or conjugate) basis. It is made using the second circuit below. The H makes the above superposition and then the Z flips the phase (|1⟩ to −|1⟩ ). If you run this circuit you will find that, like before, the outcomes are equal. Different states give the same outcomes!
(2) Measuring IN Diagonal Basis (add an H gate before measuring): deterministic outcome
To tell the difference between these states we need to measure in the diagonal basis. In our experiments we cannot physically change the measurement; however, we can effectively change the measurement using gates before measurement. To measure in the diagonal basis, the standard basis (Z ) is rotated to the diagonal basis (X ) with a Hadamard gate before the measurement.
Try Superposition (+) X Measurement and Superposition (-) X Measurement below. You should find that nearly 100% of the time the outcome is 0 and 1 respectively. That is, if we make a measurement in the standard basis, the outcome is completely uniform -- but in the diagonal basis, it has deterministic outcome. No measurement can distinguish all four kinds of states |0⟩ , |1⟩ , |+⟩ , |−⟩ . This is not a limitation of the measurement, but a fundamental consequence of the uncertainty principle. (This limitation gives rise to the possibility of quantum money and quantum cryptography.)
(3) Applying circular basis (H then S, state is |↻⟩ ; H then S+, state is |↺⟩), and Measuring IN these basis (S+ then H): random outcome
A third commonly-used basis is the circular (or Y ) basis: |↻⟩=1√2(|0⟩+i|1⟩) , |↺⟩=1√2(|0⟩−i|1⟩) . To make the |↻⟩ state we need to use the additional gate S , the phase gate. This gate applies a complex phase to |1⟩ , via the application of an H followed by an S gate. Try to figure out how to get the |↺⟩ on your own.
Like the above example, measurement in the standard basis will not give you different statistics. Even measurement in the diagonal basis will be random. To measure in this basis we must rotate the standard basis (Z ) to the circular basis (Y ). To do this, use an S† followed by H before your measurement.
Try out the last example. It should give you close to 1 as it is a measurement |↻⟩ in the circular basis.
Experiment log:
Let us divide the exercises into three sets: first set is superpositions of (+) & (-); second set is superpositions of (+)X & (-)X; and third set is superpositions of (+i)Y & (-i)Y.
Running the first set (1st and 2nd exercises), we get as the text says: 0 state of 50% probability and 1-state of 50% probability. So the results are equal or uniform: half 0 and half 1. The Quantum Score file (of first exercise) says:
qreg q,5; gate h, [[0.7071067811865476,0.7071067811865476],[0.7071067811865476,-0.7071067811865476]];gate measure, [[1,0],[0,0.7071067811865476+0.7071067811865476i]]; h q[1];measure q[1];
(If you use “run” button instead of simulation button and download CSV, you will get error message saying that you are not authorized to do this. If I remember correctly, previously I can do this so maybe I already use up all my points and have to apply for more.)
Running the second set (3rd and 4th exercises), the result of (+)X is 0 of probability 100% and the result of (-)X is 1 of probability 100%. (to be revisited)
Running the third set (5th and 6th exercises), the result of (+i)Y is 0 of probability 100% and the result of (-i)Y is 1 of probability 100%. (to be revisited)