Qubit States in QISKit
First, you’ll need to download a free distribution of Anaconda so that you can use Jupyter Lab. Once you’ve downloaded Anaconda, open the Anaconda navigator and open an instance of Jupyter Lab. If you’d like to download the notebook from Github, you can find it here. If you’d like to see the interactive version on Binder, you can find it here. To install QISKit, you can just use pip in Jupyter notebook or Jupyter Lab.
Next, you’ll need to import qiskit and matplotlib.
Now, if you want to plot the “Spin-Up” state on the Bloch Sphere, you can type the following command.
We can plot the “Spin-Down” state of the qubit with the following command.
In general, qubit states are no longer restricted to simple 0 or 1 like a classical binary bit of information. Qubits can be in infinitely many states. Each state is represented as a point on the Bloch Sphere. Spin-Up corresponds to the state 0, and Spin-Down corresponds to the state 1, but the qubit can also be in a combination of these two states. Each point on the Bloch sphere, like coordinates on the surface of the earth, represents a unique qubit state. This ability of a qubit to be in infinitely many different states is related to the concept of “superposition” in quantum physics. For example, the following state on the Bloch Sphere is an even mixture of the state 0 and the state 1, so it is in a superposition of these two state.
This “Spin-Right” position is represented as a “superposition”,
or a “linear combination” of the 0 state and the 1 state. If you don’t understand the linear algebra reference, that’s okay. Now, if we want to operate on a single qubit in the Spin-Up state (or state 0), and flip it to Spin-Down (or state 1), we can use the NOT-gate. The NOT-gate or the “Pauli X-gate” is a quantum logic gate. Quantum logic gates are conceptually similar to classical logic gates, but they are not quite the same. They operate on qubits much like classical logic gates can operate on bits, but they are always reversible and are represented by (unitary) matrix multiplication. We can create a quantum circuit in QISKit as follows:
Now, if we want to operate on the single qubit using the NOT-gate, we can do this in QISKit with the following code.
This shows us that we have flipped the qubit state to Spin-Down. This is the basic idea behind quantum algorithms. In a followup article we will look at how these quantum logic gates are implemented on actual hardware using superconducting qubits. This can also be done with IBM software and amounts to programming microwave pulses that are applied to the quantum computer chip. If you would like to look at some tutorials that walk through the mathematics behind quantum algorithms, have a look at my Github Repository on the mathematics behind quantum computing implemented in Python. If you have questions or comments, or want to discuss quantum computing and its applications, feel free to get in touch.