Cheat - Sheet - Quantum Computing
Cheat - Sheet - Quantum Computing
This document summarizes basics of quantum computation: keep it with you as a “cheat sheet” for
the quantum formalism. The document is based on “Week 0” of the EdX online course on quantum cryp-
tography, and credits for the notes go to Stephanie Wehner and Nelly Ng. For additional resources, we
recommend:
• Books: the standard resource for quantum computing is the book by Nielsen and Chuang, “Quantum
information and Computation”. Another great book is the book by Kitaev, Shen and Vialyi, “Classical
and Quantum Computation”. For those of you interested in quantum information theory, the book by
Mark Wilde, “From classical to quantum Shannon theory”, is a great resource, and it is also available
online. Finally, John Watrous has an upcoming book, available here.
• Lecture notes: the most widely used are the notes by John Watrous and those of John Preskill.
1
1 Cheat sheet
Commonly used orthonormal bases for qubits
1 0
Standard basis for 1 qubit: S = {|0i, |1i} where |0i = and |1i = .
0 1
Standard basis for n qubits: Sn = {| x i} x∈{0,1}n where for any string x = x1 x2 · · · xn , | x i = | x1 i ⊗ | x2 i ⊗
· · · ⊗ | x n i.
Hadamard basis for 1 qubit: H = {|+i, |−i} where |±i = √1 (|0i ± |1i). Since these are orthonormal
2
bases, the following holds:
Pauli matrices
The Pauli matrices are 2 × 2 matrices,
0 1 1 0
X= , Z= , Y = iXZ, (4)
1 0 0 −1
2
2 Mathematical notation
Let us start
√by recalling commonly used definitions. For a complex number c = a + ib ∈ C with a, b ∈ R
∗
and i = −1, we use c = a − ib to denote its complex conjugate. We will also need mathematical
notation that is used throughout quantum information. First, we will write vectors in a special way known
as the “bra-ket” notation. While it may look a little cumbersome at first sight, it turns out to provide a
convenient way of dealing with the many operations we will perform with such vectors. Let’s start with two
examples. We write |vi ∈ C2 to denote a vector in a 2-dimensional vector space. For example,
1
|vi = . (8)
0
The “bra” of this vector is the conjugate transpose, which for our example looks like
∗ T
T 1
hv| = (|0i)∗ = = (1 0) . (9)
0∗
The general definition of the “bra-ket” notation is as follows:
Definition 1 (Ket and Bra notation). A ket, denoted |·i, represents a d-dimensional column vector in the
complex vector space C d . A bra, denoted h·|, is a d-dimensional row vector equal to the complex conjugate
of the corresponding ket, namely
h·| = (|·i∗ ) T , (10)
where ∗ denotes the entry-wise conjugate, and T denotes the transpose.
Since we work with complex numbers, we also introduce the absolute value of such numbers.
Definition 2 (Absolute value of a complex number). Consider a complex number z ∈ C expressed as
z = x + iy where x, y ∈ R are real numbers representing the real and imaginary parts of z respectively.
The absolute value, or otherwise known as modulus of z is given by
√ q
∗
| z | = z z = x 2 + y2 . (11)
√ √
For example, for z = 1 + i2 its absolute value is given by |z| = 12 + 22 = 5. Very frequently,
we will need to compute the inner product of two vectors in the “bra-ket” notation. This inner product is
defined as follows:
Definition 3 (Inner Product). Given two d-dimensional vectors
a1 b1
.. ..
| v1 i = . and | v2 i = . , (12)
ad bd
their inner product is given by hv1 |v2 i := hv1 ||v2 i = ∑id=1 ai∗ bi .
Note that the inner product of two vectors |v1 i, |v2 i ∈ C d is in general a complex number. Later on, we
shall see that the modulus squared of the inner product | hv1 |v2 i |2 is of much significance. As an example,
let us consider the inner product of the vector |vi given in (9) and
2
|wi = . (13)
3
3
We have
2
h v | w i = (1 0) = 1·2+0·3 = 2. (14)
3
Exercise 4. Show that | hv1 |v2 i |2 = hv1 |v2 i hv2 |v1 i. Hint: first, prove the relation (hv1 |v2 i)∗ = hv2 |v1 i.
Quite frequently, we will care about the 2-norm, or more simply length, of a vector.
Definition 5 (Length of a ket vector). Consider a ket vector
a1
..
|vi = . . (15)
ad
The length of |vi is given by
v v
q u d u d
u u
k|vik2 = hv|vi = t ∑ ai∗ ai = t
∑ | ai |2 . (16)
i =1 i =1
4
3.1 A single qubit
When thinking about vectors, it is indeed natural to ask whether we could have any vector α|0i + β|1i. This
is precisely the mathematical description of quantum bits. Instead of being just “0” and “1”, quantum bits
can be in a superposition between “0” and “1”. Since “quantum bit” is somewhat long, researchers simply
use the term “qubit” to refer to a quantum bit. Thinking of bits as vectors, a qubit can be described by a
vector |vi ∈ C2 . The vector space C2 is also known as the state space of the qubit. An example of a qubit
state is
1
|+i = √ (|0i + |1i) . (19)
2
Does any vector |vi ∈ C2 form a valid qubit state? It turns out that in order to be a valid qubit, |vi must
be normalized, just as the vectors |0i and |1i corresponding to classical bits were indeed normalized (check
this for yourself!). For the moment, let us just take this as a rule, leading to the following definition.
Definition 7 (Qubit). A (pure) state of a qubit can be represented as a 2-dimensional ket vector |ψi ∈ C2 ,
The condition on α and β means that |ψi is normalized. These complex numbers α and β are also called
amplitudes of |ψi.
Throughout these lectures we will be mostly focusing on encoding information in qubits. However in
general, quantum information can also be encoded in higher dimensional quantum systems. Therefore, one
can similarly define a qudit as below:
d −1 d −1
|ψi = ∑ αi |i i , where ∀i, αi ∈ C and ∑ |αi |2 = 1. (21)
i =0 i =0
Example 9. An example of a qubit is given by the vector |−i = √1 (|0i − |1i). The length of |−i is
2
s r
q
1 1 1
h−|−i = 1 −1 = · 2 = 1, (22)
2 − 1 2
so |−i is normalized.
Exercise 10. Verify that for all values of θ, |Ψi = cos(θ )|0i + sin(θ )|1i is a valid qubit state.
In our definition of qubits, we started from a way to write classical bits as vectors |0i and |1i. Note
that these two vectors are orthonormal, which in the quantum notation can be expressed as h1|0i = 0 and
h1|1i = h0|0i = 1. These two vectors thus form a basis for C2 , in that any vector |vi ∈ C2 can be written
as |vi = α|0i + β|1i for some coefficients α, β ∈ C. This basis corresponding to “classical” bits is used so
often that it carries a special name:
5
Definition 11 (Standard basis). Consider the 2-dimensional complex vector space C2 . The standard basis,
or sometimes known as the computational basis, S = {|0i, |1i} is an orthonormal basis for this vector
space, where the basis vectors are
1 0
|0i = and |1i = . (23)
0 1
Of course, there might be many other bases for C2 . Another favorite basis which we will use rather
frequently is the Hadamard basis defined as follows:
Definition 12 (Hadamard basis). The Hadamard basis is an orthonormal basis H = {|+i, |−i} consisting
of the two basis elements
1 1 1 1 1 1
|+i = √ (|0i + |1i) = √ and |−i = √ (|0i − |1i) = √ . (24)
2 2 1 2 2 − 1
Let us verify that this is indeed an orthonormal basis using the “bra-ket” notation. As we have seen in
Example 9, |−i is normalized. Similarly,
q
1 1 1
h+|+i = 1 1 = · 2 = 1, =⇒ , h+|+i = 1 (25)
2 1 2
Exercise 13. Express |1i in the Hadamard basis. That is, find coefficients α and β such that |1i = α|+i +
β|−i.
0 0
0 0
0 0
1 A 0B → |10i AB = 1
1 A 1B → |11i AB = 0
0 1
Note that the resulting vectors are in C d with dimension d = 22 = 4, where the dimension corresponds to the
number of possible strings. It turns out that one can write a two-qubit state |ψi AB ∈ C4 as a superposition
6
of these vectors, where we again demand that |ψ AB i is normalized. As an example, let us consider a state
|ψ AB i that is an equal superposition of all the above standard basis vectors:
1 1 1 1
|ψi AB = |00i AB + |01i AB + |10i AB + |11i AB (27)
2 2 2 2
1 0 0 0
1 0 1 1 1 0 1 0
= + + + (28)
2 0
2 0
2 1 2 0
0 0 0 1
1
1 1
= . (29)
2 1
1
The sum of amplitudes 12 squared is 4 · 212 = 1, therefore |ψi is a valid two qubit quantum state. As you
might have guessed, we now proceed analogously when considering n qubits. To address multiple qubits,
we first look at the vector representation for multiple classical bits. For binary strings of length n, consider
n
the vector space C2 , where each coordinate is labelled by a string x = x1 , . . . , xn . There are a total of
d = 2n such strings, so we can label each string x with a different integer i ∈ [1, d]. We can then express
the string x as a vector | x i that is 0 everywhere, except at the position labelled by i. A quantum state of n
qubits can then be written as
with α x ∈ C and ∑ x |α x |2 = 1. The numbers α x are again called amplitudes. We emphasize that the
n
dimension of the vector space C2 increases exponentially with the number n of bits. The space C d with
d = 2n is thereby called the state space of n qubits. This means that we need an exponential number of
parameters α x to keep track of only n qubits, in sharp contrast to the n parameters x1 , . . . , xn to describe n
classical bits.
You might wonder whether this was the only way to write down qubits. After all, we had simply chosen
some mapping from strings of length n to vectors in C d . Could we have chosen any other mapping from
strings to vectors? It turns out that the answer to this is yes - as long as each string gets mapped to a vector
that is orthonormal to the others. The mapping above, however, is very convenient and generally adopted
within the realm of quantum computing. Analogous to the case of a single qubit, the basis given by the set
of vectors {| x i | x ∈ {0, 1}n } is called the standard/computational basis.
Definition 14 (Standard basis for n qubits). Consider the state space of n qubits C d , where d = 2n . For
each distinct string x ∈ {0, 1}n , associate x with a distinct integer i ∈ {1, 2, · · · d}. The standard basis for
C d is an orthonormal basis given by Sn = {| x i} x∈{0,1}n , where | x i are d-dimensional vectors
0
..
.
|xi = 1 −→ i-th position.
(31)
..
.
0
7
Let us summarize our discussion in the following definition of an n qubit quantum state.
Definition 15. An n-qubit state |ψi ∈ C d with d = 2n can be written as a superposition of standard basis
elements
| ψ i = ∑ α x | x i, where ∀ x, α x ∈ C and ∑ |α x |2 = 1. (32)
x ∈{0,1}n x ∈{0,1}n
Let us now consider two examples of two qubit states. The first is so famous it carries a special name
and we will see it very frequently in the course of these notes.
Example 16. Consider two qubits A and B, in the two qubit state known as the EPR pair 2 , one can label
the joint state as AB
1 0 1
1 1
0 + 0 = √1 0 .
|EPRiAB = √ (|00iAB + |11iAB ) = √ (33)
2 2 0 0 2 0
0 1 1
which is an equal superposition between the vectors |00i AB and |11i. The length of this vector is given by
the (square root of) inner product
1 1
hEPR|EPRi AB = √ (h00| AB + h11| AB ) · √ (|00i AB + |11i AB ) (34)
2 2
1
= ( h00|00i AB + h00|11i AB + h11|00i AB + h11|11i AB ) (35)
2 | {z } | {z } | {z } | {z }
1 0 0 1
q
1
= · 2 = 1, =⇒ h EPR| EPRi = 1. (36)
2
Example 17. Consider the two qubit state
0
1 1 1
|ψi AB = √ (|01i AB + |11i AB ) = √ . (37)
2 2 0
1
For this state, the second qubit always corresponds to bit 1. We will later see that this is significantly different
state compared to |EPRiAB (hint: it is not entangled!).
8
the joint state |ψi AB ∈ C2 ⊗ C2 can be expressed as the tensor product of individual vectors |ψi A and |φi B
α A αB
αA α A |ψi B αA βB
|ψi AB = |ψi A ⊗ |φi B = ⊗ |ψi B = = β A αB .
(40)
βA β A |ψi B
β A βB
As you may have guessed, we can of course also combine the state of two quantum systems A and B if they
are larger than just one qubit. The general definition of the tensor product of two vectors is given by
Definition 18. Given two vectors |ψ1 i ∈ C d1 and |ψ2 i ∈ C d2 respectively, the tensor product is given by
α1 α1 |ψ2 i
|ψ1 i ⊗ |ψ2 i = ... ⊗ |ψ2 i = ..
. , (41)
αd αd |ψ2 i
Omitting the tensor product symbol: |ψi A ⊗ |ψi B = |ψi A |ψi B . (42)
Writing classical bits as a string: |0i A ⊗ |0i B = |0i A |0i B = |00i AB . (43)
⊗n
Combining several identical states: |ψi1 ⊗ |ψi2 · · · ⊗ |ψin = |ψi . (44)
3. NOT commutative: In general, |ψ1 i ⊗ |ψ2 i 6= |ψ2 i ⊗ |ψ1 i unless of course |ψ1 i = |ψ2 i.
These relations hold not only for kets, but also for bras.
To understand the definition of the tensor product, let us have a look at a few examples. The first relates
to the definition of the standard basis for multiple qubits. Indeed, you may have been wondering, if we
could have proceeded in a somewhat less ad hoc manner than starting from classical strings x ∈ {0, 1}n
and assigning to them vectors | x i in a space of dimension d = 2n . Indeed, you may have started to wonder
why n qubits resulted in a state space of a dimension that is exponential in n in the first place. The reason
for this, is that the law of quantum mechanics tells us that the state space of two quantum systems is indeed
combined by the tensor product.
Example 20. Let’s recover the standard basis of two qubits, from the standard basis of the individual qubits
using the tensor product rule. Recall that the standard basis for two qubits AB is given by
1 0 0 0
0 1 0 0
0 , |01i AB = 0 , |10i AB = 1 , |11i AB = 0 .
|00i AB =
0 0 0 1
9
This basis can be constructed, by taking the tensor product of standard basis elements for individual qubits:
|0i A ⊗ |0i B , |0i A ⊗ |1i B , |1i A ⊗ |0i B , |1i A ⊗ |1i B . For example, consider
0·1 0
0 0|0i B 0 · 0 0
|1i A ⊗ |0i B = ⊗ |0i B = =1 · 1 = 1 = |10i AB .
(45)
1 1|0i B
1·0 0
We have already seen a few other examples of two qubit states. Let’s see whether we can recover them
from two individual qubit states using the tensor product.
Example 21. Consider the states |+i A = √1 (|0i A + |1i A ) and |1i B . The joint state |ψi AB is given by
2
0
1 1 1 1 · |1i B 1 1
|ψi AB = |+i A ⊗ |1i B = √ ⊗ |1i B = √ =√ . (46)
2 1 2 1 · |1i B 2 0
1
One can also express the joint state in the standard basis by:
1
|ψi AB = √ (|0i A + |1i A ) ⊗ |1i B (47)
2
1
= √ (|0i A ⊗ |1i B + |1i A ⊗ |1i B ) (48)
2
1
= √ (|01i AB + |11i AB ). (49)
2
This is the state we have seen in Example 17.
Example 22. Consider the states |+i A = √1 (|0i A + |1i A ) and |+i B = √1 (|0i B + |1i B ). The joint state
2 2
|ψi AB is
1 1
|ψi AB = √ (|0i A + |1i A ) ⊗ √ (|0i B + |1i B ) (50)
2 2
1
= (|00i AB + |01i AB + |10i AB + |11i AB ) (51)
2
1
1 1
= . (52)
2 1
1
This is the state we have seen in (27), which is an equal superposition of all standard basis vectors for the
two qubits.
The following is an example of a state that can actually not be expressed as the tensor product of two
qubit states. Such states are rather special, and play an important role later in our course. Nevertheless, let’s
have a look at it to see how we might also express a two qubit state in different bases.
10
Example 23. Consider the state
1
|Ψi AB = √ (|+i A |+i B + |−i A |−i B ). (53)
2
Let us express this state in terms of the standard basis, by expanding the terms
1 1
|+i A |+i B = (|0i A + |1i A )(|0i B + |1i B ) = (|00i AB + |10i AB + |01i AB + |11i AB ) (54)
2 2
1 1
|−i A |−i B = (|0i A − |1i A )(|0i B − |1i B ) = (|00i AB − |10i AB − |01i AB + |11i AB ). (55)
2 2
Substituting this into Eq. (53) gives
1
|Ψi AB = √ (|+i A |+i B + |−i A |−i B ) (56)
2
1
= √ (|00i AB + |10i AB + |01i AB + |11i AB + |00i AB − |10i AB − |01i AB + |11i AB ) (57)
2 2
1
= √ (|00i AB + |11i AB ) = |EPRiAB (58)
2
where |EPRiAB is the state we have seen previously in Example 16. We see that the coefficients of |EPRiAB
are the same whether we write it in the Hadamard basis or the standard basis.
5 Simple measurements
Let us consider what happens if we measure a qubit. Classically, you can think of the measurement of a bit
as simply a readout: we have a system that encodes the state ‘0’ and ‘1’ and we make a measurement to find
out which one it is.
11
We now see a good reason for the condition |α|2 + | β|2 = 1: it means that p0 + p1 = 1, that is, the
probabilities of observing ‘0’ and ‘1’ add up to one. In quantum computer science, it is customary to label
the outcomes ‘0’ for “|0i” and ‘1’ for “|1i” 3 , while in physics people often use +1 for “|0i” and −1 for
“|1i”.
Application: Randomness from a deterministic process Can we do anything interesting with what we
have learned so far? It turns out the answer is yes: by preparing just single qubits and measuring in the
standard basis, we can in principle achieve a task that it is impossible classically. Namely, we can produce
true random numbers. Consider the following process illustrated in Figure ??: first, prepare a qubit in the
state |+i = √1 (|0i + |1i). Next, measure this state in the standard basis.
2
The probability of obtaining each outcome can then be calculated by evaluating the inner products:
2 2
1
2 1 1 1
p0 = | h+|0i | = √ (h0| + h1|)|0i = √ (h0|0i + h1|0i) = √ = , (61)
2 2 | {z } | {z } ( 2) 2 2
1 0
2 2
1
2 1 1 1
p1 = | h+|1i | = √ (h0| + h1|)|1i = √ (h0|1i + h1|1i) = √ = . (62)
2 2 | {z } | {z } ( 2) 2 2
0 1
This simple example already tells us something about the power of quantum information: We could build
a machine that deterministically prepares the qubit |+i, followed by a measurement in the standard basis.
Since p0 = p1 = 1/2, this machine allows us to produce a perfect random number - even though no
randomness has been used inside our machine! In contrast, one can prove that no classical deterministic
machine can produce random numbers from scratch.
We saw how to measure a single qubit in the standard basis. The rule for computing probabilities of
measurement outcomes generalizes in a direct way to measuring n-qubit states. Indeed, consider an n-qubit
quantum state
What happens when |Ψi is measured in the standard basis {| x i} x ? It turns out that the probability of
outcome x is given by p x = |h x ||Ψi|2 = |α x |2 , explaining again the need for normalization of the vector
| Ψ i.
12
√
Example 24. As an example, let consider again the qubit |+i = (1/ 2)(|0i + |1i). Instead of measuring
√ now measure in the basis H = {|+i, |−i} given by the two orthonormal
it in the standard basis, let us
vectors |+i and |−i = (1/ 2)(|0i − |1i). Clearly, we can write the qubit as 1 · |+i + 0 · |−i. Thus the
probability of obtaining measurement outcome “|+i” is 1. We thus see that the probabilities of measurement
outcomes depends dramatically on the basis in which we measure.
Example 25. Consider measuring an arbitrary qubit α|0i + β|1i in the basis {|+i, |−i}. To find out how
to express the qubit in this other basis, it is convenient to determine how the basis elements |0i and |1i look
like in this basis. We find that
1 1
|0i = [(|0i + |1i) + (|0i − |1i)] = √ (|+i + |−i) , (65)
2 2
1 1
|1i = [(|0i + |1i) − (|0i − |1i)] = √ (|+i − |−i) . (66)
2 2
We thus have
1
α|0i + β|1i = √ [α(|+i + |−i) + β(|+i − |−i)] = (67)
2
α+β α−β
= √ |+i + √ |−i . (68)
2 2
This means that we obtain outcome “|+i” with probability |α + β|2 /2 and outcome “|−i” with probability
|α − β|2 /2.
Exercise 26. Consider the state |Ψi = |0i. What are the probabilities p0 , p1 for measuring |Ψi in the
standard basis? What are the probabilities p+ , p− for measuring |Ψi in the Hadamard basis?
Quite often we do not care about the entire probability distribution, but just the probability of one specific
outcome. Is there a more efficient way to find this probability than to rewrite the entire state |ψi in another
basis? To investigate this, let us consider a single qubit
| ψ i = α |0i + β |1i . (69)
Remember that the elements of the standard basis are orthonormal. This means that
1
(|0i)† |0i = (1 0) =1, (70)
0
† 0
(|0i) |1i = (1 0) =0. (71)
1
Because the vectors are orthonormal, we could thus have found the desired probabilities by simply com-
puting the inner product between two vectors, as claimed above. Specifically, when given the qubit |ψi =
α|0i + β|1i we obtain outcomes “|0i” and “|1i” with probabilities
2
2 α
p0 = |h0|ψi| = (1 0) = | α |2 (72)
β
2
2 α
p1 = |h1|ψi| = (0 1) = | β |2 (73)
β
(74)
13
Example 27. Suppose we measure |0i in the Hadamard basis H (see above). The probabilities of observing
outcomes “|+i” and “|−i” are given by
2
√ √ 1 2 1
p+ = |h+|0i| = (1/ 2 1/ 2) = , (75)
0 2
2
√ √ 1 2 1
p− = |h−|0i| = (1/ 2 − 1/ 2) = . (76)
0 2
For multiple qubits, the rule for finding probabilities is analogous.
Definition 28. Suppose that we measure a quantum state |ψi in the orthonormal basis {|b j i}dj=1 . The
probability of observing outcome “b j ” can be found by computing
14
Example 30. Consider a qutrit, which is a 3-dimensional quantum system represented by the vector
1 0 0
1 1 1
|vi = √ 0 + 1 + 0 , (86)
2 0 2 2
0 1
1
pb1 = |hb1 |vi|2 = , (88)
2
1 1 1
pb2 = |hb2 |vi|2 = hb2 |vi hv|b2 i = √ (1 + 1) · √ (1 + 1) = , (89)
2 2 2 2 2
1 1
pb3 = |hb3 |vi|2 = hb3 |vi hv|b3 i = √ (1 − 1) · √ (1 − 1) = 0. (90)
2 2 2 2
Expectation values Physicists (but also computer scientists!) like to compute expectation values of mea-
surement outcomes, as they provide an indication of the average behavior, if one was to perform a measure-
ment many times (however we shall see later, that the measurement will perturb the state!). Let us suppose
that we measure a qubit |Ψi in the standard basis {|0i, |1i}. We will also adopt the physics convention
of labelling these outcomes ±1. This means that we associate the outcome “|0i” with outcome +1, and
outcome “|1i” with outcome −1. The expectation value the outcome obtained when measuring |Ψi is then
where Z = |0ih0| − |1ih1|. As we shall see later, Z is called the Pauli-Z matrix.
Example 31. Consider the basis {|0i A , |1i A } for qubit A, and the basis {|+i B , |−i B } for qubit B. A basis
for the joint state AB is then given by {|0i A |+i B , |0i A |−i B , |1i A |+i B , |1i A |−i B }.
15
Let us now think how we might construct some measurement for two quantum states from measurements
of the individual ones. Suppose we measure particle A in the basis {|b jA i} j and particle B in the basis
{|bkB i}k when the joint state of both particles is given by |ψi AB . What is the probability that we obtain
outcome “ |b jA i ” on A, and outcome “ |bkB i ” on B? To find such joint probabilities, we first write down
the joint basis of quantum states A and B as above: {{|b jA i|bkB i} j }k . We can then apply the usual rule to
compute the probability as
p jk = |hb jA |hbkB ||ψi AB |2 . (93)
Example 32. Consider two qubits in an EPR pair
1
|EPRi = √ (|00i + |11i), (94)
2
and measure them both in the standard basis. The probabilities of obtaining outcomes 00, 01, 10, and 11 are
given by
1
p00 = p11 = , (95)
2
p01 = p10 = 0. (96)
6 Transformations on qubits
Just like on classical bits, we can perform operations on qubits. Since we can write quantum states as
vectors, we are looking for a linear operator U that maps vectors to vectors
|ψout i = U |ψin i (97)
for some matrix U. If |ψin i ∈ C d , then U is a d × d matrix with complex entries. Recall that for any
quantum state we have hψ|ψi = 1. And we have also seen that this is quite important, because it tells us
that the sum of the probabilities, if we measure the state, should also be 1. This means that the operation U
should preserve the inner product 4 , i.e.,
hψout |ψout i = hψin |U † U |ψin i = 1 . (98)
Similarly, the same should be true for the operation U †
hψout |ψout i = hψin |UU † |ψin i = 1 . (99)
We see that in order to preserve probabilities the operation U should preserve the length of any vector. This
is the case precisely if U † U = UU † = I, where I is the identity matrix. Such a matrix I will continually
appear throughout these notes, and we define it below.
Definition 33 (Identity). The identity I is a diagonal, square matrix where each diagonal element is equal
to 1, i.e.
1 0 ··· ··· 0
0 1 · · · · · · 0
I = . . . . (100)
.. .. . . . . . ...
0 0 ··· 0 1
For any dimension d, we denote the d × d identity matrix as I d .
4 Remember that (U |ψi)† = hψ|U † .
16
Remark 34. The identity matrix is a unitary operation that preserves all quantum states, i.e. for any quantum
state |ψi, I |ψi = |ψi.
We will typically not specify the dimension of the identity matrix explicitly if it can be inferred from
context. The only allowed operations in the quantum regime are unitary operations.
Definition 35 (Unitary operation). An operation U is unitary if and only if U † U = UU † = I.
To gain some intuition about unitary operations, let us have a look at some useful examples.
Example 36. Consider the matrix
1 1 1
H= √ . (101)
2 1 −1
You can convince yourself that H † = H and thus
† 1 0
H H = HH = =I. (102)
0 1
That is, H is unitary. We have that
1 1 1 1 1 1
H |0i = √ =√ = |+i . (103)
2 1 − 1 0 2 1
Similarly, you can convince yourself that H |1i = |−i. We thus see that H transforms the computational
basis {|0i, |1i} into the Hadamard basis {|+i, |−i}. Indeed, H is called the Hadamard transform.
Note that I is itself also a unitary operation, called the identity operation. It just means that the state is
not transformed at all. Let us now consider a somewhat more complicated operation.
Example 37. For any θ ∈ R, consider the matrix
cos 2θ − sin 2θ
R(θ ) = . (104)
sin 2θ cos 2θ
The adjoint of this matrix is given by
† cos 2θ sin 2θ
R (θ ) = , (105)
− sin 2θ cos 2θ
and therefore
† cos 2θ − sin 2θ cos 2θ sin 2θ
R(θ ) R (θ ) = · (106)
sin 2θ cos 2θ − sin 2θ cos 2θ
cos2 θ
2 + sin2 θ
2 0 1 0
= = . (107)
0 sin2 θ
2 + cos2 θ
2
0 1
One can check that R† (θ ) R(θ ) = I as well, therefore R(θ ) is unitary.
cos 2θ − sin 2θ 1 cos 2θ
R(θ )|0i = · = . (108)
sin 2θ cos 2θ 0 sin 2θ
cos 2θ − sin 2θ 0 − sin 2θ
R(θ )|1i = · = . (109)
sin 2θ cos 2θ 1 cos 2θ
If we take θ = π
2, then cos 2θ = sin 2θ = cos π4 = √1 and therefore
2
π π
R |0i = |+i and R |1i = −|−i. (110)
2 2
17
6.1 Pauli matrices as unitary operations
In this section we look at the Pauli matrices, commonly denoted as X, Y, Z. These are quite famous in
physics, but also have rather interesting interpretations as bit and phase flip operations as we will see below.
The Pauli matrices are unitary 2 × 2 matrices, with the following form
0 1
X= , (111)
1 0
1 0
Z= , (112)
0 −1
Y = iXZ. (113)
The Pauli-X matrix acts on the standard basis vectors by interchanging them:
In analogy to classical computation X is also referred to as NOT, since it changes 0 to 1 and vice versa. This
is also known as a bit flip operation. On the other hand, the Pauli-Z matrix acts on the standard basis by
introducing a phase flip
The Pauli-Z matrix has the effect of interchanging the vectors |+i and |−i. To be precise, we have
√ √ √
Z |+i = Z (|0i + |1i)/ 2 = ( Z |0i + Z |1i)/ 2 = (|0i − |1i)/ 2 = |−i. (118)
Similarly, Z |−i = |+i. We thus see that Z acts like a bit flip upon the Hadamard basis, while it acts like
a phase flip in the standard basis. Applying both a bit and a phase flip gives Y = iXZ. The i makes Y
Hermitian, that is, Y † = Y. This matrix, when acted upon the standard basis vectors, introduces a bit flip
and a phase flip:
Exercise 38. Verify that the Pauli matrices X, Z and Y are indeed unitary.
18