(Cover photo by Mark Garlick on Science Photo Library.)
Quantum computers are going to accelerate drug discovery, change the way we encrypt our information, and much more. If you haven’t heard of quantum computing yet, here’s a video that provides a nice introduction.
This article breaks down how we mathematically express qubits (quantum bits) and explains why each notation works.
Refresher on superposition: in classical computing, bits can only take on boolean values (0 or 1 and nothing in-between). But a qubit can be in a superposition of ∣0⟩ and ∣1⟩.
(For now, let the symbols “∣” and “⟩” just be indicators that a value is related to a quantum object.) Qubits in superposition have some chance of “collapsing” to ∣0⟩ and some chance of collapsing to ∣1⟩ when measured.
Whenever a qubit is measured, it must collapse to ∣0⟩ or ∣1⟩
After a qubit collapses to ∣0⟩ or ∣1⟩, it does not go back into superposition. If it collapsed to ∣0⟩, it is now ∣0⟩.
Expressing 1 qubit
Expanded notation for 1 qubit
Let’s say we have a qubit, ∣ψ⟩. Perhaps you have seen expanded notation:
∣ψ⟩=a∣0⟩+b∣1⟩
This representation uniquely describes the qubit’s superposition:
a2 is the probability that ∣ψ⟩ will collapse to ∣0⟩ when measured
b2 is the probability that ∣ψ⟩ will collapse to ∣1⟩ when measured
(Technically, a2 and b2 are relative probabilities. They’re scaled so that a2+b2=100%. They’re squared because they could be negative.)
For example, this qubit has a 50% chance of collapsing to ∣0⟩ or ∣1⟩ when measured:
∣ψ1⟩=0.5⋅∣0⟩+0.5⋅∣1⟩
And this qubit has a 100% chance of collapsing to ∣1⟩ when measured:
∣ψ2⟩=0⋅∣0⟩+1⋅∣1⟩=∣1⟩
This helps to answer the question, what do the∣1⟩and∣0⟩represent?
Example #2 (above) shows that ∣1⟩ represents a qubit will certainly collapse to ∣1⟩ (because it already is ∣1⟩).
By similar logic, ∣0⟩ represents a qubit that always collapses to (or “has collapsed to”) ∣0⟩.
This builds intuition about expanded notation. Some qubit, a∣0⟩+b∣1⟩, is a combination of the fundamental ∣0⟩ and ∣1⟩ states, with some chance of becoming∣0⟩ or ∣1⟩ (collapsing upon measurement).
Vector notation for 1 qubit
There exists another way to express qubits, which involves vectors. If you’ve never seen vectors or matrices, you should check out this introduction.
To start, let’s define ∣0⟩ and ∣1⟩ in terms of vectors:
∣0⟩∣1⟩=(10)=(01)
We will get back to why these definitions make sense. For now, let’s see how they let us rewrite a qubit:
∣ψ⟩=a∣0⟩+b∣1⟩=a(10)+b(01)=(a0)+(0b)=(ab)
So the qubit ∣ψ⟩ can be expressed as just one vector of two numbers:
ψ=(ab)
And note that a and b still represent the coefficients of ∣0⟩ and ∣1⟩ (all we did was mathematically simplify the expression).
a2 is still the probability that the qubit will collapse to ∣0⟩ when measured
b2 is still the probability that the qubit will collapse to ∣1⟩ when measured
For example, this qubit has a 50% chance of collapsing to ∣0⟩ or ∣1⟩ when measured:
∣ψ3⟩=(0.50.5)
This qubit has a 100% chance of collapsing to ∣1⟩ when measured:
∣ψ4⟩=(01)
But a qubit that has a 100% chance of collapsing to ∣1⟩ is just the qubit ∣1⟩. So Example #4 (above) shows us the following:
∣ψ4⟩=(01)=∣1⟩
Similarly, the vector below represents a qubit with a 100% chance of collapsing to ∣0⟩ when measured, so it is ∣0⟩:
∣ψ5⟩=(10)=∣0⟩
And these are the two definitions that we began with:
Note, it just happens that 12=100% and 02=0%, so it seems the values weren’t squared.
Now you see how the initial definitions of ∣0⟩ and ∣1⟩ make sense — they uphold the following rule:
(top num)2 = probability the qubit collapses to ∣0⟩ when measured
(bottom num)2 = probability the qubit collapses to ∣1⟩ when measured
But what if ∣ψ⟩ were comprised of more than one qubit?
Expressing 2+ qubits
Expanded notation for 2+ qubits
We can use expanded notation in a very similar manner. Note, though, that each additional qubit doubles the number of fundamental states:
1 qubit, 21=2 states:
∣0⟩,∣1⟩
2 qubits, 22=4 states:
∣00⟩,∣01⟩,∣10⟩,∣11⟩
3 qubits, 23=8 states:
∣000⟩,∣001⟩,∣010⟩,∣011⟩,∣100⟩,∣101⟩,∣110⟩,∣111⟩
(In general, an n-qubit system can be in a superposition of 2n states.)
So, for example, a 4-qubit system could be written in expanded notation as follows (note, 24 states need to be represented):
As you can see, expanded notation becomes tedious to write. But there exists a more compact way to represent qubits!
Vector notation for 2+ qubits
A multi-qubit system can also be represented as a vector. For simplicity, let’s consider a 2-qubit system (we write ∣00⟩ to ∣11⟩ in ascending binary order):
∣ψ⟩=a∣00⟩+b∣01⟩+c∣10⟩+d∣11⟩
Let’s name the two qubits in our 2-qubit system, qubit 1 and qubit 2. Coloring the equation will help visualize this (qubit 1 is in red, qubit 2 is in blue):
∣ψ⟩=a∣00⟩+b∣01⟩+c∣11⟩+d∣11⟩
For example, the state ∣01⟩ is equivalent to
qubit 1 (red) in state ∣0⟩
qubit 2 (blue) in state ∣1⟩
We already know how to write the two qubits of ∣ψ6⟩ in vector notation:
qubit 1 of ∣ψ⟩qubit 2 of ∣ψ⟩=(xy)=(zw)
x2= probability that qubit 1 collapses to ∣0⟩ when measured
y2= probability that qubit 1 collapses to ∣1⟩ when measured
z2= probability that qubit 2 collapses to ∣0⟩ when measured
w2= probability that qubit 2 collapses to ∣1⟩ when measured
While the coefficients here are nota, b, c, and d, they’re related to a, b, c, and d, as we will now show. Note that the probability that \vert\psi₆\rangle collapses to ∣00⟩ when measured can be represented in two ways:
It is a2 by definition. (Remember, ∣ψ⟩=a∣00⟩+⋯)
It is also x2⋅z2 since collapsing to ∣00⟩ means:
qubit 1 collapses to∣0⟩ (with probability x2) and
qubit 2 collapses to ∣0⟩ (with probability z2)
So it turns out that:
a2a=x2⋅z2=xz
Similarly, the probability that ∣ψ6⟩ collapses to ∣01⟩ when measured can be represented in two ways:
b2 (remember, ∣ψ6⟩=⋯+b∣01⟩+⋯ )
x2⋅w2 (qubit 1 collapses to ∣0⟩and qubit 2 collapses to ∣1⟩)
This yields
b2b=x2⋅w2=xw
And the same can be done for ∣ψ6⟩ collapsing to ∣10⟩ to show
c2c=y2⋅z2=yz
or ∣ψ6⟩ collapsing to ∣11⟩ to show
d2d=y2⋅w2=yw
So we have
abcd=xz=xw=yz=yw
This relationship between a, b, c, d and x, y, z, w in Fig 24 will soon help us to understand the intuition behind the vector representation of ∣ψ6⟩.
To represent a system of 2+ qubits in vector notation, we take the tensor product ‘⊗’ of all of the qubits (we’ll understand why further down). For now, let’s just see what happens:
(2) replace qubit 1 and qubit 2 with their vector notations
(3) compute the tensor product
(4) rewrite in terms of a, b, c, d
Look at that! We’ve simplified a 2-qubit system to just one vector:
∣ψ6⟩=a∣00⟩+b∣01⟩+c∣10⟩+d∣11⟩=⎝⎛abcd⎠⎞
There’s something special about this vector! Notice that if you square the values of the vector from top-to-bottom, you get, a2, b2, c2, and d2. Those are the probabilities that ∣ψ6⟩ will collapse to ∣00⟩, ∣01⟩, ∣10⟩, or ∣11⟩ when measured.
That’s why we take the tensor product of the qubits—it makes the result contain all the coefficients defining the superposition. And because of the way a tensor product is calculated, the coefficients will be in the same order as they were in expanded notation!
For example, we could find the probability that ∣ψ6⟩ will collapse to ∣01⟩ when measured by squaring the second item in its vector representation, shown in green:
∣ψ6⟩=a∣00⟩+b∣01⟩+c∣10⟩+d∣11⟩=⎝⎛abcd⎠⎞
Notice that there is no ∣01⟩ in the vector representation because it is implied.
Say we are told that a 2-qubit system, ∣ψ7⟩, has a 50% chance of collapsing to ∣00⟩ or ∣11⟩ when measured. We can write it in vector notation as follows:
Again, the values in the vector correspond to the fundamental states in descending order (e.g., ∣00⟩, ∣01⟩, ∣10⟩, ∣11⟩ for 2 qubits). The expanded notation is no longer needed!
Also, remember, the values are squared to find the coefficients.
Finally, here is what the generic 4-qubit system from Fig 16 would look like in vector notation:
While that’s a very tall vector, at least you don’t need to write out all the states from ∣0000⟩ to ∣1111⟩.
That’s it! Hopefully, you now have a better grasp of the notation.
What next?
Understanding qubits in vector notation becomes very helpful when you begin to work with quantum logic gates. The gates can be represented as matrices so that their interactions with qubits become matrix multiplications. If you’re interested in how that works, check out this lecture about the mathematical representation of quantum computing.