Skip to content
ImagineWorld

Our Space in the Universe

node_idnode-book_essential-mathematics-for-quantum-computing_chapter-08-our-space-in-the-universe
node_typechapter_node
schema_profileworld.chapter_node.v1
entropyhigh
manifoldworld
domainimagineworld.net
authorityinforms
layercorpus
statusactive
chapter_num8
chapter_titleOur Space in the Universe
governed_byCORPUS
constitutional_citationCONSTITUTION
local graph

Our space in the universe is called a Hilbert space. A Hilbert space is a type of vector space that has certain properties – properties that we will develop in this chapter. The most important will be defining an inner product. Once this is done, we will be able to measure distance and angles between vectors in an n-dimensional complex space. We will also be able to measure the length of vectors in these spaces. Later in the chapter, we will look at putting these Hilbert spaces together into even bigger Hilbert spaces through the tensor product!

The other main topic of this chapter is linear operators. We will go through many types, showing the distinct properties of each.

In this chapter, we are going to cover the following main topics:

  • The inner product
  • Orthonormality
  • The outer product
  • Operators
  • Types of operators
  • Tensor products

An inner product can actually be any function that follows a few properties, but we are going to zero in on one definition of the inner product that we will use in quantum computing. Here it is:

⟨∣x⟩,∣y⟩⟩≡⟨[x1⋮xn],[y1⋮yn]⟩=∑i=1nxi∗yi=x1∗y1+⋯+xn∗yn\langle |x\rangle, |y\rangle \rangle \equiv \left\langle \begin{bmatrix} x_1 \\ \vdots \\ x_n \end{bmatrix}, \begin{bmatrix} y_1 \\ \vdots \\ y_n \end{bmatrix} \right\rangle = \sum_{i=1}^{n} x_i^* y_i = x_1^* y_1 + \cdots + x_n^* y_n

Mathematicians use the preceding notation for the inner product, but Dirac defined it with a bra and ket, calling it a bracket:

⟨x∣y⟩≡⟨∣x⟩,∣y⟩⟩\langle x | y \rangle \equiv \langle |x\rangle, |y\rangle \rangle

Now, if we define a bra to be the conjugate transpose of its corresponding ket, so that if:

∣x⟩=[x1⋮xn]|x\rangle = \begin{bmatrix} x_1 \\ \vdots \\ x_n \end{bmatrix}

Then, ⟨x| is now:

[x1∗⋯xn∗]\begin{bmatrix} x_1^* & \cdots & x_n^* \end{bmatrix}

We can then define a bracket as just matrix multiplication!

⟨x∣y⟩=[x1∗⋯xn∗][y1⋮yn]=∑i=1nxi∗yi=x1∗y1+⋯+xn∗yn\langle x | y \rangle = \begin{bmatrix} x_1^* & \cdots & x_n^* \end{bmatrix} \begin{bmatrix} y_1 \\ \vdots \\ y_n \end{bmatrix} = \sum_{i=1}^{n} x_i^* y_i = x_1^* y_1 + \cdots + x_n^* y_n

Pretty cool, eh? That is one of the reasons why bra-ket notation is so convenient! You should notice something else too. The bra ⟨x| is a linear functional. It will take any vector |y⟩ and give you a scalar according to the inner product formula!

Let’s look at an example. Let’s say |x⟩ and |y⟩ are defined this way:

∣x⟩=[3i2i]∣y⟩=[2−i3]|x\rangle = \begin{bmatrix} 3 \\ i \\ 2i \end{bmatrix} \quad |y\rangle = \begin{bmatrix} 2 \\ -i \\ 3 \end{bmatrix}

Then, the bras are going to be:

⟨x∣=[3−i−2i]⟨y∣=[2i3]\langle x | = \begin{bmatrix} 3 & -i & -2i \end{bmatrix} \quad \langle y | = \begin{bmatrix} 2 & i & 3 \end{bmatrix}

Now, let’s calculate the inner product ⟨y|x⟩:

⟨y∣x⟩=[2i3]⋅[3i2i]={2⋅3+i⋅i+3⋅2i6−1+6i5+6i\langle y | x \rangle = \begin{bmatrix} 2 & i & 3 \end{bmatrix} \cdot \begin{bmatrix} 3 \\ i \\ 2i \end{bmatrix} = \begin{cases} 2 \cdot 3 + i \cdot i + 3 \cdot 2i \\ \quad 6 - 1 + 6i \\ \quad 5 + 6i \end{cases}

Let’s reverse the inner product and calculate ⟨x|y⟩:

⟨x∣y⟩=[3−i−2i]⋅[2−i3]={3⋅2+(−i)⋅(−i)+(−2i)⋅36−1−6i5−6i\langle x | y \rangle = \begin{bmatrix} 3 & -i & -2i \end{bmatrix} \cdot \begin{bmatrix} 2 \\ -i \\ 3 \end{bmatrix} = \begin{cases} 3 \cdot 2 + (-i) \cdot (-i) + (-2i) \cdot 3 \\ \quad 6 - 1 - 6i \\ \quad 5 - 6i \end{cases}

You might have noticed that the preceding answers are complex conjugates of each other; that’s because:

⟨x∣y⟩=⟨y∣x⟩∗\langle x | y \rangle = \langle y | x \rangle^*

Since bras are linear functionals, brackets are left-distributive (α and β are scalars):

⟨y∣(α∣x⟩+β∣z⟩)=α⟨y∣x⟩+β⟨y∣z⟩\langle y | \big( \alpha |x\rangle + \beta |z\rangle \big) = \alpha \langle y | x \rangle + \beta \langle y | z \rangle

(1)

And they are also right-distributive:

(α⟨x∣+β⟨z∣)∣y⟩=α⟨x∣y⟩+β⟨z∣y⟩\big( \alpha \langle x | + \beta \langle z | \big) | y \rangle = \alpha \langle x | y \rangle + \beta \langle z | y \rangle

Let’s test the left-distributive property in an example where we evaluate both sides of Equation (1) separately. We will define all the variables first. Our two scalars will be α = 3 and β = 2. Our vectors are defined as follows:

∣x⟩=[210]∣z⟩=[642]⟨y∣=[134]|x\rangle = \begin{bmatrix} 2 \\ 1 \\ 0 \end{bmatrix} \quad |z\rangle = \begin{bmatrix} 6 \\ 4 \\ 2 \end{bmatrix} \quad \langle y | = \begin{bmatrix} 1 & 3 & 4 \end{bmatrix}

Alright, here we go. Let’s evaluate the left side of Equation (1) first:

⟨y∣(α∣x⟩+β∣z⟩)=[134](3[210]+2[642])=[134]([630]+[1284])=[134][18114]=18+33+16=67\begin{aligned} \langle y | \big( \alpha |x\rangle + \beta |z\rangle \big) &= \begin{bmatrix} 1 & 3 & 4 \end{bmatrix} \left( 3 \begin{bmatrix} 2 \\ 1 \\ 0 \end{bmatrix} + 2 \begin{bmatrix} 6 \\ 4 \\ 2 \end{bmatrix} \right) \\ &= \begin{bmatrix} 1 & 3 & 4 \end{bmatrix} \left( \begin{bmatrix} 6 \\ 3 \\ 0 \end{bmatrix} + \begin{bmatrix} 12 \\ 8 \\ 4 \end{bmatrix} \right) \\ &= \begin{bmatrix} 1 & 3 & 4 \end{bmatrix} \begin{bmatrix} 18 \\ 11 \\ 4 \end{bmatrix} = 18 + 33 + 16 = 67 \end{aligned}

And now for the right side of Equation (1):

α⟨y∣x⟩+β⟨y∣z⟩=3([134][210])+2([134][642])=3(2+3+0)+2(6+12+8)=3⋅5+2⋅26=15+52=67\begin{aligned} \alpha \langle y | x \rangle + \beta \langle y | z \rangle &= 3 \left( \begin{bmatrix} 1 & 3 & 4 \end{bmatrix} \begin{bmatrix} 2 \\ 1 \\ 0 \end{bmatrix} \right) + 2 \left( \begin{bmatrix} 1 & 3 & 4 \end{bmatrix} \begin{bmatrix} 6 \\ 4 \\ 2 \end{bmatrix} \right) \\ &= 3(2 + 3 + 0) + 2(6 + 12 + 8) \\ &= 3 \cdot 5 + 2 \cdot 26 \\ &= 15 + 52 = 67 \end{aligned}

Luckily, our answers match. Whew! I didn’t want to have to go back and do that again! Let’s move on to see how the inner product can be used in vector spaces.

In this section, we will look at the concepts of the norm and orthogonality to come up with orthonormality.

We can define a metric on our vector spaces called the norm and denote it this way, ∥x∥, where x is the vector on which the norm is being measured. In two- and three-dimensional Euclidean spaces, it is often called the length of a vector, but in higher dimensions, we use the term norm. It gives us a way to measure vectors.

We define the norm using our inner product from the previous section, like so:

∥x∥=⟨x∣x⟩\| x \| = \sqrt{\langle x | x \rangle}

As always, let’s look at an example. What is the norm of the vector |x⟩ here?

∣x⟩=[234]|x\rangle = \begin{bmatrix} 2 \\ 3 \\ 4 \end{bmatrix}

Well, let’s work it out:

∥x∥=⟨x∣x⟩=[234][234]=4+9+16=29\begin{aligned} \| x \| &= \sqrt{\langle x | x \rangle} \\ &= \sqrt{\begin{bmatrix} 2 & 3 & 4 \end{bmatrix} \begin{bmatrix} 2 \\ 3 \\ 4 \end{bmatrix}} \\ &= \sqrt{4 + 9 + 16} = \sqrt{29} \end{aligned}

As you can see, the norm, ∥x∥, of |x⟩ is the square root of 29.

Oftentimes, especially in quantum computing, we will want to represent our vectors by something called a unit vector. The word unit refers to the fact that the norm of these vectors is one. How do we achieve this? Well, we divide a vector by its norm in a process called normalization.

A unit vector |u⟩ is found for the vector |v⟩ using the following formula:

∣u⟩=∣v⟩∥v∥|u\rangle = \frac{|v\rangle}{\| v \|}

What is the unit vector for the vector |x⟩ from the previous section? Well, we just divide |x⟩ by its norm to obtain:

∣u⟩=∣x⟩∥x∥=129[234]=[2/293/294/29]|u\rangle = \frac{|x\rangle}{\| x \|} = \frac{1}{\sqrt{29}} \begin{bmatrix} 2 \\ 3 \\ 4 \end{bmatrix} = \begin{bmatrix} 2/\sqrt{29} \\ 3/\sqrt{29} \\ 4/\sqrt{29} \end{bmatrix}

You should take the norm of |u⟩ to ensure that it is indeed 1.

Orthogonal may not be a word you’ve seen before, but I bet you are familiar with the word perpendicular. For instance, the two vectors in the following graph are perpendicular to each other:

Figure 8.1 – Two perpendicular vectors

Orthogonality is taking the concept of vectors being perpendicular to each other to higher dimensions of ℂn.

The inner product is helpful in this regard as well. If two vectors are orthogonal to each other, their inner product will be 0. Let’s see whether the two vectors in Figure 8.1 are orthogonal according to the inner product:

[−11][11]=−1⋅1+1⋅1=−1+1=0\begin{bmatrix} -1 & 1 \end{bmatrix} \begin{bmatrix} 1 \\ 1 \end{bmatrix} = -1 \cdot 1 + 1 \cdot 1 = -1 + 1 = 0

Indeed, they are orthogonal, as their inner product is zero. Are the next two vectors orthogonal?

∣x⟩=[210]∣z⟩=[642]|x\rangle = \begin{bmatrix} 2 \\ 1 \\ 0 \end{bmatrix} \quad |z\rangle = \begin{bmatrix} 6 \\ 4 \\ 2 \end{bmatrix}

Well, let’s see!

⟨x∣z⟩=[210][642]=12+4+0=16\begin{aligned} \langle x | z \rangle &= \begin{bmatrix} 2 & 1 & 0 \end{bmatrix} \begin{bmatrix} 6 \\ 4 \\ 2 \end{bmatrix} \\ &= 12 + 4 + 0 = 16 \end{aligned}

So, no – they’re not! Now, it’s your turn.

Determine whether each pair of vectors is orthogonal using the inner product:

  1. [123],[2−2−1]\begin{bmatrix} 1 \\ 2 \\ 3 \end{bmatrix}, \begin{bmatrix} 2 \\ -2 \\ -1 \end{bmatrix}
  2. [012−1],[−1125]\begin{bmatrix} 0 \\ 1 \\ 2 \\ -1 \end{bmatrix}, \begin{bmatrix} -1 \\ 1 \\ 2 \\ 5 \end{bmatrix}

So, if we combine the concept of orthogonality and normalization, we get orthonormal vectors. These are very important in the study of vector spaces and quantum computing.

Let’s see whether we can come up with some orthonormal vectors in ℂ2. We’ll try the computational basis vectors:

∣0⟩=[10]∣1⟩=[01]|0\rangle = \begin{bmatrix} 1 \\ 0 \end{bmatrix} \qquad |1\rangle = \begin{bmatrix} 0 \\ 1 \end{bmatrix}

Are they orthogonal?

⟨1∣0⟩=[01][10]=0⋅1+1⋅0=0\langle 1 | 0 \rangle = \begin{bmatrix} 0 & 1 \end{bmatrix} \begin{bmatrix} 1 \\ 0 \end{bmatrix} = 0 \cdot 1 + 1 \cdot 0 = 0

Well, their inner product is zero, so they are orthogonal! Are they unit vectors?

∥0∥2=⟨0∣0⟩=[10][10]=1⋅1+0⋅0=1∥1∥2=⟨1∣1⟩=[01][01]=0⋅0+1⋅1=1\begin{aligned} \| 0 \|^2 &= \langle 0 | 0 \rangle = \begin{bmatrix} 1 & 0 \end{bmatrix} \begin{bmatrix} 1 \\ 0 \end{bmatrix} = 1 \cdot 1 + 0 \cdot 0 = 1 \\ \| 1 \|^2 &= \langle 1 | 1 \rangle = \begin{bmatrix} 0 & 1 \end{bmatrix} \begin{bmatrix} 0 \\ 1 \end{bmatrix} = 0 \cdot 0 + 1 \cdot 1 = 1 \end{aligned}

Yes! The square root of their own inner product (aka their norm) is one. So |0⟩ and |1⟩ are orthonormal (hint: that’s one of the reasons they were chosen as the canonical 0 and 1 vectors).

Let’s look at another set of vectors that are important in quantum computing. They are labeled with plus and minus signs:

∣+⟩=[1212]∣−⟩=[12−12]|+\rangle = \begin{bmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{bmatrix} \qquad |-\rangle = \begin{bmatrix} \frac{1}{\sqrt{2}} \\ -\frac{1}{\sqrt{2}} \end{bmatrix}

What do you think? Orthonormal? Or just normal? How do we know? That’s right – we use our formulas. Let’s see whether they are orthogonal first:

⟨−∣+⟩=[12−12][1212]={12⋅12+(−12)⋅1212−12=0\langle - | + \rangle = \begin{bmatrix} \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}} \end{bmatrix} \begin{bmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{bmatrix} = \begin{cases} \frac{1}{\sqrt{2}} \cdot \frac{1}{\sqrt{2}} + \left(-\frac{1}{\sqrt{2}}\right) \cdot \frac{1}{\sqrt{2}} \\ \quad \frac{1}{2} - \frac{1}{2} = 0 \end{cases}

Okay, so their inner product is zero. Therefore, they are orthogonal. Are they normal or abnormal (he-he)?

∥+∥2=⟨+∣+⟩=[1212][1212]=12+12=1∥−∥2=⟨−∣−⟩=[12−12][12−12]=12+12=1\begin{aligned} \| + \|^2 &= \langle + | + \rangle = \begin{bmatrix} \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \end{bmatrix} \begin{bmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{bmatrix} = \frac{1}{2} + \frac{1}{2} = 1 \\ \| - \|^2 &= \langle - | - \rangle = \begin{bmatrix} \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}} \end{bmatrix} \begin{bmatrix} \frac{1}{\sqrt{2}} \\ -\frac{1}{\sqrt{2}} \end{bmatrix} = \frac{1}{2} + \frac{1}{2} = 1 \end{aligned}

Looks like they’re normal! So |+⟩ and |-⟩ are orthonormal vectors.

Almost all vectors in quantum computing are unit vectors and many are orthogonal to each other. When you are dealing with orthonormal vectors and doing computations, it is convenient to use the Kronecker delta function. It is defined thusly:

δij={0if i≠j1if i=j\delta_{ij} = \begin{cases} 0 & \text{if } i \neq j \\ 1 & \text{if } i = j \end{cases}

So, when you see that symbol, if the indices of i and j are equal, then it is one. Otherwise, it is zero.

A good example is the identity matrix. If you replace the entries with the Kronecker delta function, you will get ones on the main diagonal when the indices of the entries equal each other:

I=[δ11δ12δ21δ22]=[1001]I = \begin{bmatrix} \delta_{11} & \delta_{12} \\ \delta_{21} & \delta_{22} \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}

More importantly, when you have a basic set of orthonormal vectors, the inner product of a vector with itself is one because they are normalized. The inner product is zero when you use any other basis vector because they are orthogonal. For instance, take the basis set B with orthonormal vectors:

B={∣0⟩,∣1⟩,∣2⟩,…,∣n⟩}B = \{ |0\rangle, |1\rangle, |2\rangle, \ldots, |n\rangle \}

We can then use the Kronecker delta function to succinctly represent their inner product:

⟨i∣j⟩=δij\langle i | j \rangle = \delta_{ij}

I want you to know this function because you will see it in quantum computing literature, and it helps us in succinctly describing computations.

The outer product is interesting because it is again the matrix multiplication of two vectors, but this time, the vectors are reversed, producing a matrix. The inner product uses the matrix multiplication of two vectors to get a scalar. The outer product uses two vectors to produce a matrix. Formally, the outer product is defined to be:

∣u⟩⟨v∣=[u1v1∗u1v2∗⋯u1vn∗u2v1∗u2v2∗⋯u2vn∗⋮⋮⋱⋮umv1∗umv2∗⋯umvn∗]|u\rangle \langle v| = \begin{bmatrix} u_1 v_1^* & u_1 v_2^* & \cdots & u_1 v_n^* \\ u_2 v_1^* & u_2 v_2^* & \cdots & u_2 v_n^* \\ \vdots & \vdots & \ddots & \vdots \\ u_m v_1^* & u_m v_2^* & \cdots & u_m v_n^* \end{bmatrix}

If you remember matrix multiplication from Chapter 2, The Matrix, we have the following situation when multiplying an m × n matrix and an n × p matrix. They produce an m × p matrix, as shown in the following diagram. Since we are dealing with vectors, we have an m × 1 matrix and a 1 × p matrix:

Am×n⋅Bn×p=Cm×pA_{m \times n} \cdot B_{n \times p} = C_{m \times p}

Figure 8.2 – The schematics of matrix multiplication

Let’s look at an example. First, we have two vectors |u⟩ and |v⟩:

∣u⟩=[32−1] and ∣v⟩=[7231]|u\rangle = \begin{bmatrix} 3 \\ 2 \\ -1 \end{bmatrix} \text{ and } |v\rangle = \begin{bmatrix} 7 \\ 2 \\ 3 \\ 1 \end{bmatrix}

Now, let’s do the outer product with them:

∣u⟩⟨v∣=[32−1][7231]=[3⋅73⋅23⋅33⋅12⋅72⋅22⋅32⋅1−1⋅7−1⋅2−1⋅3−1⋅1]=[2169314462−7−2−3−1]\begin{aligned} |u\rangle \langle v| &= \begin{bmatrix} 3 \\ 2 \\ -1 \end{bmatrix} \begin{bmatrix} 7 & 2 & 3 & 1 \end{bmatrix} \\ &= \begin{bmatrix} 3 \cdot 7 & 3 \cdot 2 & 3 \cdot 3 & 3 \cdot 1 \\ 2 \cdot 7 & 2 \cdot 2 & 2 \cdot 3 & 2 \cdot 1 \\ -1 \cdot 7 & -1 \cdot 2 & -1 \cdot 3 & -1 \cdot 1 \end{bmatrix} \\ &= \begin{bmatrix} 21 & 6 & 9 & 3 \\ 14 & 4 & 6 & 2 \\ -7 & -2 & -3 & -1 \end{bmatrix} \end{aligned}

Is the outer product commutative? Well, let’s try:

∣v⟩⟨u∣=[7231][32−1]=[7⋅37⋅27⋅(−1)2⋅32⋅22⋅(−1)3⋅33⋅23⋅(−1)1⋅31⋅21⋅(−1)]=[2114−764−296−332−1]\begin{aligned} |v\rangle \langle u| &= \begin{bmatrix} 7 \\ 2 \\ 3 \\ 1 \end{bmatrix} \begin{bmatrix} 3 & 2 & -1 \end{bmatrix} \\ &= \begin{bmatrix} 7 \cdot 3 & 7 \cdot 2 & 7 \cdot (-1) \\ 2 \cdot 3 & 2 \cdot 2 & 2 \cdot (-1) \\ 3 \cdot 3 & 3 \cdot 2 & 3 \cdot (-1) \\ 1 \cdot 3 & 1 \cdot 2 & 1 \cdot (-1) \end{bmatrix} \\ &= \begin{bmatrix} 21 & 14 & -7 \\ 6 & 4 & -2 \\ 9 & 6 & -3 \\ 3 & 2 & -1 \end{bmatrix} \end{aligned}

Apparently not! So, in general, |u⟩⟨v| ≠|v⟩⟨u|. Look closely at the matrices for the final answers though. Do you see any similarities? That’s right – they are the transpose of each other! This leads us to the following property of the outer product:

(∣u⟩⟨v∣)†=(∣v⟩⟨u∣)(|u\rangle \langle v|)^\dagger = (|v\rangle \langle u|)

You should also note that the outer product is distributive over addition, so:

(∣v⟩+∣w⟩)⟨u∣=∣v⟩⟨u∣+∣w⟩⟨u∣(|v\rangle + |w\rangle) \langle u| = |v\rangle \langle u| + |w\rangle \langle u|

(2)

∣u⟩(⟨v∣+⟨w∣)=∣u⟩⟨v∣+∣u⟩⟨w∣|u\rangle \big( \langle v| + \langle w| \big) = |u\rangle \langle v| + |u\rangle \langle w|

So, let’s try out Equation (2) on our friends |0⟩ and |1⟩. Here’s the left side of the equation:

(∣0⟩+∣1⟩)⟨1∣=([10]+[01])[01]=[11][01]=[0101]\begin{aligned} & (|0\rangle + |1\rangle) \langle 1| \\ &= \left( \begin{bmatrix} 1 \\ 0 \end{bmatrix} + \begin{bmatrix} 0 \\ 1 \end{bmatrix} \right) \begin{bmatrix} 0 & 1 \end{bmatrix} \\ &= \begin{bmatrix} 1 \\ 1 \end{bmatrix} \begin{bmatrix} 0 & 1 \end{bmatrix} \\ &= \begin{bmatrix} 0 & 1 \\ 0 & 1 \end{bmatrix} \end{aligned}

As an exercise, compute the right side of Equation (2), and make sure that you get the same answer as you just got for the left side.

Compute the following:

∣0⟩⟨1∣+∣1⟩⟨1∣|0\rangle \langle 1| + |1\rangle \langle 1|

In this section, we will consider linear operators. We first described these in Chapter 5, Transforming Space with Matrices. To reiterate, linear operators are linear transformations that map vectors from and to the same vector space. They are represented by square matrices. For just this section, I will put a “hat” or caret on the top of operators and use just the uppercase letter for matrices, as I want to be deliberate when referencing operators.

For instance, let’s look at the X̂ operator that transforms the zero and one states:

X^∣0⟩=∣1⟩\hat{X} |0\rangle = |1\rangle X^∣1⟩=∣0⟩\hat{X} |1\rangle = |0\rangle

Now, let’s come up with a matrix that represents this operator. The question becomes, which basis will we use? Let’s use the computational basis, which is |0⟩ and |1⟩. I will denote this set of basis vectors by the letter C. So, the X̂ operator in the C basis is represented by:

XC=[0110]X_C = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}

Now, I want to come up with a matrix representation of X̂ in the |+⟩, |-⟩ basis, which I will denote as +,-. Here is the matrix representation of the X̂ operator in the +,- basis:

X+,−=[100−1]X_{+,-} = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}

Now that we have refreshed our knowledge around linear operators (which I will sometimes just call operators), let’s look at another way we can represent an operator.

Representing an operator using the outer product

Section titled “Representing an operator using the outer product”

Can we use the outer product to represent an operator? Well, since the computation of an outer product results in a matrix, we most certainly can. But, given the previous discussion, since the outer product is a matrix, multiple outer products can represent an operator.

Let’s show that we can by writing an equation in which a matrix A transforms a vector:

A∣x⟩=∣y⟩A |x\rangle = |y\rangle

(3)

Now, let’s try to represent our matrix A by an outer product between two vectors |u⟩ and |v⟩:

A=∣u⟩⟨v∣A = |u\rangle \langle v|

Okay, let’s rewrite Equation (3) using our new outer product representation of the matrix A:

(∣u⟩⟨v∣)∣x⟩=∣y⟩(|u\rangle \langle v|) |x\rangle = |y\rangle

Due to the properties of the inner product and outer product that we have enumerated in the previous sections, we can rewrite this as:

∣u⟩(⟨v∣∣x⟩)=∣y⟩|u\rangle (\langle v | |x\rangle) = |y\rangle

Due to bra-ket notation, we can rewrite this with a bracket:

∣u⟩(⟨v∣x⟩)=∣y⟩|u\rangle (\langle v | x \rangle) = |y\rangle

(4)

We know that a bracket denotes an inner product and therefore produces a scalar, like so:

⟨v∣x⟩=αα∈C\begin{gathered} \langle v | x \rangle = \alpha \\ \alpha \in \mathbb{C} \end{gathered}

We can take our scalar α and put it back into Equation (4) and rearrange it:

∣u⟩α=∣y⟩α∣u⟩=∣y⟩\begin{gathered} |u\rangle \alpha = |y\rangle \\ \alpha |u\rangle = |y\rangle \end{gathered}

We now see that the ket |y⟩ that was a product of the matrix multiplication in Equation (3) is just another ket proportional to |u⟩. This is great because it shows that we can represent a linear operator with an outer product in bra-ket notation. Not only that, the resulting ket will be proportional to the ket we use in the outer product.

So, how can this be used? Let’s say we have an operator Ô defined with our plus and minus kets from before. This gives us a matrix O defined in an outer product, like so:

O=∣+⟩⟨−∣O = |+\rangle \langle -|

Now, we want to know what our new operator Ô does to the minus ket. We can do it without ever resorting to matrices, like so:

O^∣−⟩=O∣−⟩=(∣+⟩⟨−∣)∣−⟩\hat{O} |-\rangle = O |-\rangle = (|+\rangle \langle -|) |-\rangle O^∣−⟩=∣+⟩⟨−∣−⟩\hat{O} |-\rangle = |+\rangle \langle - | - \rangle O^∣−⟩=∣+⟩⋅1=∣+⟩\hat{O} |-\rangle = |+\rangle \cdot 1 = |+\rangle

So, our operator Ô turns the minus ket into the plus ket. You try it now.

What does the operator Ô do to the plus ket? In other words, what is the following?

O^∣+⟩\hat{O} |+\rangle

The following relation goes under a few names (the closure relation and the resolution of identity), but I will go with the name completeness relation. I will just state it without proving it, as the proof is rather laborious. We start with an orthonormal basis B where:

B={∣0⟩,∣1⟩,∣2⟩,…,∣n⟩}B = \{ |0\rangle, |1\rangle, |2\rangle, \ldots, |n\rangle \}

Then, the identity operator Î can be written as an outer product, like so:

I=∑i=0n∣i⟩⟨i∣I = \sum_{i=0}^{n} |i\rangle \langle i|

(5)

That’s it. Doesn’t seem like much, does it? But it is used over and over again in quantum computing to manipulate bra-ket expressions.

So, let’s apply this to an example. Let’s take our basis to be the plus and minus kets {|+⟩,|-⟩}. How then do we write the identity operator in this basis using the outer product representation? Well, using Equation (5), we get:

I=∣+⟩⟨+∣+∣−⟩⟨−∣I = |+\rangle \langle +| + |-\rangle \langle -|

Now, let’s test the completeness relation. If we apply the identity operator to the plus ket, we should get the plus ket back. Let’s see:

I∣+⟩=(∣+⟩⟨+∣+∣−⟩⟨−∣)∣+⟩Distribute the plus ketI∣+⟩=(∣+⟩⟨+∣+⟩+∣−⟩⟨−∣+⟩)Calculate the inner productsI∣+⟩=(∣+⟩⋅1+∣−⟩⋅0)=∣+⟩\begin{aligned} I |+\rangle &= (|+\rangle \langle +| + |-\rangle \langle -|) |+\rangle \\ &\text{Distribute the plus ket} \\ I |+\rangle &= (|+\rangle \langle + | + \rangle + |-\rangle \langle - | + \rangle) \\ &\text{Calculate the inner products} \\ I |+\rangle &= (|+\rangle \cdot 1 + |-\rangle \cdot 0) = |+\rangle \end{aligned}

Indeed, we do get the plus ket back, and hence, we can see how the completeness relation works in a simple example.

As we saw, we can manipulate operators using bra-ket notation without resorting to a matrix representation. We also saw the use of the dagger symbol when looking at the conjugate transpose. Now, I’d like to take a step back and put this all together to define the adjoint of an operator.

In this definition, we need to remember that for every ket |x⟩, there is a bra ⟨x|. Let’s say we have an operator  that acts on |x⟩ to give us |y⟩:

A^∣x⟩=∣y⟩\hat{A} |x\rangle = |y\rangle

Is there an associated operator we can use on the bra ⟨x| to give us the associated bra ⟨y|of the ket |y⟩? It happens that there is, and it is named the adjoint of the operator  and written this way:

⟨y∣=⟨x∣A^†\langle y| = \langle x| \hat{A}^\dagger

Now, there are rules when manipulating adjoint operators that you must keep in mind. First, the adjoint of a scalar is its complex conjugate:

α†=α∗\alpha^\dagger = \alpha^* α∈C\alpha \in \mathbb{C}

You can distribute the adjoint operation amongst scalar multiplication of operators, like so:

(αA^)†=α∗A^†(\alpha \hat{A})^\dagger = \alpha^* \hat{A}^\dagger

I will reiterate that bras and kets are the adjoints of each other:

(∣x⟩)†=⟨x∣(|x\rangle)^\dagger = \langle x| (⟨x∣)†=∣x⟩(\langle x|)^\dagger = |x\rangle

If you take the adjoint of an adjoint, you get back the original operator:

(A^†)†=A^(\hat{A}^\dagger)^\dagger = \hat{A}

You cannot distribute the adjoint across the multiplication of operators; rather, they anti-commute:

(A^B^)†=B^†A^†(\hat{A}\hat{B})^\dagger = \hat{B}^\dagger \hat{A}^\dagger

Finally, the adjoint can be distributed across a sum of operators:

(A^+B^+C^)†=A^†+B^†+C^†(\hat{A} + \hat{B} + \hat{C})^\dagger = \hat{A}^\dagger + \hat{B}^\dagger + \hat{C}^\dagger

I know this seems like a lot of rules, but you will need them when you manipulate bra-ket expressions in quantum computing.

Finally, if an operator is expressed as an outer product, we can take its adjoint in the following way:

A^=∣x⟩⟨y∣\hat{A} = |x\rangle \langle y| A^†=∣y⟩⟨x∣\hat{A}^\dagger = |y\rangle \langle x|

When an operator is represented as a matrix on an orthonormal basis, then its adjoint is the conjugate transpose of the matrix:

A^†=A†\hat{A}^\dagger = A^\dagger

Let’s look at a quick example. The X̂ operator we have looked at previously can be represented in the computational basis as an outer product thusly:

X=∣0⟩⟨1∣+∣1⟩⟨0∣X = |0\rangle \langle 1| + |1\rangle \langle 0|

Now, let’s take the adjoint of X:

X†=(∣0⟩⟨1∣+∣1⟩⟨0∣)†X^\dagger = (|0\rangle \langle 1| + |1\rangle \langle 0|)^\dagger X†=(∣0⟩⟨1∣)†+(∣1⟩⟨0∣)†X^\dagger = (|0\rangle \langle 1|)^\dagger + (|1\rangle \langle 0|)^\dagger X†=∣1⟩⟨0∣+∣0⟩⟨1∣X^\dagger = |1\rangle \langle 0| + |0\rangle \langle 1|

If you look closely, you should notice that the adjoint of X is equal to the original X. That’s because X̂ is Hermitian, which we will discuss in our next section.

There are certain types of linear operators that are special and need to be defined so that we can refer to them later in the book. You will also hear of them all the time in quantum computing.

Normal operators are ones that commute with their adjoint. For an operator Â, if:

A^A^†=A^†A^\hat{A}\hat{A}^\dagger = \hat{A}^\dagger \hat{A}

(6)

then  is normal. They are important because a normal operator is diagonalizable, which is something we will consider later in the book. The following operators (Hermitian, unitary, positive, and positive semi-definite) are all normal operators.

A normal matrix represents a normal operator, and it commutes with its conjugate transpose. Let’s look at an example normal matrix A:

A=[−i2+3i−2+3i0]A = \begin{bmatrix} -i & 2 + 3i \\ -2 + 3i & 0 \end{bmatrix}

Its conjugate transpose is:

A†=[i−2−3i2−3i0]A^\dagger = \begin{bmatrix} i & -2 - 3i \\ 2 - 3i & 0 \end{bmatrix}

Now, let’s see if A commutes with its conjugate transpose. We’ll calculate the left side of Equation (6) first:

AA†=[−i2+3i−2+3i0][i−2−3i2−3i0]AA^\dagger = \begin{bmatrix} -i & 2 + 3i \\ -2 + 3i & 0 \end{bmatrix} \begin{bmatrix} i & -2 - 3i \\ 2 - 3i & 0 \end{bmatrix} AA†=[(−i)i+(2+3i)(2−3i)(−i)(−2−3i)+(2+3i)⋅0(−2+3i)i+0⋅(2−3i)(−2+3i)(−2−3i)+0⋅0]AA^\dagger = \begin{bmatrix} (-i)i + (2 + 3i)(2 - 3i) & (-i)(-2 - 3i) + (2 + 3i) \cdot 0 \\ (-2 + 3i)i + 0 \cdot (2 - 3i) & (-2 + 3i)(-2 - 3i) + 0 \cdot 0 \end{bmatrix} AA†=[14−3+2i−3−2i13]AA^\dagger = \begin{bmatrix} 14 & -3 + 2i \\ -3 - 2i & 13 \end{bmatrix}

And now we do the same for the right side of Equation (6):

A†A=[i−2−3i2−3i0][−i2+3i−2+3i0]A^\dagger A = \begin{bmatrix} i & -2 - 3i \\ 2 - 3i & 0 \end{bmatrix} \begin{bmatrix} -i & 2 + 3i \\ -2 + 3i & 0 \end{bmatrix} A†A=[i(−i)+(−2−3i)(−2+3i)i(2+3i)+(−2−3i)⋅0(2−3i)(−i)+0⋅(−2+3i)(2−3i)(2+3i)+0⋅0]A^\dagger A = \begin{bmatrix} i(-i) + (-2 - 3i)(-2 + 3i) & i(2 + 3i) + (-2 - 3i) \cdot 0 \\ (2 - 3i)(-i) + 0 \cdot (-2 + 3i) & (2 - 3i)(2 + 3i) + 0 \cdot 0 \end{bmatrix} A†A=[14−3+2i−3−2i13]A^\dagger A = \begin{bmatrix} 14 & -3 + 2i \\ -3 - 2i & 13 \end{bmatrix}

And there you go – the answers match and, therefore, our example matrix A is a normal matrix!

Normal operators and matrices have special properties, namely:

  • They are diagonalizable; this will come up in the next chapter.
  • Their eigenvalues are the conjugates of the eigenvalues of their adjoints.
  • The eigenvectors associated with different eigenvalues are orthogonal.
  • A vector space can be defined by an orthogonal basis set of these eigenvectors.

The operators that follow are all special types of normal operators.

The definition of a Hermitian operator is rather terse and simple as well. A Hermitian operator is an operator that is equal to its adjoint:

A^=A^†\hat{A} = \hat{A}^\dagger

You will also hear these referred to as self-adjoint operators.

Since Hermitian operators are normal, they have all their properties plus one more:

  • All their eigenvalues are real numbers

Hermitian operators play an important part in quantum computing, as all measurements of a quantum state are done via a Hermitian operator.

Unitary operators are very important, as they describe the evolution of a quantum state and therefore all gates in quantum computing are unitary. They also have a very simple definition:

U^−1=U^†\hat{U}^{-1} = \hat{U}^\dagger

Using this definition, we can also derive that:

U^−1U^=U^U^−1=I^\hat{U}^{-1}\hat{U} = \hat{U}\hat{U}^{-1} = \hat{I} U^†U^=U^U^†=I^\hat{U}^\dagger \hat{U} = \hat{U}\hat{U}^\dagger = \hat{I}

Unitary operators have two unique properties. First, their eigenvalues are complex numbers of modulus one:

∣λ∣=1λ=eiθ,θ∈R\begin{gathered} |\lambda| = 1 \\ \lambda = e^{i\theta}, \theta \in \mathbb{R} \end{gathered}

And they preserve the inner product.

Let’s quickly prove that they preserve the inner product using bra-ket notation:

U^∣x⟩=∣x′⟩,U^∣y⟩=∣y′⟩\hat{U}|x\rangle = |x'\rangle, \hat{U}|y\rangle = |y'\rangle ⟨x′∣y′⟩=(⟨x∣U^†)(U^∣y⟩)=⟨x∣U^†U^⏟I^∣y⟩\langle x' | y' \rangle = (\langle x| \hat{U}^\dagger)(\hat{U}|y\rangle) = \langle x| \underbrace{\hat{U}^\dagger \hat{U}}_{\hat{I}} |y\rangle ⟨x′∣y′⟩=⟨x∣I^∣y⟩=⟨x∣y⟩\langle x' | y' \rangle = \langle x| \hat{I} |y\rangle = \langle x | y \rangle

A consequence of unitary operators preserving the inner product is that they also preserve the norm of transformed vectors.

Unitary operators are represented by unitary matrices, and similarly:

U−1=U†U^{-1} = U^\dagger

In general, unitary matrices are expressed this way:

U=[ab−eiφb∗eiφa∗],∣a∣2+∣b∣2=1U = \begin{bmatrix} a & b \\ -e^{i\varphi}b^* & e^{i\varphi}a^* \end{bmatrix}, \quad |a|^2 + |b|^2 = 1

The determinant is:

det⁡(U)=eiφ\det(U) = e^{i\varphi}

Since all quantum computing gates are unitary, let’s look at one and test it. The phase shift gate is represented in the computational basis by the following matrix:

P(φ)=[100eiφ]P(\varphi) = \begin{bmatrix} 1 & 0 \\ 0 & e^{i\varphi} \end{bmatrix}

To find the inverse of a matrix, we use our formula from Chapter 7, Eigen-Stuff:

A−1=[abcd]−1=1det⁡(A)[d−b−ca]A^{-1} = \begin{bmatrix} a & b \\ c & d \end{bmatrix}^{-1} = \frac{1}{\det(A)} \begin{bmatrix} d & -b \\ -c & a \end{bmatrix}

So, first, we have to find its determinant:

det⁡(P(φ))=1⋅eiφ−0=eiφ\det(P(\varphi)) = 1 \cdot e^{i\varphi} - 0 = e^{i\varphi}

Now, we just plug and play:

P−1(φ)=1eiφ[eiφ001]=[1001eiφ]P^{-1}(\varphi) = \frac{1}{e^{i\varphi}} \begin{bmatrix} e^{i\varphi} & 0 \\ 0 & 1 \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & \frac{1}{e^{i\varphi}} \end{bmatrix}

Now for the moment of truth – is it unitary?

P†(φ)=[100e−iφ]=[1001eiφ]P^\dagger(\varphi) = \begin{bmatrix} 1 & 0 \\ 0 & e^{-i\varphi} \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & \frac{1}{e^{i\varphi}} \end{bmatrix}

Indeed, it is! Let’s move on to projection operators.

We covered projection linear transformations in Chapter 5, Using Matrices to Transform Space. In that chapter, we defined a projection this way. If you have a linear transformation P, then if the following condition holds, it is a projection:

(7)

P2=PP^2 = P

In quantum computing, they are defined a little differently:

Given a normalized state ∣ψ⟩|\psi\rangle the projection operator for this state is:

(8)

P^=∣ψ⟩⟨ψ∣\hat{P} = |\psi\rangle \langle \psi|

Equation (7) still holds for projection operators, but given the definition in Equation (8), you also get that the projection operator is Hermitian:

P^=P^†\hat{P} = \hat{P}^\dagger

All Projections Are Orthogonal in Quantum Computing

While there are non-orthogonal projection transformations in mathematics, we do not use them in quantum computing, so when you hear projection, assume that it is an orthogonal projection unless explicitly told otherwise.

If two projection operators commute, then their product is also a projection operator:

If P^1P^2=P^2P^1 then\text{If } \hat{P}_1 \hat{P}_2 = \hat{P}_2 \hat{P}_1 \text{ then} P^1P^2 is also a projection operator.\hat{P}_1 \hat{P}_2 \text{ is also a projection operator.}

In quantum computing, we often project one vector space onto another. Let’s say I have a vector in an n-dimensional vector space defined by the basis {|0⟩,|1⟩,…|n⟩} and I want to project it onto an m-dimensional subspace defined by the basis {|0⟩,|1⟩,…|m⟩}. Both bases are orthonormal. Then, the projection operator that projects onto our subspace is defined by:

Pm≡∑i=1m∣i⟩⟨i∣P_m \equiv \sum_{i=1}^{m} |i\rangle \langle i|

The only eigenvalues a projection operator can have are zero and one. Now, let’s move on to positive operators.

Positive operators are happy and optimistic, always looking on the bright side of life. Okay, maybe that’s a joke :) Mathematically, positive operators are Hermitian. There are actually two types of positive operators, and they are only slightly different.

An operator  is said to be positive definite if:

⟨ψ∣A^∣ψ⟩>0\langle \psi | \hat{A} | \psi \rangle > 0

(9)

Please consult the appendix on Bra-Ket notation if you are unfamiliar with the notation in Equation (9).

An operator  is said to be positive semidefinite if:

⟨ψ∣A^∣ψ⟩≥0\langle \psi | \hat{A} | \psi \rangle \ge 0

So the only difference is that positive definite operators do not include zero in their definition. All eigenvalues of positive operators are non-negative.

Okay, well, we’re done with types of operators! There are quite a few, but they will come up in different segments of quantum computing, so try to keep them all straight.

No More Hats

As I said at the beginning of the section on operators, I will drop the hat or caret on top of operators, and you should be able to derive whether I mean an operator or a matrix from the context in which it is used.

Tensor products are a way to combine vector spaces. One of the postulates of quantum mechanics is that the state of a qubit is completely described by a unit vector in a Hilbert space. The problem then becomes how to deal with more than one qubit. This is where a tensor product comes in. Each qubit has its own Hilbert space, and to describe many qubits as a system, we need to combine all their Hilbert spaces into one bigger Hilbert space.

Mathematically, that means that if we have a Hilbert space H and another Hilbert space J, we denote their tensor product as:

M=H⊗JM = H \otimes J

If H is an h dimensional space and J is a j dimensional space, then the dimension of the combined space M is h ⋅ j. In other words:

dim⁡(M)=dim⁡(H)⋅dim⁡(J)\dim(M) = \dim(H) \cdot \dim(J)

Before we go any farther, let’s look at the tensor product of two vectors.

The tensor product of two vectors is denoted in the following way in bra-ket notation. You’ll notice that there are four different ways to notate it, so be careful when you come across it in quantum computing literature and know exactly what you are dealing with:

∣u⟩∣v⟩or∣u⟩⊗∣v⟩or∣uv⟩or∣u,v⟩|u\rangle|v\rangle \quad \text{or} \quad |u\rangle \otimes |v\rangle \quad \text{or} \quad |uv\rangle \quad \text{or} \quad |u,v\rangle

Here are some of the properties of the tensor product:

  • For a scalar s and a vector |u⟩ in U and vector |v⟩ in V, then:
s(∣u⟩⊗∣v⟩)=(s∣u⟩)⊗∣v⟩=∣u⟩⊗(s∣v⟩)s(|u\rangle \otimes |v\rangle) = (s|u\rangle) \otimes |v\rangle = |u\rangle \otimes (s|v\rangle)
  • It is both right and left distributive. For vectors |v⟩ and |w⟩ in V and vectors |u⟩ and |z⟩ in U, then:
(∣v⟩+∣w⟩)⊗∣u⟩=∣v⟩⊗∣u⟩+∣w⟩⊗∣u⟩(|v\rangle + |w\rangle) \otimes |u\rangle = |v\rangle \otimes |u\rangle + |w\rangle \otimes |u\rangle ∣v⟩⊗(∣u⟩+∣z⟩)=∣v⟩⊗∣u⟩+∣v⟩⊗∣z⟩|v\rangle \otimes (|u\rangle + |z\rangle) = |v\rangle \otimes |u\rangle + |v\rangle \otimes |z\rangle
  • It is not commutative, so in general:
∣v⟩⊗∣u⟩≠∣u⟩⊗∣v⟩|v\rangle \otimes |u\rangle \neq |u\rangle \otimes |v\rangle

Now, let’s look at how we do the tensor product for actual column vectors. When the tensor product is implemented with arrays of numbers, it is actually the Kronecker product. Keep this in mind when researching and reading about the tensor product.

So, here is the Kronecker product defined mathematically for vectors. The tensor product of vectors is defined as:

∣x⟩⊗∣y⟩=∣xy⟩=[x1x2⋮xh]⊗[y1y2⋮yk]=[x1⋅y1x1⋅y2⋮x1⋅ykx2⋅y1x2⋅y2⋮xh⋅y1xh⋅y2⋮xh⋅yk]|x\rangle \otimes |y\rangle = |xy\rangle = \begin{bmatrix} x_1 \\ x_2 \\ \vdots \\ x_h \end{bmatrix} \otimes \begin{bmatrix} y_1 \\ y_2 \\ \vdots \\ y_k \end{bmatrix} = \begin{bmatrix} x_1 \cdot y_1 \\ x_1 \cdot y_2 \\ \vdots \\ x_1 \cdot y_k \\ x_2 \cdot y_1 \\ x_2 \cdot y_2 \\ \vdots \\ x_h \cdot y_1 \\ x_h \cdot y_2 \\ \vdots \\ x_h \cdot y_k \end{bmatrix}

In other words, take the first component of |x⟩ and multiply it by every component of |y⟩, then take the second component of |x⟩ and multiply it by every component of |y⟩, and repeat this procedure until all of the components of |x⟩ are exhausted! That’s a lot to say! Let’s look at a definition with just 1 × 2 vectors:

∣ψ⟩=[ab]⊗[cd]=[acadbcbd]|\psi\rangle = \begin{bmatrix} a \\ b \end{bmatrix} \otimes \begin{bmatrix} c \\ d \end{bmatrix} = \begin{bmatrix} ac \\ ad \\ bc \\ bd \end{bmatrix}

That’s not bad, right? By the way, if you noticed, the tensor product of two vectors always produces another vector. Here is an example for you:

[20]⊗[31]=[2⋅32⋅10⋅30⋅1]=[6200]\begin{bmatrix} 2 \\ 0 \end{bmatrix} \otimes \begin{bmatrix} 3 \\ 1 \end{bmatrix} = \begin{bmatrix} 2 \cdot 3 \\ 2 \cdot 1 \\ 0 \cdot 3 \\ 0 \cdot 1 \end{bmatrix} = \begin{bmatrix} 6 \\ 2 \\ 0 \\ 0 \end{bmatrix}

Alright, how about some examples with our two favorite vectors |0⟩ and |1⟩? Let’s do a tensor product between them:

∣0⟩⊗∣0⟩=∣00⟩=[10]⊗[10]=[1000]∣0⟩⊗∣1⟩=∣01⟩=[10]⊗[01]=[0100]|0\rangle \otimes |0\rangle = |00\rangle = \begin{bmatrix} 1 \\ 0 \end{bmatrix} \otimes \begin{bmatrix} 1 \\ 0 \end{bmatrix} = \begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \end{bmatrix} \qquad |0\rangle \otimes |1\rangle = |01\rangle = \begin{bmatrix} 1 \\ 0 \end{bmatrix} \otimes \begin{bmatrix} 0 \\ 1 \end{bmatrix} = \begin{bmatrix} 0 \\ 1 \\ 0 \\ 0 \end{bmatrix}
  • What is |11⟩?
  • What is |10⟩?

You will remember that we can completely describe a vector space by its basis. The same is true of a tensor product space. To get the basis of the tensor product space, you take the tensor product of each basis vector in one space with every basis vector in the other space involved in the tensor product. I hope you remember the Cartesian product from Chapter 3, Foundations. A quick reminder is that if I have two sets A={x, y, z} and B={1, 2, 3}, their Cartesian product is all the ordered pairs shown in the following graphic:

A×B={(x,1),(x,2),(x,3),(y,1),(y,2),(y,3),(z,1),(z,2),(z,3)}A \times B = \{ (x,1), (x,2), (x,3), (y,1), (y,2), (y,3), (z,1), (z,2), (z,3) \}

Figure 8.3 – An example of the Cartesian product of A × B [1]

So, another way to describe the basis of the new tensor product space is to first take the Cartesian product of all basis vectors and then do the tensor product between all the ordered pairs. And there you go!

Let’s look at an example. What if we had two vector spaces, U and V, that were both two-dimensional? The basis for U is {|0⟩,|1⟩}, and the basis for V is {|+⟩,|-⟩}. Then, what is the basis for the tensor product of U and V? We have to calculate all the following tensor products:

∣0⟩⊗∣+⟩∣0⟩⊗∣−⟩∣1⟩⊗∣+⟩∣1⟩⊗∣−⟩\begin{gathered} |0\rangle \otimes |+\rangle \\ |0\rangle \otimes |-\rangle \\ |1\rangle \otimes |+\rangle \\ |1\rangle \otimes |-\rangle \end{gathered}

So let’s look at one of these and calculate it using the Kronecker product:

∣0⟩⊗∣+⟩=[10]⊗[1212]=[121200]|0\rangle \otimes |+\rangle = \begin{bmatrix} 1 \\ 0 \end{bmatrix} \otimes \begin{bmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{bmatrix} = \begin{bmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \\ 0 \\ 0 \end{bmatrix}

So, that is one of the four vectors that are in the basis of our tensor product. Of course, once we have a basis, we can describe every vector in the space as a linear combination of our new basis vectors.

Calculate the Kronecker product of the following:

∣0⟩⊗∣−⟩∣1⟩⊗∣+⟩∣1⟩⊗∣−⟩\begin{gathered} |0\rangle \otimes |-\rangle \\ |1\rangle \otimes |+\rangle \\ |1\rangle \otimes |-\rangle \end{gathered}

In bra-ket notation, there are rules to follow about the tensor product of linear operators. First, let’s define the tensor product of operators in bra-ket notation. Let’s say we have a vector |v⟩ and linear operator A in vector space V. We also have a vector |u⟩ and linear operator B in vector space U. Then, A ⊗ B on the tensor product space of U ⊗ V is defined as:

(A⊗B)(∣v⟩⊗∣u⟩)≡A∣v⟩⊗B∣u⟩(A \otimes B)(|v\rangle \otimes |u\rangle) \equiv A|v\rangle \otimes B|u\rangle

Let’s look at an example. We’ll say we have two familiar linear operators X and Z and vector states |0⟩ and |1⟩. Here is the math of our example:

(X⊗Z)(∣0⟩⊗∣1⟩)=X∣0⟩⊗Z∣1⟩X∣0⟩=∣1⟩ and Z∣1⟩=−∣1⟩ soX∣0⟩⊗Z∣1⟩=∣1⟩⊗−∣1⟩=−∣11⟩\begin{aligned} (X \otimes Z)(|0\rangle \otimes |1\rangle) &= X|0\rangle \otimes Z|1\rangle \\ X|0\rangle = |1\rangle \text{ and } Z|1\rangle = -|1\rangle &\text{ so} \\ X|0\rangle \otimes Z|1\rangle &= |1\rangle \otimes -|1\rangle = -|11\rangle \end{aligned}

(10)

When we represent operators with matrices, we can calculate the tensor product using the Kronecker product. It is very similar to the Kronecker product for vectors, as column vectors are just n × 1 matrices. You basically take the first matrix entries and multiply them by the second matrix. Here’s the definition. Given an m x n matrix A and a p × q matrix B, then their Kronecker product is an (m ⋅ p) × (n ⋅ q) matrix, like so:

A⊗B=[a11B⋯a1nB⋮⋱⋮am1B⋯amnB]\mathbf{A} \otimes \mathbf{B} = \begin{bmatrix} a_{11}\mathbf{B} & \cdots & a_{1n}\mathbf{B} \\ \vdots & \ddots & \vdots \\ a_{m1}\mathbf{B} & \cdots & a_{mn}\mathbf{B} \end{bmatrix}

That’s pretty abstract; let’s look at an example. Let’s make matrix A a 2 × 2 matrix and B a 2 × 2 matrix as well. What will be the dimension of their Kronecker product? From the definition, we see it will be 4 × 4. Here’s the example:

[1134]⊗[0560]=[1[0560]1[0560]3[0560]4[0560]]=[1⋅01⋅51⋅01⋅51⋅61⋅01⋅61⋅03⋅03⋅54⋅04⋅53⋅63⋅04⋅64⋅0]=[05056060015020180240]\begin{aligned} \begin{bmatrix} 1 & 1 \\ 3 & 4 \end{bmatrix} \otimes \begin{bmatrix} 0 & 5 \\ 6 & 0 \end{bmatrix} &= \begin{bmatrix} 1 \begin{bmatrix} 0 & 5 \\ 6 & 0 \end{bmatrix} & 1 \begin{bmatrix} 0 & 5 \\ 6 & 0 \end{bmatrix} \\ 3 \begin{bmatrix} 0 & 5 \\ 6 & 0 \end{bmatrix} & 4 \begin{bmatrix} 0 & 5 \\ 6 & 0 \end{bmatrix} \end{bmatrix} = \begin{bmatrix} 1 \cdot 0 & 1 \cdot 5 & 1 \cdot 0 & 1 \cdot 5 \\ 1 \cdot 6 & 1 \cdot 0 & 1 \cdot 6 & 1 \cdot 0 \\ 3 \cdot 0 & 3 \cdot 5 & 4 \cdot 0 & 4 \cdot 5 \\ 3 \cdot 6 & 3 \cdot 0 & 4 \cdot 6 & 4 \cdot 0 \end{bmatrix} = \begin{bmatrix} 0 & 5 & 0 & 5 \\ 6 & 0 & 6 & 0 \\ 0 & 15 & 0 & 20 \\ 18 & 0 & 24 & 0 \end{bmatrix} \end{aligned}

What is B ⊗ A?

Now, let’s redo our example from earlier, Equation (10), in matrix form to double-check our work:

(X⊗Z)(∣0⟩⊗∣1⟩)=([0110]⊗[100−1])([10]⊗[01])=[0010000−110000−100][0100]=[000−1]=−∣1⟩⊗∣1⟩=−∣11⟩\begin{aligned} &(X \otimes Z)(|0\rangle \otimes |1\rangle) \\ &= \left( \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} \otimes \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} \right) \left( \begin{bmatrix} 1 \\ 0 \end{bmatrix} \otimes \begin{bmatrix} 0 \\ 1 \end{bmatrix} \right) \\ &= \begin{bmatrix} 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & -1 \\ 1 & 0 & 0 & 0 \\ 0 & -1 & 0 & 0 \end{bmatrix} \begin{bmatrix} 0 \\ 1 \\ 0 \\ 0 \end{bmatrix} \\ &= \begin{bmatrix} 0 \\ 0 \\ 0 \\ -1 \end{bmatrix} = -|1\rangle \otimes |1\rangle = -|11\rangle \end{aligned}

Indeed, we get the same answer, which is assuring! Finally, let’s look at the inner product for tensor product spaces.

This is actually probably the most important definition when it comes to the tensor product because it enables us to have a Hilbert space as the output of our tensor product. Without further ado, here is the definition of the inner product for the tensor product of two vector spaces.

Two Hilbert spaces V and U create a tensor product space W:

W=V⊗UW = V \otimes U

For vectors |v⟩ and |x⟩ in V and vectors |u⟩ and |z⟩ in U, we define two composite vectors in W:

∣w⟩=∣v⟩⊗∣x⟩∣y⟩=∣u⟩⊗∣z⟩\begin{gathered} |w\rangle = |v\rangle \otimes |x\rangle \\ |y\rangle = |u\rangle \otimes |z\rangle \end{gathered}

We now define the inner product of these two composite vectors |w⟩ and |y⟩ as:

⟨w∣y⟩=(⟨v∣⊗⟨x∣)(∣u⟩⊗∣z⟩)=⟨v∣u⟩⟨x∣z⟩\langle w | y \rangle = (\langle v| \otimes \langle x|)(|u\rangle \otimes |z\rangle) = \langle v | u \rangle \langle x | z \rangle

(11)

We were able to simplify in Equation (11) due to the mixed-product property of the Kronecker product:

(A⊗B)(C⊗D)=(AC)⊗(BD)(A \otimes B)(C \otimes D) = (AC) \otimes (BD)

The inner product of two of our computation basis vectors in ℂ4 should be zero. Let’s check:

⟨00∣11⟩=(⟨0∣⟨0∣)(∣1⟩∣1⟩)=⟨0∣1⟩⟨0∣1⟩=0⋅0=0\langle 00 | 11 \rangle = (\langle 0| \langle 0|)(|1\rangle |1\rangle) = \langle 0 | 1 \rangle \langle 0 | 1 \rangle = 0 \cdot 0 = 0

Indeed, it is! Whew!

Calculate the following inner products:

⟨00∣01⟩⟨00∣10⟩⟨10∣01⟩\begin{gathered} \langle 00 | 01 \rangle \\ \langle 00 | 10 \rangle \\ \langle 10 | 01 \rangle \end{gathered}

This concludes our discussion of tensor products.

We have covered a lot of ground in this chapter, but I hope you feel it’s been worth it. I think it has because it brings everything we have worked on in the previous chapters together into one framework. Also, we can do real math with quantum computing now that we just couldn’t do before. We will build on this in the last chapter to reach new heights in quantum computing that, at first, probably looked unattainable!