












Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!













©c 2003 by Andreas Klappenecker. All rights reserved.
Chapter 2
Quantum Circuits
Quantum computing can be based on various different computational models. The most accessible one is the quantum circuit model, which specifies a se- quence of operations that manipulate the state of the quantum computer at discrete time steps. The basic rules of this model are surprisingly simple. This chapter introduces the basic properties of quantum states, quantum gates, and measurements.
A bit has two distinguishable states, denoted by 0 and 1. A classical computer manipulates a set of bits, which form the memory of the computer. The memory of a quantum computer is based in a similar way on the notion of a quantum bit, qubit for short. A qubit has two clearly distinguishable states, denoted by | 0 〉 and | 1 〉. The possible states of a qubit are not exhausted by these two possibilities. In general, the state of a qubit is of the form a| 0 〉+b| 1 〉, where a and b are complex numbers satisfying |a|^2 + |b|^2 = 1. The states | 0 〉 and | 1 〉 should be understood as basis vectors of a complex two-dimensional vector space. We can associate with these states the basis vectors
| 0 〉 =
The state a| 0 〉 + b| 1 〉 is a linear combination of these two basis vectors, and is represented by the vector (a, b)t. The operations of the quantum computer manipulate these vectors by linear transformations or by measurements. The value of a quantum bit is always 0 or 1, never anything else. If a qubit is in the state a| 0 〉 + b| 1 〉, then this means that the value 0 is observed with
1
The operations of a quantum computer allow reading, writing, or manipulat- ing the content of the memory, and therefore serve the same purpose as the operations of a classical computer. The main distinction is that the opera- tions of a quantum computer are formulated to be conformant with the laws of quantum mechanics. We explain in this section the basic operations on a single quantum bit, and introduce some convenient notations. The input operation of a quantum computer can prepare the memory in any basis state. As a result, each quantum bit is either in the state | 0 〉 or in the state | 1 〉, but not in a superposition of these basis states. The actual computation is done by applying simple operations, called quantum gates, which allow to manipulate the content of the memory. The result of the computation is determined by measurement operations. If the memory consists of a single quantum bit, then the operations are particularly easy to understand. We recall some mathematical vocabulary to ease our discussion. If x = (xm− 1 ,... , x 0 )t^ and y = (ym− 1 ,... , y 0 )t^ are vectors in Cm, then 〈x|y〉 = xm− 1 ym− 1 + · · · + x 0 y 0
defines a hermitian product. We follow the convention that hermitian prod- ucts are anti-linear in the first argument, and linear in the second.
Exercise 2.5 Show that the hermitian product is positive definite, that is, 〈x|x〉 ≥ 0 for all x ∈ Cm, and 〈x|x〉 > 0 if x 6 = 0.
If x ∈ Cm, then the norm of x is defined by ‖x‖ =
〈x|x〉. A vector x with norm ‖x‖ = 1 is called a unit vector. Let U : Cm^ → Cm^ be a linear map. If 〈 U x|U y 〉 = 〈x|y〉 holds for all x, y ∈ Cm, then U is called unitary.
Exercise 2.6 Show that a complex m × m matrix U is unitary if and only if U −^1 = U t; that is, the inverse of a unitary matrix is obtained by transposing the matrix and conjugating the matrix entries.
Exercise 2.7 A quantum state is a unit vector. Show that if a linear map M maps each unit vector x ∈ Cm^ to a unit vector M x, then M has to be unitary. This property explains the relevance of unitary maps in quantum computing.
Exercise 2.8 Let {u 0 ,... , um− 1 } and {v 0 ,... , vm− 1 } be orthonormal bases of Cm. Let U be a linear map such that vi = U ui for i = 0,... , m − 1. Show that U is unitary.
We have now the terminology to describe the operations on a single quan- tum bit. A quantum gate changes the state of a single qubit by applying an arbitary unitary map U. We use the following graphical notation for such a quantum gate:
U
The horizontal line represents the evolution of the quantum bit over time. The time flow is from left to right. The box represents a quantum gate, which applies a unitary map U to the state of the qubit. The quantum gate is unitary, hence, in particular, linear. This means that the action of the gate is completely determined by its behavior on the base states | 0 〉 and | 1 〉. Suppose that the quantum gate U changes the input state | 0 〉 to m 00 | 0 〉 + m 10 | 1 〉 and the input | 1 〉 to m 01 | 0 〉 + m 11 | 1 〉. If the input is a linear combination a| 0 〉 + b| 1 〉, then the gate U will change this state to
a (m 00 | 0 〉 + m 10 | 1 〉) + b (m 01 | 0 〉 + m 11 | 1 〉) = (am 00 + bm 01 )| 0 〉 + (am 10 + bm 11 )| 1 〉.
The result of this computation can be expressed in the standard basis (2.1) by the following matrix vector product: ( a m 00 + b m 01 a m 10 + b m 11
m 00 m 01 m 10 m 11
a b
The most familiar example is given by a not gate, which changes | 0 〉 to | 1 〉 and vice versa. This quantum gate can be described by the unitary matrix
X =
If we apply this quantum gate twice, then we recover the input. Graphically, we obtain the rule
X X =
Another operation on one quantum bit is given by the Hadamard gate
H =
This operation has the following effect:
H| 0 〉 =
| 1 〉 and H| 1 〉 =
An output is obtained by measuring the state of the quantum bit. The measurement operation of a quantum bit in the state a| 0 〉 + b| 1 〉 yields output 0 with probability |a|^2 , and output 1 with probability |b|^2. The state is, in general, changed by the measurement operation. If 0 is observed, then the state is set to | 0 〉, and if 1 is observed, then the state is set to | 1 〉. We depict a measurement of the quantum bit by a meter sign:
The operations obtained so far allow us to derive a quantum circuit simu- lating an unbiased coin flip. This circuit produces output 0 with probability 1/2, and output 1 with probability 1/2. We initialize the quantum bit with the state | 0 〉, then apply the Hadamard gate, and measure the result:
| 0 〉 (^) H
The Hadamard gate changes the state to √^12 | 0 〉 + √^12 | 1 〉; hence, the measure- ment produces the output with the desired probability.
Exercise 2.13 Design a quantum circuit that simulates a biased coin flip. The circuit should produce output 0 with probability 1/3, and output 1 with probability 2/3.
We need operations that enable the interaction between different quantum bits. The xor gate or controlled-not gate acts on two distinct quan- tum bits. Suppose that the memory contains two quantum bits, then the controlled-not gate operates on the basis states of the system as follows:
| 00 〉 7 → | 00 〉, | 01 〉 7 → | 01 〉, | 10 〉 7 → | 11 〉, | 11 〉 7 → | 10 〉.
If we extend this operation linearly, then the quantum state
a 00 | 00 〉 + a 01 | 01 〉 + a 10 | 10 〉 + a 11 | 11 〉
will be mapped by this controlled-not gate to
a 00 | 00 〉 + a 01 | 01 〉 + a 10 | 11 〉 + a 11 | 10 〉.
Exercise 2.14 The xor gate is a unitary map. Determine the associated unitary matrix with respect to the computational basis | 00 〉, | 01 〉, | 10 〉, | 11 〉. Choose the basis vectors in this order.
Exercise 2.15 Suppose that a controlled-not gate is applied to the state 1 2 |^00 〉^ +^
1 2 |^10 〉^ +^ √^1 2 |^11 〉. What is the resulting state? Controlled-not gates can be generalized to an arbitrary number n ≥ 2 of quantum bits. A controlled-not gate with control bit at position i and target bit at position j 6 = i is a unitary map, which is determined by
|xn− 1 · · · x 1 x 0 〉 7 → |yn− 1 · · · y 1 y 0 〉,
where xk and yk are elements of { 0 , 1 }, such that xk = yk for all k 6 = j, and the target bit yj = xi ⊕ xj is the result of adding xi to xj modulo 2. We denote this controlled-not gate by Λi,j (X). A controlled-not gate Λ 1 , 0 (X) acting on two quantum bits is depicted in the graphical notation for quantum gates by
The two horizontal lines represent the two quantum bits. The most significant bit (the bit at position 1) is shown on top, and the least significant bit (the bit at position 0) is shown at the bottom. The black dot • depicts the control bit of the quantum gate, and the crossed circle ⊕ depicts the target bit. To illustrate, assume that we have three quantum bits, which are initially in the state 1 2
Suppose that this state is processed by the quantum circuit
The time flow is from left to right. The first controlled-not gate Λ 2 , 1 (X) negates the quantum bit in the middle, if the most significant bit is set. The resulting intermediate state after applying the first controlled-not gate is
1 2
We emphasize that not every element of V ⊗ W is of the form v ⊗ w for some v ∈ V and w ∈ W. However, every element of V ⊗ W can be expressed as a sum
i,j vi^ ⊗^ wj^ of such tensor products, with^ vi^ ∈^ V^ and^ wj^ ∈^ W^.
Exercise 2.17 Give an example of a vector in C^2 ⊗C^2 that cannot be written in the form v ⊗ w with v, w ∈ C^2. Prove your result.
It might be helpful to re-iterate the construction. We started with two finite-dimensional vector spaces V and W. We constructed a giant vector space A with basis {(v, w) | v ∈ V, w ∈ W }. The generators of B were chosen such that the quotient space V ⊗ W = A/B satisfies the relations (2.2)–(2.4). It is easy to see that V ⊗ W = A/B is a finite-dimensional vector space, even though A and B are infinite-dimensional.
Exercise 2.18 Let V and W be complex finite-dimensional vector spaces. Let {e 1 ,... , em} be a basis of V and {f 1 ,... , fn} be a basis of W. Show that {ei ⊗ fj | 0 ≤ i < m, 0 ≤ j < n} generates V ⊗ W.
The exercise shows that dim(V ⊗ W ) ≤ dim(V ) dim(W ). In fact, it is possi- ble to show that equality holds, which proves that the generating set in the previous exercise is a basis of V ⊗ W. Let V and W be as in Exercise 2.18. Suppose that A is a linear map on V , and B is a linear map on W. Let A ⊗ B denote the linear map on V ⊗ W , which is determined by
(A ⊗ B)(ei ⊗ fj ) = Aei ⊗ Bfj.
This uniquely determines the values of A ⊗ B on other elements of V ⊗ W because the elements ei ⊗ fj are a basis.
Exercise 2.19 Let A and B be the matrices
a 00 a 01 a 10 a 11
b 00 b 01 b 10 b 11
representing linear maps with respect to the basis {e 0 , e 1 }. Determine the matrix A ⊗ B with respect to the basis {e 0 ⊗ e 0 , e 0 ⊗ e 1 , e 1 ⊗ e 0 , e 1 ⊗ e 1 }.
The tensor product plays a significant role in quantum computing. Recall that the state space of a single quantum bit is given by C^2. In quantum mechanics, the state space of a joint quantum system is described by the
tensor product of the state spaces of its parts. Consequently, a compound system of n quantum bits has the state space
C^2 ⊗ · · · ⊗ C^2 (n factors).
This is a 2n-dimensional complex vector space, hence isomorphic to C^2 n
. The isomorphism is explicitly given by the linear map
|xn− 1 〉 ⊗ · · · ⊗ |x 1 〉 ⊗ |x 0 〉 7 −→ |xn− 1 · · · x 1 x 0 〉,
where xi ∈ { 0 , 1 }, 0 ≤ i < n. We will use this isomorphism freely, and switch from one representation to the other, whichever is more convenient. We will silently identify the two notations and write | 00 〉 = | 0 〉 ⊗ | 0 〉, etc.
Exercise 2.20 By convention, the basis vectors associated with the basis | 0 〉 and | 1 〉 of C^2 are
| 0 〉 =
Derive the vectors of C^4 ∼= C^2 ⊗ C^2 associated with
| 00 〉 = | 0 〉 ⊗ | 0 〉, | 01 〉 = | 0 〉 ⊗ | 1 〉, | 10 〉 = | 1 〉 ⊗ | 0 〉, | 11 〉 = | 1 〉 ⊗ | 1 〉.
Exercise 2.21 Which vector is associated with (a 0 | 0 〉+a 1 | 1 〉)⊗(b 0 | 0 〉+b 1 | 1 〉), assuming the above convention for the basis vectors?
Suppose we have a memory with n quantum bits. Let U be a unitary 2 × 2 matrix. We define a single-qubit gate U acting on the quantum bit at position i to be the unitary map 12 n−i− 1 ⊗ U ⊗ 12 i. Alternatively, one can describe the action of the gate by
|xn− 1 〉 ⊗ · · · ⊗ |xi〉 ⊗ · · · ⊗ |x 0 〉 7 → |xn− 1 〉 ⊗ · · · ⊗ U |xi〉 ⊗ · · · ⊗ |x 0 〉,
where xi ∈ { 0 , 1 }, 0 ≤ i < n. All tensor components remain unchanged with the exception of |xi〉, which is replaced by U |xi〉. Let us illustate this definition in the case of two quantum bits. Suppose that we apply the Hadamard gate H on the least significant bit, that is, the gate acts on the quantum bit at position i = 0. The unitary map associated with this gate is represented by the matrix
computational basis. We define these measurement operations in this section and discuss some possible extensions. Assume that we have a memory consisting of n quantum bits. Suppose that the memory is in the quantum state
v =
x∈Fn 2
ax|x〉, ax ∈ C.
The state vector v is, as always, assumed to be of unit norm, ‖v‖ = 1. A measurement of the quantum bit at position i yields the result k ∈ { 0 , 1 } with probability (^) ∑
x∈Fn 2 with xi=k
|ax|^2.
The measurement changes, in general, the state vector. If k is observed, then the resulting state of the memory is given by (^) ‖v^1 k ‖ vk, where
vk =
x∈Fn 2 with xi=k
ax|x〉.
Let us illustrate the effect of this operation in the case of two quantum bits. Suppose that the memory is in the state
v =
If we measure the qubit at position i = 0, then we will observe 0 with prob- ability (1/2)^2 + (1/
2)^2 = 3/4, and 1 with probability (1/2)^2 = 1/4. Note that v 0 = 12 | 00 〉 + √^12 | 10 〉 and v 1 = 12 | 11 〉. Therefore, if we observe 0, then the memory will be in the state
1 ‖v 0 ‖ v 0 =
v 0 =
and if we observe 1, then the memory will be in the state
1 ‖v 1 ‖
v 1 = 2v 1 = | 11 〉.
Exercise 2.24 Let v = 13 | 00 〉 +
√ 3 3 |^01 〉^ +
√ 5 3 |^10 〉.^ If we measure the least significant bit, what is the probability to observe 0, respectively 1? Determine the resulting states v 0 and v 1 of the memory.
The graphical notation for a measurement is the meter sign. For instance, the measurement of the least significant quantum bit is depicted by
The reader familiar with quantum mechanics will notice that many more types of measurements are, in principle, possible. However, the practical ways to measure quantum bits are typically rather limited. Although quantum physics allows us to measure with respect to any orthonormal basis, we limit ourselves here to the computational basis. If we could perform a measurement with respect to a totally arbitrary orthonormal basis, then there would be no need for quantum gates. The quantum algorithm would then simply consist of a measurement in the appropriate basis.
We give in this section some tiny examples, which illustrate the notions that we have introduced so far. We will mainly discuss some small quantum cir- cuits, which do not necessarily have any purpose other than illustrating the effect of quantum operations. The superficial examples given here allow us, nonetheless, to illustrate some common tricks of the trade. We will discuss some more meaningful examples in the next chapter. Example 1. The first example illustrates how the Hadamard gates can be used to generate quickly a superposition of all possible input states. Suppose that the Hadamard gate is applied to both quantum bits, first on the least significant bit, then on the most significant bit:
Therefore, the action on the state vector is given by (H ⊗ 12 )( 12 ⊗H). Suppose that the input is | 00 〉 = | 0 〉 ⊗ | 0 〉. The intermediate state after applying the first gate is
| 0 〉 ⊗ H| 0 〉 = | 0 〉 ⊗ (
The final state after applying the second gate is
H| 0 〉 ⊗ (
Indeed, if we apply the three controlled-not gates to the state | 0000 〉, then this state remains unchanged, and if we apply the three controlled-not gates to | 1000 〉, then we get | 1111 〉; the result follows by linearity of the quantum gates. In graphical notation, the quantum circuit is given by
H
Exercise 2.26 Design a quantum circuit that prepares the superposition of all basis states with even parity for a system of three quantum bits, namely the state 1 2
Assume that the memory is initially in the state | 000 〉.
Example 3. Suppose that we have a boolean function f : Fn 2 → F 2. A quantum circuit implementing f has to be realized by a unitary map. This can be accomplished, for instance, by implementing the map
|y〉 ⊗ |x〉 7 → |y ⊕ f (x)〉 ⊗ |x〉
on n + 1 qubits, where x ∈ Fn 2 , and y ∈ F 2. The most significant bit is the output bit, and the n lowest significant bits are the input bits. The result of f (x) is added modulo 2 to the output bit. The result is a quantum circuit of the form
|x〉
|y〉
.. .
f (^). .. |x〉
|y ⊕ f (x)〉
The linearity of the circuit allows to evaluate f for any linear combination of the basis states. Assume that all n + 1 quantum bits are initialized with state | 0 〉. We apply the Hadamard gate to all n input bits. The resulting state is
1 √ 2 n
x∈Fn 2
| 0 〉 ⊗ |x〉,
a superposition of all possible inputs. If we apply the circuit implementing the function f , then we obtain as a result
1 √ 2 n
x∈Fn 2
|f (x)〉 ⊗ |x〉.
Thus, the circuit evaluates the function f for all possible inputs at once.
Exercise 2.27 Design a quantum circuit that implements the parity function f (x 2 , x 1 , x 0 ) = x 2 ⊕ x 1 ⊕ x 0. Show how this circuit can be used to generate the state
The state space of a memory with n quantum bits is given by the complex vector space C^2 n^ ∼= C^2 ⊗ · · · ⊗ C^2. We choose, once and for all, a fixed orthonormal basis of this vector space, and call it the computational ba- sis. Its basis vectors are denoted by | 0 · · · 00 〉, | 0 · · · 01 〉, · · · , | 1 · · · 11 〉. An arbitrary state of the memory is of the form ∑
x∈Fn 2
ax|x〉, where
x∈F 2 n
|ax|^2 = 1. (2.6)
A measurement of the quantum bit at position i yields the result k ∈ { 0 , 1 } with probability
xi=k |ax| (^2). If k is observed, then the resulting state after the measurement is (^) ‖v^1 k ‖ vk, where vk denotes the vector
vk =
x∈Fn 2 ,xi=k
ax|x〉.
A single-qubit gate is determined by a matrix U ∈ U(2) and a bit po- sition i. Such a gate modifies the state of the memory by applying the unitary matrix 12 n−i− 1 ⊗U ⊗ 12 i. A controlled-not gate Λi,k(X) is specified by its action on the basis vectors
Λi,k(X)|xn− 1 · · · x 1 x 0 〉 = |yn− 1 · · · y 1 y 0 〉,
where yj = xj for all j 6 = k, and yk = xi ⊕ xk.