Bra-Ket Notation

The notation used to write quantum states, and the operations that go with it.

This is a piece of supplementary material, meant to help you further understand topics that are important to quantum computing but not the main focus of the course. Pages like this one either provide more mathematical background or look more closely at the theory behind something covered elsewhere.

This page will be doing the former for bra-ket notation, a type of notation widely used in quantum physics and computing but not used as often in math or computer science.

A ket is simply a column vector, i.e. a list of amplitudes in the form of a $n \times 1$ matrix. For a qubit, this list is always of size 2, where the first term represents the amplitude for $|0\rangle$ and the second term represents the amplitude for $|1\rangle$. We write a ket as $|\psi\rangle$, where $\psi$ is our quantum state variable.

A bra is simply a row vector, i.e. a list of amplitudes in the form of a $1 \times n$ matrix. Similarly to a ket, we write a bra as $\langle \psi|$. Importantly, $\langle \psi| = |\psi\rangle^\dag$ and $|\psi\rangle = \langle\psi|^\dag$.

Here, the $\dag$ symbol denotes the conjugate transpose of the vector. You may be familiar with the transpose of a matrix already; the conjugate transpose simply also flips the sign of the imaginary part of each element. For example,

$$ |\psi\rangle = \begin{bmatrix} a \\ b+ci \end{bmatrix} \qquad |\psi\rangle^\dag=\langle\psi|=\begin{bmatrix} a & b-ci \end{bmatrix} $$

There is nothing special about vectors here; you can find the conjugate transpose of any matrix in a similar way.

In bra-ket notation, $\langle \psi | \psi \rangle$ represents the inner product (dot product) and $|\psi\rangle \langle \psi |$ represents the outer product. For the example above, we find that

$$ \langle \psi | \psi \rangle = \begin{bmatrix} a & b-ci \end{bmatrix} \begin{bmatrix} a \\ b+ci \end{bmatrix} = a^2+b^2+c^2 = 1 $$

When the bra and the ket are the same state, this operation is the same as taking the sum of the absolute value squared of each term in $|\psi\rangle$. By our quantum state restriction, this sum must be 1. Similarly, we find that

$$ |\psi\rangle\langle\psi| = \begin{bmatrix} a \\ b+ci \end{bmatrix}\begin{bmatrix} a & b-ci \end{bmatrix} = \begin{bmatrix} a^2 & ab-aci \\ ab+aci & b^2+c^2 \end{bmatrix} $$

I will use the rest of this page to discuss a few other properties of bra-ket notation that later pages look at in more detail. Don't worry if you don't understand much of this; each of these properties is covered more closely further on. Likewise, feel free to use this page as a reference at any point.

You will often see kets written next to each other, like $|\psi\rangle|\xi\rangle$. This is not matrix multiplication, since the dimensions are invalid. Instead, this is used to refer to the tensor product, sometimes denoted with the $\otimes$ symbol. For example,

$$ A = \begin{bmatrix} a \\ b \\ c \end{bmatrix}, \quad B = \begin{bmatrix} d \\ e \end{bmatrix}, \quad A \otimes B = \begin{bmatrix} ad \\ ae \\ bd \\ be \\ cd \\ ce \end{bmatrix} $$

More formally, in quantum computing, the tensor product between a $m \times n$ matrix $A$ and $p \times q$ matrix $B$ is defined as

$$ A \otimes B = \begin{bmatrix} a_{11}B & \cdots & a_{1n}B \\ \vdots & \ddots & \vdots \\ a_{m1}B & \cdots & a_{mn}B \end{bmatrix} $$

This matrix will have size $mp \times nq$. Tensor products are really useful in quantum computing. We'll be using them a lot, and I hope it becomes more clear why they're the right operation for a lot of what we're doing as you read on.

The final thing I'll mention here is that you can multiply matrices with bras or kets, since they are just vectors. Often in quantum computing, this will be a square matrix with a size that corresponds to a power of 2. For example, suppose we have the matrix

$$ H = \begin{bmatrix} 1/\sqrt{2} & 1/\sqrt{2} \\ 1/\sqrt{2} & -1/\sqrt{2} \end{bmatrix} $$

Let's try applying $H$ to a state, say $|0\rangle$. We would write this operation as follows:

$$ H|0\rangle = \begin{bmatrix} 1/\sqrt{2} & 1/\sqrt{2} \\ 1/\sqrt{2} & -1/\sqrt{2} \end{bmatrix}\begin{bmatrix} 1 \\ 0 \end{bmatrix} = \begin{bmatrix} 1/\sqrt{2} \\ 1/\sqrt{2} \end{bmatrix} = |+\rangle $$

This is an interesting result! This matrix seems to convert the $|0\rangle$ state, i.e. 100% '0', into the $|+\rangle$ state, i.e. 50% '0' and 50% '1'.

There is a more subtle fact about this matrix $H$. We can observe that $HH^\dag=H^\dag H=I$, where $I$ is the identity matrix. If this property is true for some matrix $U$, then $U$ is a unitary matrix, which means that it will preserve the property that $\langle \psi | \psi \rangle=1$ for any quantum state $|\psi\rangle$ when applied. More formally, we would write $$ \langle\psi|U^\dag U|\psi\rangle = \langle\psi|\psi\rangle = 1 $$ where $\langle\psi|U^\dag$ represents the unitary $U$ being applied on the bra and $U|\psi\rangle$ represents it being applied on the ket. This unitary $H$ is extremely important; it is known as a Hadamard gate, and we will be talking about it in Superposition, Single-Qubit Gates, Intro to Qiskit.