Quantum mechanics basics
Introductionβ
In the following video, Olivia Lanes steps you through the content in this lesson. Alternatively, you can open the YouTube video for this lesson in a separate window.
In the previous lesson, we learned how to produce an entangled state of two qubits, known as a "Bell state." When we measured the state, we saw that the measurements of the two qubits were correlated: when one was measured to be 0 then the other was also measured 0 and when one was 1 the other was measured 1, too. We saw that this is a hallmark of quantum entanglement. Today we'll dig deeper into this state and what it reveals about the quantum physics fundamental to quantum computing.
The Bell stateβ
Many of the quantum phenomena that make quantum computers behave differently from classical computers are already present in the deceptively simple Bell state we produced in the previous lesson. Let's bring back that Bell state circuit:
# Added by doQumentation β required packages for this notebook
!pip install -q qiskit
from qiskit import QuantumCircuit
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()
qc.draw("mpl")
The image above represents the quantum circuit for making the Bell state . The two black horizontal lines represent our two qubits, and the boxes and other symbols on those lines represent gates or operations performed on the corresponding qubits. The gray double line is a classical information bus that allows us to store the classical information that we obtain by measuring the two qubits. We're going to dig into the details of this circuit and the resulting Bell state in order to understand the basics of quantum computing.
The math of quantum computingβ
Quantum state representationβ
First, we need a common language in which to discuss quantum states and circuits. There are a couple different ways to represent quantum states. The first is with Dirac notation. In Dirac notation, the state looks like this:
Here, the state is written inside angle brackets and vertical bars. The two terms each represent the two possible measurement outcomes of the state. So when we measure this state, we will either find that both of the qubits are in the state 0 or that both are in the state 1. The is called a "normalization constant." It is there to ensure that the sum of the squares each of the coefficients in the state all add up to . We'll discuss why this is the case later, in the section about measurements.
The second way to represent a state is in the standard language of linear algebra: as a vector, where each entry of the vector represents a different possible measurement outcome. In this notation, our Bell state would be written like this:
By convention, the entries of the vector are ordered as follows:
- The first entry corresponds to the two-qubit state
- The second to
- The third to
- The fourth to
As expected, in the Bell state vector , the first and fourth entries are nonzero, while the second and third entries are zero. The normalization constant ensures that the length of the vector is .
A note on the ordering of qubitsβ
Qiskit uses little endian ordering. This means that the rightmost qubit is considered the first (or least significant) qubit, and the leftmost qubit is the most significant qubit. So, when we write a state like :
- the rightmost bit corresponds to qubit , and is in the state .
- the leftmost bit corresponds to qubit , and is in the state .
Gate representationβ
Just as states can be represented as vectors, gates can be represented as matrices. A gate acts on a state by transforming its vector into a new vector.
Each gate corresponds to a specific matrix that dictates how the state will be transformed. We apply this transformation by multiplying the gate matrix and the original state vector, with the gate matrix to the left of the state vector, like this:
where represents the gate matrix and represents the state vector.
Let's look at the Hadamard gate as an example. The Hadamard gate is a single-qubit gate (the red box labelled "H" in the circuit diagram above) that transforms the state to and the state to . In matrix notation, the Hadamard looks like:
Check your understandingβ
Use matrix multiplication to show that the Hadamard matrix transforms the states as expected. (If needed, you can learn how to do matrix multiplication.)