Skip to content
ImagineWorld

Advanced Concepts

node_idnode-book_essential-mathematics-for-quantum-computing_chapter-09-advanced-concepts
node_typechapter_node
schema_profileworld.chapter_node.v1
entropyhigh
manifoldworld
domainimagineworld.net
authorityinforms
layercorpus
statusactive
chapter_num9
chapter_titleAdvanced Concepts
governed_byCORPUS
constitutional_citationCONSTITUTION
local graph

In this chapter, we will go into some advanced linear algebra concepts. These will not come up all the time in quantum computing, but when they do, you should know what they are and where to find information about them. Almost all the topics are about decomposing a matrix. This becomes important in quantum computing because when we come up with a unitary transformation that we’d like to do on a quantum computer, we will only have certain unitary operators to use on it. Then, it becomes a question of which combination of available operators we should use so that we can perform our overall unitary transformation. Along the way, we will also look at important inequalities and how to represent functions that have matrices in them.

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

  • Gram-Schmidt
  • Cauchy-Schwarz and triangle inequalities
  • Spectral decomposition
  • Singular value decomposition
  • Polar decomposition
  • Operator functions and the matrix exponential

The Gram-Schmidt process is an algorithm in which you input a basis set of vectors and it outputs a basis set that is orthogonal. We can then normalize that set of vectors, and suddenly, we have an orthonormal set of basis vectors! This is very helpful in quantum computing and other areas of applied math, as an orthonormal basis is usually the best basis for computations and representing vectors with coordinates.

Gram-Schmidt Is a Decomposition Tool

While we won’t go into it in this book, the Gram-Schmidt process is used in certain decompositions, so it’s good to know from that vantage point too.

Let’s look at an example before getting into the nitty-gritty of the actual procedure (which can be dry and dull). Let’s say I have a basis for ℂ2, such as the following:

∣x1⟩=[20],∣x2⟩=[1−2i]|x_1\rangle = \begin{bmatrix} 2 \\ 0 \end{bmatrix}, \quad |x_2\rangle = \begin{bmatrix} 1 \\ -2i \end{bmatrix}

These vectors are not orthogonal, since their inner product does not equal 0:

⟨x1∣x2⟩=[20][1−2i]=2−0=2\langle x_1 | x_2 \rangle = \begin{bmatrix} 2 & 0 \end{bmatrix} \begin{bmatrix} 1 \\ -2i \end{bmatrix} = 2 - 0 = 2

They are also not normalized. Now, I want to get an orthonormal basis for ℂ2 using these two vectors. Here’s the process. The first step is the easiest; we just choose the first vector in our set, |x1⟩, to be the first vector in our soon to be orthogonal basis set (denoted by |v1⟩):

∣v1⟩=∣x1⟩=[20]|v_1\rangle = |x_1\rangle = \begin{bmatrix} 2 \\ 0 \end{bmatrix}

That was easy enough. This is the easiest step of Gram-Schmidt, which is always the first step. Now for the second step. Here is the formula:

∣v2⟩=∣x2⟩−⟨x2∣v1⟩⟨v1∣v1⟩∣v1⟩|v_2\rangle = |x_2\rangle - \frac{\langle x_2 | v_1 \rangle}{\langle v_1 | v_1 \rangle} |v_1\rangle

Let’s calculate the numerator of the right part of the equation first:

⟨x2∣v1⟩=[12i][20]=2\langle x_2 | v_1 \rangle = \begin{bmatrix} 1 & 2i \end{bmatrix} \begin{bmatrix} 2 \\ 0 \end{bmatrix} = 2

Now for the denominator:

⟨v1∣v1⟩=[20][20]=4\langle v_1 | v_1 \rangle = \begin{bmatrix} 2 & 0 \end{bmatrix} \begin{bmatrix} 2 \\ 0 \end{bmatrix} = 4

Finally, let’s put it all together!

∣v2⟩=∣x2⟩−⟨x2∣v1⟩⟨v1∣v1⟩∣v1⟩⟨x2∣v1⟩⟨v1∣v1⟩=24=12∣v2⟩=[1−2i]−12[20]∣v2⟩=[1−2i]−[10]=[0−2i]\begin{aligned} |v_2\rangle &= |x_2\rangle - \frac{\langle x_2 | v_1 \rangle}{\langle v_1 | v_1 \rangle} |v_1\rangle \\ \frac{\langle x_2 | v_1 \rangle}{\langle v_1 | v_1 \rangle} &= \frac{2}{4} = \frac{1}{2} \\ |v_2\rangle &= \begin{bmatrix} 1 \\ -2i \end{bmatrix} - \frac{1}{2} \begin{bmatrix} 2 \\ 0 \end{bmatrix} \\ |v_2\rangle &= \begin{bmatrix} 1 \\ -2i \end{bmatrix} - \begin{bmatrix} 1 \\ 0 \end{bmatrix} = \begin{bmatrix} 0 \\ -2i \end{bmatrix} \end{aligned}

So, our new orthogonal basis for ℂ2 is the following basis set:

∣v1⟩=[20],∣v2⟩=[0−2i]|v_1\rangle = \begin{bmatrix} 2 \\ 0 \end{bmatrix}, \quad |v_2\rangle = \begin{bmatrix} 0 \\ -2i \end{bmatrix}

You should calculate their inner product to ensure it is zero and that they are indeed orthogonal. So, now all we need to do is normalize them to get an orthonormal basis! Let’s do |v1⟩ first:

∥v1∥2=⟨v1∣v1⟩=4∥v1∥=4=2∣e1⟩=∣v1⟩∥v1∥=[20]⋅12=[10]\begin{aligned} \|v_1\|^2 &= \langle v_1 | v_1 \rangle = 4 \\ \|v_1\| &= \sqrt{4} = 2 \\ |e_1\rangle &= \frac{|v_1\rangle}{\|v_1\|} = \begin{bmatrix} 2 \\ 0 \end{bmatrix} \cdot \frac{1}{2} = \begin{bmatrix} 1 \\ 0 \end{bmatrix} \end{aligned}

Now for |v2⟩:

∥v2∥2=⟨v2∣v2⟩=[02i][0−2i]=4∥v2∥=4=2∣e2⟩=∣v2⟩∥v2∥=[0−2i]⋅12=[0−i]\begin{aligned} \|v_2\|^2 &= \langle v_2 | v_2 \rangle = \begin{bmatrix} 0 & 2i \end{bmatrix} \begin{bmatrix} 0 \\ -2i \end{bmatrix} = 4 \\ \|v_2\| &= \sqrt{4} = 2 \\ |e_2\rangle &= \frac{|v_2\rangle}{\|v_2\|} = \begin{bmatrix} 0 \\ -2i \end{bmatrix} \cdot \frac{1}{2} = \begin{bmatrix} 0 \\ -i \end{bmatrix} \end{aligned}

We now have an orthonormal basis for ℂ2, as shown in the following:

∣e1⟩=[10],∣e2⟩=[0−i]|e_1\rangle = \begin{bmatrix} 1 \\ 0 \end{bmatrix}, \quad |e_2\rangle = \begin{bmatrix} 0 \\ -i \end{bmatrix}

And this all started from two linearly independent vectors using the Gram-Schmidt process. Pretty cool, eh?

Now, it’s time to lay out the entire process:

Given a basis B={∣x1⟩,∣x2⟩,…,∣xp⟩}B = \{|x_1\rangle, |x_2\rangle, \ldots, |x_p\rangle\} for a vector space VV, define

∣v1⟩=∣x1⟩∣v2⟩=∣x2⟩−⟨x2∣v1⟩⟨v1∣v1⟩∣v1⟩∣v3⟩=∣x3⟩−⟨x3∣v1⟩⟨v1∣v1⟩∣v1⟩−⟨x3∣v2⟩⟨v2∣v2⟩∣v2⟩⋮∣vp⟩=∣xp⟩−⟨xp∣v1⟩⟨v1∣v1⟩∣v1⟩−⟨xp∣v2⟩⟨v2∣v2⟩∣v2⟩−⋯−⟨xp∣vp−1⟩⟨vp−1∣vp−1⟩∣vp−1⟩\begin{aligned} |v_1\rangle &= |x_1\rangle \\ |v_2\rangle &= |x_2\rangle - \frac{\langle x_2 | v_1 \rangle}{\langle v_1 | v_1 \rangle} |v_1\rangle \\ |v_3\rangle &= |x_3\rangle - \frac{\langle x_3 | v_1 \rangle}{\langle v_1 | v_1 \rangle} |v_1\rangle - \frac{\langle x_3 | v_2 \rangle}{\langle v_2 | v_2 \rangle} |v_2\rangle \\ &\vdots \\ |v_p\rangle &= |x_p\rangle - \frac{\langle x_p | v_1 \rangle}{\langle v_1 | v_1 \rangle} |v_1\rangle - \frac{\langle x_p | v_2 \rangle}{\langle v_2 | v_2 \rangle} |v_2\rangle - \cdots - \frac{\langle x_p | v_{p-1} \rangle}{\langle v_{p-1} | v_{p-1} \rangle} |v_{p-1}\rangle \end{aligned}

Then {∣v1⟩,∣v2⟩,…,∣vp⟩}\{|v_1\rangle, |v_2\rangle, \ldots, |v_p\rangle\} is an orthogonal basis for VV.

This algorithm will give us an orthogonal basis; then, all we have to do is normalize each vector, and we get an orthonormal basis! Let’s move on to two important inequalities.

The Cauchy-Schwarz inequality is one of the most important inequalities in mathematics. Succinctly stated, it says that the absolute value of the inner product of two vectors is less than or equal to the norm of those two vectors multiplied together. In fact, they are only equal if the two vectors are linearly dependent:

∣⟨u∣v⟩∣≤∥u∥∥v∥|\langle u | v \rangle| \le \|u\| \|v\|

There are several proofs of this inequality, which I encourage you to seek out if you are interested. But, in the totality of things, knowing this inequality is all that is really required for quantum computing.

The other major inequality is the triangle inequality. It comes from our old friend Euclid in his book The Elements. Succinctly stated, it says that the length of two sides of a triangle must always be more than the length of one side. They will only be equal in the corner case when the triangle has zero area. It is very intuitive once you see some example triangles. Here are some triangles that show how the side z is less than the sum of sides x and y:

Figure 9.1 – Three example triangles for the triangle inequality [1]

Now, let’s state the triangle inequality:

∥x+y∥≤∥x∥+∥y∥\|x + y\| \le \|x\| + \|y\|

You’ll notice that the way it is notated is using the norms of vectors. Let’s look at an example. Let’s say we have the two following kets:

∣x⟩=2∣0⟩+3i∣1⟩∣y⟩=2i∣0⟩−∣1⟩\begin{aligned} |x\rangle &= 2|0\rangle + 3i|1\rangle \\ |y\rangle &= 2i|0\rangle - |1\rangle \end{aligned}

Their corresponding bras (that is, their conjugate transpose) are:

⟨x∣=2⟨0∣−3i⟨1∣⟨y∣=−2i⟨0∣−⟨1∣\begin{aligned} \langle x| &= 2\langle 0| - 3i\langle 1| \\ \langle y| &= -2i\langle 0| - \langle 1| \end{aligned}

Now, the norm of |x⟩ is:

∥x∥2=⟨x∣x⟩=(2⟨0∣−3i⟨1∣)(2∣0⟩+3i∣1⟩)∥x∥2=⟨x∣x⟩=4⟨0∣0⟩+6i⟨0∣1⟩ 0−6i⟨1∣0⟩ 0+9⟨1∣1⟩∥x∥2=⟨x∣x⟩=4+9=13∥x∥=13\begin{aligned} \|x\|^2 &= \langle x | x \rangle = \bigl(2\langle 0| - 3i\langle 1|\bigr)\bigl(2|0\rangle + 3i|1\rangle\bigr) \\ \|x\|^2 &= \langle x | x \rangle = 4\langle 0|0\rangle + 6i\cancel{\langle 0|1\rangle}^{\,0} - 6i\cancel{\langle 1|0\rangle}^{\,0} + 9\langle 1|1\rangle \\ \|x\|^2 &= \langle x | x \rangle = 4 + 9 = 13 \\ \|x\| &= \sqrt{13} \end{aligned}

The norm of |y⟩ is:

∥y∥2=⟨y∣y⟩=(−2i⟨0∣−⟨1∣)(2i∣0⟩−∣1⟩)∥y∥2=⟨y∣y⟩=4⟨0∣0⟩+2i⟨0∣1⟩ 0−2i⟨1∣0⟩ 0+1⟨1∣1⟩∥y∥2=⟨y∣y⟩=4+1=5∥y∥=5\begin{aligned} \|y\|^2 &= \langle y | y \rangle = \bigl(-2i\langle 0| - \langle 1|\bigr)\bigl(2i|0\rangle - |1\rangle\bigr) \\ \|y\|^2 &= \langle y | y \rangle = 4\langle 0|0\rangle + 2i\cancel{\langle 0|1\rangle}^{\,0} - 2i\cancel{\langle 1|0\rangle}^{\,0} + 1\langle 1|1\rangle \\ \|y\|^2 &= \langle y | y \rangle = 4 + 1 = 5 \\ \|y\| &= \sqrt{5} \end{aligned}

So, the right side of the triangle inequality is:

∥x∥+∥y∥=13+5≈5.84\|x\| + \|y\| = \sqrt{13} + \sqrt{5} \approx 5.84

Let’s calculate the left side of the triangle inequality:

∣x⟩+∣y⟩=2∣0⟩+3i∣1⟩+2i∣0⟩−∣1⟩∣x⟩+∣y⟩=(2+2i)∣0⟩+(−1+3i)∣1⟩∥x+y∥2=((2−2i)⟨0∣+(−1−3i)⟨1∣)((2+2i)∣0⟩+(−1+3i)∣1⟩)∥x+y∥2=(4+4)⟨0∣0⟩+(1+9)⟨1∣1⟩∥x+y∥2=8+10=18∥x+y∥=18=32≈4.24\begin{aligned} |x\rangle + |y\rangle &= 2|0\rangle + 3i|1\rangle + 2i|0\rangle - |1\rangle \\ |x\rangle + |y\rangle &= (2 + 2i)|0\rangle + (-1 + 3i)|1\rangle \\ \|x + y\|^2 &= \bigl((2 - 2i)\langle 0| + (-1 - 3i)\langle 1|\bigr)\bigl((2 + 2i)|0\rangle + (-1 + 3i)|1\rangle\bigr) \\ \|x + y\|^2 &= (4 + 4)\langle 0|0\rangle + (1 + 9)\langle 1|1\rangle \\ \|x + y\|^2 &= 8 + 10 = 18 \\ \|x + y\| &= \sqrt{18} = 3\sqrt{2} \approx 4.24 \end{aligned}

So, the triangle equality holds for our two kets |x⟩ and |y⟩ since 4.24 ≤ 5.84. Now, we will move to look at decompositions of matrices.

The spectrum of a square matrix is the set of its eigenvalues. There is a cool theorem in linear algebra that states that all matrices representing a linear operator have the same spectrum. Before we use the spectrum though, we need to talk about diagonal matrices.

The main diagonal of a matrix is every entry where the row index equals the column index. Examples make this very easy to see. All the following matrices have the letter d on their main diagonal:

[d32d],[d224d421d],[d4234d2451d4122d]\begin{bmatrix} d & 3 \\ 2 & d \end{bmatrix}, \quad \begin{bmatrix} d & 2 & 2 \\ 4 & d & 4 \\ 2 & 1 & d \end{bmatrix}, \quad \begin{bmatrix} d & 4 & 2 & 3 \\ 4 & d & 2 & 4 \\ 5 & 1 & d & 4 \\ 1 & 2 & 2 & d \end{bmatrix}

Now, a diagonal matrix has zero on all entries outside the main diagonal. Here are examples of diagonal matrices:

[200i],[3000−20004],[3000030000i00005]\begin{bmatrix} 2 & 0 \\ 0 & i \end{bmatrix}, \quad \begin{bmatrix} 3 & 0 & 0 \\ 0 & -2 & 0 \\ 0 & 0 & 4 \end{bmatrix}, \quad \begin{bmatrix} 3 & 0 & 0 & 0 \\ 0 & 3 & 0 & 0 \\ 0 & 0 & i & 0 \\ 0 & 0 & 0 & 5 \end{bmatrix}

Here are two cool features of diagonal matrices that make them all the rage at linear algebra parties. One, all their eigenvalues are on their main diagonal. Two, they are very easy to exponentiate. Let’s see the latter in action real quick:

[2002]2=[220022]=[4004][2002]3=[230023]=[8008]⋮[2002]n=[2n002n]\begin{aligned} \begin{bmatrix} 2 & 0 \\ 0 & 2 \end{bmatrix}^2 &= \begin{bmatrix} 2^2 & 0 \\ 0 & 2^2 \end{bmatrix} = \begin{bmatrix} 4 & 0 \\ 0 & 4 \end{bmatrix} \\ \begin{bmatrix} 2 & 0 \\ 0 & 2 \end{bmatrix}^3 &= \begin{bmatrix} 2^3 & 0 \\ 0 & 2^3 \end{bmatrix} = \begin{bmatrix} 8 & 0 \\ 0 & 8 \end{bmatrix} \\ &\vdots \\ \begin{bmatrix} 2 & 0 \\ 0 & 2 \end{bmatrix}^n &= \begin{bmatrix} 2^n & 0 \\ 0 & 2^n \end{bmatrix} \end{aligned}

Try to exponentiate any regular old random matrix… it’ll take you a while! Now, back to the main feature – spectral decomposition.

The spectral theorem lets us know when an operator can be represented by a diagonal matrix. These operators and all the matrices that represent them are called diagonalizable. This means that we can factor a diagonalizable matrix A into:

A=PDP−1A = PDP^{-1}

where P is an invertible matrix and D is a diagonal matrix.

If you remember from the last chapter, all normal operators and their associated normal matrices are diagonalizable. If this is the case, then we can decompose a matrix A into even more special factors:

A=UΛU†A = U\Lambda U^\dagger

Looks like a fraternity name, right? Well, U is a unitary matrix, and the capital Greek letter lambda (Λ) is a diagonal matrix with all the eigenvalues of A on its main diagonal! Remember that we used the lowercase lambda (λ) for each eigenvalue, so it makes sense to use the uppercase lambda for all of them together in one matrix. Now, here comes the kicker – the column vectors making up U are the eigenvectors of A!

Putting this all together means that we can decompose any normal matrix into a unitary matrix U, its conjugate transpose, and a diagonal matrix Λ that has the eigenvalues down its main diagonal. Please note that the eigenvalues placement on the main diagonal must correspond with its eigenvector’s placement in U. Since the set of eigenvalues is called the spectrum, I hope you can see why this is called spectral decomposition.

Okay, enough talk – more action! Let’s do an example.

Diagonalizable Matrices

Please note that there are diagonalizable matrices that are not normal, but we do not often come across these matrices in quantum computing.

Let’s use spectral decomposition to decompose the quantum gate Y. Here is its matrix in the computational basis:

Y=[0−ii0]Y = \begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix}

Now, I will go ahead and tell you that the eigenvalues of Y are 1 and -1. The eigenvectors are as follows where ”+” denotes the eigenvector for the eigenvalue of 1 and ”–” denotes the eigenvector of -1:

∣λY+⟩=[12i2],∣λY−⟩=[12−i2]|\lambda_{Y+}\rangle = \begin{bmatrix} \frac{1}{\sqrt{2}} \\ \frac{i}{\sqrt{2}} \end{bmatrix}, \quad |\lambda_{Y-}\rangle = \begin{bmatrix} \frac{1}{\sqrt{2}} \\ \frac{-i}{\sqrt{2}} \end{bmatrix}

So, according to the spectral theorem, I can represent Y in terms of a matrix U that has its eigenvectors as the columns, a diagonal matrix with the eigenvalues down its main diagonal, and the conjugate transpose of U. So, here is U and U dagger:

U=[1212i2−i2],U†=[12−i212i2]U = \begin{bmatrix} \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ \frac{i}{\sqrt{2}} & \frac{-i}{\sqrt{2}} \end{bmatrix}, \quad U^\dagger = \begin{bmatrix} \frac{1}{\sqrt{2}} & \frac{-i}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} & \frac{i}{\sqrt{2}} \end{bmatrix}

Here is the eigenvalue matrix:

Λ=[100−1]\Lambda = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}

Putting this all together, we can now decompose Y into:

Y=UΛU†=[1212i2−i2][100−1][12−i212i2]Y = U\Lambda U^\dagger = \begin{bmatrix} \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ \frac{i}{\sqrt{2}} & \frac{-i}{\sqrt{2}} \end{bmatrix} \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} \begin{bmatrix} \frac{1}{\sqrt{2}} & \frac{-i}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} & \frac{i}{\sqrt{2}} \end{bmatrix}

I encourage you to work out the matrix multiplication and make sure I’m right!

But, hey – wait a minute. We’re in quantum computing and we like bra-ket notation! So, let’s do it in bra-ket notation!

All the way back in Chapter 2, The Matrix, we talked about how you can represent a matrix as a set of column vectors (kets) or row vectors (bras). Well, we’re going to use that here. I’ll prove this using 2 × 2 matrices, and then you’ll have to trust me that it works for n × n matrices. I can represent the unitary matrix U that has eigenvectors for its column vectors like so:

U=[∣λ1⟩∣λ2⟩]U = \begin{bmatrix} |\lambda_1\rangle & |\lambda_2\rangle \end{bmatrix}

U dagger then becomes:

U†=[⟨λ1∣⟨λ2∣]U^\dagger = \begin{bmatrix} \langle \lambda_1| \\ \langle \lambda_2| \end{bmatrix}

The eigenvalue matrix will look like this:

Λ=[λ100λ2]\Lambda = \begin{bmatrix} \lambda_1 & 0 \\ 0 & \lambda_2 \end{bmatrix}

Putting it all together, it looks like:

A=UΛU†=[∣λ1⟩∣λ2⟩][λ100λ2][⟨λ1∣⟨λ2∣]A = U\Lambda U^\dagger = \begin{bmatrix} |\lambda_1\rangle & |\lambda_2\rangle \end{bmatrix} \begin{bmatrix} \lambda_1 & 0 \\ 0 & \lambda_2 \end{bmatrix} \begin{bmatrix} \langle \lambda_1| \\ \langle \lambda_2| \end{bmatrix}

Multiplying the first two matrices, we get:

A=UΛU†=[λ1∣λ1⟩λ2∣λ2⟩][⟨λ1∣⟨λ2∣]A = U\Lambda U^\dagger = \begin{bmatrix} \lambda_1|\lambda_1\rangle & \lambda_2|\lambda_2\rangle \end{bmatrix} \begin{bmatrix} \langle \lambda_1| \\ \langle \lambda_2| \end{bmatrix}

Then, when we do the final multiplication, we get:

A=UΛU†=λ1∣λ1⟩⟨λ1∣+λ2∣λ2⟩⟨λ2∣A = U\Lambda U^\dagger = \lambda_1|\lambda_1\rangle\langle \lambda_1| + \lambda_2|\lambda_2\rangle\langle \lambda_2|

And this is the bra-ket equation for spectral decomposition! For an n × n matrix, it becomes:

A=∑i=1nλi∣λi⟩⟨λi∣A = \sum_{i=1}^{n} \lambda_i |\lambda_i\rangle\langle \lambda_i|

This is a very important result! It means that any normal operator can be represented as a linear combination of outer products composed of just its eigenvalues and eigenvectors! Let’s see how this plays out with our Y operator.

You may have noticed that the eigenvectors of Y look eerily familiar; that’s because they are the i and minus i states!

∣λY+⟩=∣i⟩≡[12i2],∣λY−⟩=∣−i⟩≡[12−i2]|\lambda_{Y+}\rangle = |i\rangle \equiv \begin{bmatrix} \frac{1}{\sqrt{2}} \\ \frac{i}{\sqrt{2}} \end{bmatrix}, \quad |\lambda_{Y-}\rangle = |-i\rangle \equiv \begin{bmatrix} \frac{1}{\sqrt{2}} \\ \frac{-i}{\sqrt{2}} \end{bmatrix}

So, using spectral decomposition, we can represent the quantum Y gate this way:

(1)

Y=∣i⟩⟨i∣−∣−i⟩⟨−i∣Y = |i\rangle\langle i| - |-i\rangle\langle -i|

If you want to express this in the computational basis, you have to write i and minus i in it:

∣i⟩=12(∣0⟩+i∣1⟩)∣−i⟩=12(∣0⟩−i∣1⟩)\begin{aligned} |i\rangle &= \frac{1}{\sqrt{2}}\bigl(|0\rangle + i|1\rangle\bigr) \\ |-i\rangle &= \frac{1}{\sqrt{2}}\bigl(|0\rangle - i|1\rangle\bigr) \end{aligned}

Then, substitute this with Equation (1) and work out the math. You will get:

Y=i(∣1⟩⟨0∣−∣0⟩⟨1∣)Y = i\bigl(|1\rangle\langle 0| - |0\rangle\langle 1|\bigr)

Now, let’s look at another decomposition.

Singular Value Decomposition (SVD) is probably the most famous decomposition you can do for linear operators and matrices. It is at the core of search engines and machine learning algorithms. Additionally, it can be used on any type of matrix, even rectangular ones. However, we will only look at square matrices.

Succinctly stated, it guarantees that for any matrix A, it can be decomposed into three matrices:

A=UΣV†A = U\Sigma V^\dagger

Whereas U is a unitary matrix, Σ (sigma) is a diagonal matrix with what is known as the singular values of A on its diagonal, and V is also a unitary matrix. It should be noted that this decomposition is not unique, and different matrices can be used for U, Σ, and V.

Let’s look at an example. We have the following matrix A:

A=[−2000]A = \begin{bmatrix} -2 & 0 \\ 0 & 0 \end{bmatrix}

Without going through the math, I’m going to tell you that SVD can be used to get this decomposition:

A=[−1001][2000][1001]A = \begin{bmatrix} -1 & 0 \\ 0 & 1 \end{bmatrix} \begin{bmatrix} 2 & 0 \\ 0 & 0 \end{bmatrix} \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}

Let’s make sure that U and V are unitary matrices:

U=[−1001],U†=[−1001]U = \begin{bmatrix} -1 & 0 \\ 0 & 1 \end{bmatrix}, \quad U^\dagger = \begin{bmatrix} -1 & 0 \\ 0 & 1 \end{bmatrix}

Verify that UU†=IUU^\dagger = I

[−1001][−1001]=[1001]=I\begin{bmatrix} -1 & 0 \\ 0 & 1 \end{bmatrix} \begin{bmatrix} -1 & 0 \\ 0 & 1 \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} = I

Since V is the identity matrix, I think we can safely assume it is unitary.

Now for these pesky singular values on the main diagonal of Σ. How do we get those? Those are found by taking the square root of the eigenvalues of A multiplied by its conjugate transpose. So for us, this is:

A=[−2000],A†=[−2000]A = \begin{bmatrix} -2 & 0 \\ 0 & 0 \end{bmatrix}, \quad A^\dagger = \begin{bmatrix} -2 & 0 \\ 0 & 0 \end{bmatrix} AA†=[−2000][−2000]=[4000]AA^\dagger = \begin{bmatrix} -2 & 0 \\ 0 & 0 \end{bmatrix} \begin{bmatrix} -2 & 0 \\ 0 & 0 \end{bmatrix} = \begin{bmatrix} 4 & 0 \\ 0 & 0 \end{bmatrix}

The eigenvalues are on the main diagonal, and they are 4 and 0. So, the singular values of A are the square root of these eigenvalues, namely 2 and 0. If you look at the middle matrix, Σ, you’ll notice that it has these singular values on its main diagonal. Your next question might be, how do we find U and V? Well, you may be disappointed, but I’m not going to go through the algorithm here. Suffice it to say that it involves finding an orthonormal set of eigenvectors for AA†. If you are interested in learning more, I encourage you to look into one of the linear algebra books in my appendix of references. Though, to be quite truthful, we almost always use computers to calculate SVD. Let’s move onto another decomposition – polar decomposition.

Polar decomposition allows you to factor any matrix into unitary and positive semi-definite Hermitian matrices. It can be seen as breaking down a linear transformation into a rotation or reflection and scaling in ℝn. Formally, it is as follows:

A=UPA = UP

for any matrix A. U is a unitary matrix and P is a positive semi-definite matrix. Let’s look at an example:

A=[200−1]A = \begin{bmatrix} 2 & 0 \\ 0 & -1 \end{bmatrix}

Using polar decomposition, this matrix can be decomposed into:

A=UP=[100−1][2001]A = UP = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} \begin{bmatrix} 2 & 0 \\ 0 & 1 \end{bmatrix}

This may not seem like much, but we took a random matrix and turned it into a reflection matrix times a scaling matrix. Pretty cool!

Again, I will not go through the algorithm here because we will use calculators. Calculators for polar decomposition are not as plentiful as SVD, but I have found using the SciPy Python library to be the best way.

Operator functions and the matrix exponential

Section titled “Operator functions and the matrix exponential”

Now, we get to look at functions that involve an operator and their matrix representations. What types of functions are we talking about? Well, really any function that can be defined, such as the sine of x. You have probably never seen a function like this:

f(A)=sin⁡(A)f(A) = \sin(A)

where A is a matrix. The first question is, does this even make sense? Well, mathematicians have come up with ways for this to make sense, and it has applications in quantum computing.

As we have said, if a matrix A is diagonalizable, it can be decomposed into an invertible matrix P and diagonal matrix D as:

A=PDP−1A = PDP^{-1}

(2)

Given that, we can represent a function involving such a matrix like so:

f(A)=P[f(d1)⋯0⋮⋱⋮0⋯f(dn)]P−1f(A) = P \begin{bmatrix} f(d_1) & \cdots & 0 \\ \vdots & \ddots & \vdots \\ 0 & \cdots & f(d_n) \end{bmatrix} P^{-1}

(3)

where the matrix in the middle is the diagonal matrix D in Equation (2). The function is evaluated for every value on the main diagonal of D.

Let’s look at an example. Let’s do the easiest case, where we are already dealing with a diagonal matrix:

A=[π00π2]A = \begin{bmatrix} \pi & 0 \\ 0 & \frac{\pi}{2} \end{bmatrix}

Now, we want to find the sine of A. Following the process from Equation (3), this is what we get:

sin⁡(A)=[sin⁡π00sin⁡π2]sin⁡(A)=[0001]\begin{aligned} \sin(A) &= \begin{bmatrix} \sin \pi & 0 \\ 0 & \sin \frac{\pi}{2} \end{bmatrix} \\ \sin(A) &= \begin{bmatrix} 0 & 0 \\ 0 & 1 \end{bmatrix} \end{aligned}

How about we check our answer by finding the cosine of A as well and then summing their squares? Here is the cosine of A:

cos⁡(A)=[cos⁡π00cos⁡π2]cos⁡(A)=[−1000]\begin{aligned} \cos(A) &= \begin{bmatrix} \cos \pi & 0 \\ 0 & \cos \frac{\pi}{2} \end{bmatrix} \\ \cos(A) &= \begin{bmatrix} -1 & 0 \\ 0 & 0 \end{bmatrix} \end{aligned}

We know the trigonometric identity:

sin⁡2x+cos⁡2x=1\sin^2 x + \cos^2 x = 1

The number 1 in that identity becomes the identity matrix for us when dealing with matrices. Now, let’s verify our calculations for sine and cosine!

sin⁡(A)=[0001]sin⁡2(A)=[0001]cos⁡(A)=[−1000]cos⁡2(A)=[1000]sin⁡2(A)+cos⁡2(A)=[0001]+[1000]=[1001]=I\begin{aligned} \sin(A) &= \begin{bmatrix} 0 & 0 \\ 0 & 1 \end{bmatrix} \\ \sin^2(A) &= \begin{bmatrix} 0 & 0 \\ 0 & 1 \end{bmatrix} \\ \cos(A) &= \begin{bmatrix} -1 & 0 \\ 0 & 0 \end{bmatrix} \\ \cos^2(A) &= \begin{bmatrix} 1 & 0 \\ 0 & 0 \end{bmatrix} \\ \sin^2(A) + \cos^2(A) &= \begin{bmatrix} 0 & 0 \\ 0 & 1 \end{bmatrix} + \begin{bmatrix} 1 & 0 \\ 0 & 0 \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} = I \end{aligned}

So, our calculations are correct and this makes sense!

A function that comes up a lot in quantum computing is the exponential function:

f(x)=ex=exp⁡(x)f(x) = e^x = \exp(x)

You’ll notice that we use exp(x) to also denote the exponential function, as it is easier to write sometimes. If the matrix is diagonal, such as the Z operator, this becomes easy to calculate:

Z=[100−1]eZ=[e100e−1]\begin{aligned} Z &= \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} \\ e^Z &= \begin{bmatrix} e^1 & 0 \\ 0 & e^{-1} \end{bmatrix} \end{aligned}

Let’s see a slightly harder example. What is exp(A) when A is:

A=[120−1]A = \begin{bmatrix} 1 & 2 \\ 0 & -1 \end{bmatrix}

Well, first we need to diagonalize it, and the first step of that is finding its eigenvalues:

[120−1]−λ[1001]=[1−λ20−1−λ]det⁡[1−λ20−1−λ]=(1−λ)(−1−λ)−2⋅0det⁡[1−λ20−1−λ]=λ2−1λ2=1λ1=1,λ2=−1\begin{aligned} \begin{bmatrix} 1 & 2 \\ 0 & -1 \end{bmatrix} - \lambda \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} &= \begin{bmatrix} 1-\lambda & 2 \\ 0 & -1-\lambda \end{bmatrix} \\ \det\begin{bmatrix} 1-\lambda & 2 \\ 0 & -1-\lambda \end{bmatrix} &= (1-\lambda)(-1-\lambda) - 2 \cdot 0 \\ \det\begin{bmatrix} 1-\lambda & 2 \\ 0 & -1-\lambda \end{bmatrix} &= \lambda^2 - 1 \\ \lambda^2 &= 1 \\ \lambda_1 &= 1, \quad \lambda_2 = -1 \end{aligned}

Then, we have to find its eigenvectors. I will go ahead and tell you that they are:

∣λ1⟩=[10],∣λ2⟩=[−11]|\lambda_1\rangle = \begin{bmatrix} 1 \\ 0 \end{bmatrix}, \quad |\lambda_2\rangle = \begin{bmatrix} -1 \\ 1 \end{bmatrix}

Given all of this, we can write its diagonal representation like so:

A=PDP−1=[1−101][100−1][1101]A = PDP^{-1} = \begin{bmatrix} 1 & -1 \\ 0 & 1 \end{bmatrix} \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}

Evaluating the exponential function on the main diagonal of D gives us:

exp⁡(A)=exp⁡(PDP−1)=[1−101][e001e][1101]\exp(A) = \exp(PDP^{-1}) = \begin{bmatrix} 1 & -1 \\ 0 & 1 \end{bmatrix} \begin{bmatrix} e & 0 \\ 0 & \frac{1}{e} \end{bmatrix} \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}

Multiplying this all out gives us:

exp⁡(A)=[ee2−1e01e]\exp(A) = \begin{bmatrix} e & \frac{e^2 - 1}{e} \\ 0 & \frac{1}{e} \end{bmatrix}

While this was a long example, it should show you the power of being able to calculate the functions of operators.

Well, that wraps up this chapter. I hope you can see all the wonderful decompositions you can do with matrices and some of the more advanced things you can do with them. This chapter also concludes the book. I hope you have enjoyed it and learned as much as I did. Take this math and go forth to infinity and beyond in the universe of quantum computing!