Hi, I'm Thomas

NYC-based developer, student, and CS enthusiast.

Understanding quantum bit notation

01 December 2020

(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\vert0\rangle and 1\vert1\rangle. (For now, let the symbols “\vert” and “\rangle” just be indicators that a value is related to a quantum object.) Qubits in superposition have some chance of “collapsing” to 0\vert0\rangle and some chance of collapsing to 1\vert1\rangle when measured.

  • Whenever a qubit is measured, it must collapse to 0\vert0\rangle or 1\vert1\rangle
  • After a qubit collapses to 0\vert0\rangle or 1\vert1\rangle, it does not go back into superposition. If it collapsed to 0\vert0\rangle, it is now 0\vert0\rangle.

Expressing 1 qubit

Expanded notation for 1 qubit

Let’s say we have a qubit, ψ\vert\psi\rangle. Perhaps you have seen expanded notation:


This representation uniquely describes the qubit’s superposition:

  • a2a^2 is the probability that ψ\vert\psi\rangle will collapse to 0\vert0\rangle when measured
  • b2b^2 is the probability that ψ\vert\psi\rangle will collapse to 1\vert1\rangle when measured

(Technically, a2a^2 and b2b^2 are relative probabilities. They’re scaled so that a2+b2=100%a^2 + b^2 = 100\%. They’re squared because they could be negative.)

For example, this qubit has a 50% chance of collapsing to 0\vert0\rangle or 1\vert1\rangle when measured:


And this qubit has a 100% chance of collapsing to 1\ket1 when measured:

ψ2=00+11=1\begin{align*}\ket{\psi_2}&=0\cdot\ket{0}+1\cdot\ket{1}\\&=\ket{1} \end{align*}

This helps to answer the question, what do the 1\vert1\rangle and 0\vert0\rangle represent?

  • Example #2 (above) shows that 1\vert1\rangle represents a qubit will certainly collapse to 1\vert1\rangle (because it already is 1\vert1\rangle).
  • By similar logic, 0\vert0\rangle represents a qubit that always collapses to (or “has collapsed to”) 0\vert0\rangle.

This builds intuition about expanded notation. Some qubit, a0+b1,a\ket0+b\ket1, is a combination of the fundamental 0\vert0\rangle and 1\vert1\rangle states, with some chance of becoming 0\vert0\rangle or 1\vert1\rangle (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\vert0\rangle and 1\vert1\rangle in terms of vectors:

0=(10)1=(01)\begin{align*}\ket{0}&=\begin{pmatrix}1 \\ 0\end{pmatrix}\\\ket{1}&=\begin{pmatrix}0 \\ 1\end{pmatrix}\end{align*}

We will get back to why these definitions make sense. For now, let’s see how they let us rewrite a qubit:

ψ=a0+b1=a(10)+b(01)=(a0)+(0b)=(ab)\begin{align*}\ket{\psi}&=a\ket{0}+b\ket{1}\\ &=a\begin{pmatrix}1\\0\end{pmatrix}+b\begin{pmatrix}0\\1\end{pmatrix}\\ &=\begin{pmatrix}a\\0\end{pmatrix}+\begin{pmatrix}0\\b\end{pmatrix}\\ &=\begin{pmatrix}a\\b\end{pmatrix} \end{align*}

So the qubit ψ\vert\psi\rangle can be expressed as just one vector of two numbers:


And note that aa and bb still represent the coefficients of 0\vert0\rangle and 1\vert1\rangle (all we did was mathematically simplify the expression).

  • a2a^2 is still the probability that the qubit will collapse to 0\vert0\rangle when measured
  • b2b^2 is still the probability that the qubit will collapse to 1\vert1\rangle when measured

For example, this qubit has a 50% chance of collapsing to 0\vert0\rangle or 1\vert1\rangle when measured:


This qubit has a 100% chance of collapsing to 1\vert1\rangle when measured:


But a qubit that has a 100% chance of collapsing to 1\vert1\rangle is just the qubit 1\vert1\rangle. So Example #4 (above) shows us the following:


Similarly, the vector below represents a qubit with a 100% chance of collapsing to 0\vert0\rangle when measured, so it is 0\vert0\rangle:


And these are the two definitions that we began with:

Note, it just happens that 12=100%1^2 = 100\% and 02=0%0^2 = 0\%, so it seems the values weren’t squared.

Now you see how the initial definitions of 0\vert0\rangle and 1\vert1\rangle make sense — they uphold the following rule:

  • (top num)2(\text{top num})^2 = probability the qubit collapses to 0\vert0\rangle when measured
  • (bottom num)2(\text{bottom num})^2 = probability the qubit collapses to 1\vert1\rangle when measured

But what if ψ\vert\psi\rangle 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=22^1=2 states:


2 qubits, 22=42^2=4 states:

00,01,10,11\ket{00}, \ket{01}, \ket{10}, \ket{11}

3 qubits, 23=82^3=8 states:

000,001,010,011,100,101,110,111\ket{000}, \ket{001}, \ket{010}, \ket{011}, \ket{100}, \ket{101}, \ket{110}, \ket{111}

(In general, an nn-qubit system can be in a superposition of 2n2^n states.)

So, for example, a 4-qubit system could be written in expanded notation as follows (note, 242^4 states need to be represented):

ψ=a0000+b0001+c0010+d0011+e0100+f0101+g0110+h0111+j1000+k1001+l1010+m1011+n1100+o1101+p1110+q1111\begin{align*}\ket{\psi}&=a\ket{0000}+b\ket{0001}+c\ket{0010}+d\ket{0011}\\ &+e\ket{0100}+f\ket{0101}+g\ket{0110}+h\ket{0111}\\ &+j\ket{1000}+k\ket{1001}+l\ket{1010}+m\ket{1011}\\ &+n\ket{1100}+o\ket{1101}+p\ket{1110}+q\ket{1111}\\\end{align*}

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\vert00\rangle to 11\vert11\rangle in ascending binary order):


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):


For example, the state 01\vert01\rangle is equivalent to

  • qubit 1 (red) in state 0\vert0\rangle
  • qubit 2 (blue) in state 1\vert1\rangle

We already know how to write the two qubits of ψ6\vert\psi_6\rangle in vector notation:

qubit 1 of ψ=(xy)qubit 2 of ψ=(zw)\begin{align*}\text{qubit 1 of $\ket{\psi}$} &= \begin{pmatrix}x\\y\end{pmatrix} \\ \text{qubit 2 of $\ket{\psi}$} &= \begin{pmatrix}z\\w\end{pmatrix}\end{align*}
  • x2=x^2 = probability that qubit 1 collapses to 0\vert0\rangle when measured
  • y2=y^2 = probability that qubit 1 collapses to 1\vert1\rangle when measured
  • z2=z^2 = probability that qubit 2 collapses to 0\vert0\rangle when measured
  • w2=w^2 = probability that qubit 2 collapses to 1\vert1\rangle when measured

While the coefficients here are not aa, bb, cc, and dd, they’re related to aa, bb, cc, and dd, as we will now show. Note that the probability that \vert\psi₆\rangle collapses to 00\vert00\rangle when measured can be represented in two ways:

  1. It is a2a^2 by definition. (Remember, ψ=a00+\ket\psi = a\vert00\rangle + \cdots)
  2. It is also x2z2x^2\cdot z^2 since collapsing to 00\vert00\rangle means:
    • qubit 1 collapses to0\vert0\rangle (with probability x2x^2) and
    • qubit 2 collapses to 0\vert0\rangle (with probability z2z^2)

So it turns out that:

a2=x2z2a=xz\begin{align*}a^2&=x^2\cdot z^2\\ a&=xz\end{align*}

Similarly, the probability that ψ6\vert\psi_6\rangle collapses to 01\vert01\rangle when measured can be represented in two ways:

  • b2b^2 (remember, ψ6=+b01+\vert\psi_6\rangle = \cdots + b\vert01\rangle + \cdots )
  • x2w2x^2\cdot w^2 (qubit 1 collapses to 0\vert0\rangle and qubit 2 collapses to 1\vert1\rangle)

This yields

b2=x2w2b=xw\begin{align*}b^2&=x^2\cdot w^2\\ b&=xw\end{align*}

And the same can be done for ψ6\vert\psi_6\rangle collapsing to 10\vert10\rangle to show

c2=y2z2c=yz\begin{align*} c^2&=y^2\cdot z^2\\ c&=yz \end{align*}

or ψ6\vert\psi_6\rangle collapsing to 11\vert11\rangle to show

d2=y2w2d=yw\begin{align*} d^2&=y^2\cdot w^2\\ d&=yw \end{align*}

So we have

a=xzb=xwc=yzd=yw\begin{align*}a&=xz\\ b&=xw\\ c&=yz\\ d&=yw\end{align*}

This relationship between aa, bb, cc, dd and xx, yy, zz, ww in Fig 24 will soon help us to understand the intuition behind the vector representation of ψ6\vert\psi_6\rangle.

To represent a system of 2+ qubits in vector notation, we take the tensor product\otimes’ of all of the qubits (we’ll understand why further down). For now, let’s just see what happens:

ψ6=qubit 1qubit 2=(xy)(zw)=(xzxwyzyw)=(abcd)\begin{align}\ket{\psi_6} &= \text{qubit 1}\otimes\text{qubit 2}\\ &= \begin{pmatrix}x\\y\end{pmatrix}\otimes\begin{pmatrix}z\\w\end{pmatrix}\\ &= \begin{pmatrix}xz\\xw\\yz\\yw\end{pmatrix}\\ &= \begin{pmatrix}a\\b\\c\\d\end{pmatrix} \end{align}

Here are the steps from above broken down:

  • (2) replace qubit 1 and qubit 2 with their vector notations
  • (3) compute the tensor product
  • (4) rewrite in terms of aa, bb, cc, dd

Look at that! We’ve simplified a 2-qubit system to just one vector:

ψ6=a00+b01+c10+d11=(abcd)\begin{align*}\ket{\psi_6} = a\ket{00}+b\ket{01}+c\ket{10}+d\ket{11} = \begin{pmatrix}a\\b\\c\\d\end{pmatrix} \end{align*}

There’s something special about this vector! Notice that if you square the values of the vector from top-to-bottom, you get, a2a^2, b2b^2, c2c^2, and d2d^2. Those are the probabilities that ψ6\vert\psi_6\rangle will collapse to 00\vert00\rangle, 01\vert01\rangle, 10\vert10\rangle, or 11\vert11\rangle 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\vert\psi_6\rangle will collapse to 01\vert01\rangle when measured by squaring the second item in its vector representation, shown in green:

ψ6=a00+b01+c10+d11=(abcd)\begin{align*}\ket{\psi_6} = a\ket{00}+\textcolor{ForestGreen}{b}\ket{01}+c\ket{10}+d\ket{11} = \begin{pmatrix}a\\\textcolor{ForestGreen}{b}\\c\\d\end{pmatrix} \end{align*}

Notice that there is no 01\vert01\rangle in the vector representation because it is implied.

Say we are told that a 2-qubit system, ψ7\vert\psi_7\rangle, has a 50% chance of collapsing to 00\vert00\rangle or 11\vert11\rangle when measured. We can write it in vector notation as follows:

ψ7=0.500+001+010+0.511=(0.5000.5)\begin{align*}\ket{\psi_7} = \textcolor{MidnightBlue}{\sqrt{0.5}}\cdot\ket{00}+\textcolor{ForestGreen}{0}\cdot\ket{01}+\textcolor{#FE6F5E}{0}\cdot\ket{10}+\textcolor{Plum}{\sqrt{0.5}}\cdot\ket{11} = \begin{pmatrix}\textcolor{MidnightBlue}{\sqrt{0.5}}\\\textcolor{ForestGreen}{0}\\\textcolor{#FE6F5E}{0}\\\textcolor{Plum}{\sqrt{0.5}}\end{pmatrix} \end{align*}

Again, the values in the vector correspond to the fundamental states in descending order (e.g., 00\vert00\rangle, 01\vert01\rangle, 10\vert10\rangle, 11\vert11\rangle 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:

ψ=a0000+b0001+c0010+d0011+e0100+f0101+g0110+h0111+j1000+k1001+l1010+m1011+n1100+o1101+p1110+q1111=(abcdefghjklmnopq)\begin{align*}\ket{\psi}&=a\ket{0000}+b\ket{0001}+c\ket{0010}+d\ket{0011}\\ &+e\ket{0100}+f\ket{0101}+g\ket{0110}+h\ket{0111}\\ &+j\ket{1000}+k\ket{1001}+l\ket{1010}+m\ket{1011}\\ &+n\ket{1100}+o\ket{1101}+p\ket{1110}+q\ket{1111}\\ &=\begin{pmatrix}a\\b\\c\\d\\e\\f\\g\\h\\j\\k\\l\\m\\n\\o\\p\\q\end{pmatrix}\\ \end{align*}

While that’s a very tall vector, at least you don’t need to write out all the states from 0000\vert0000\rangle to 1111\vert1111\rangle.

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.