CHAPTER
Quantum Algorithms
5
CHAPTER OUTLINE 5.1 Quantum Parallelism (Revisited)........................................................................ 146 5.2 Deutsch and DeutscheJozsa Algorithms............................................................. 148 5.2.1 Deutsch Algorithm.......................................................................... 148 5.2.2 DeutscheJozsa Algorithm................................................................ 150 5.3 Grover Search Algorithm ................................................................................... 151 5.4 Quantum Fourier Transform ............................................................................... 155 5.5 The Period of a Function and Shor Factoring Algorithm....................................... 159 5.5.1 Period of a Function ....................................................................... 159 5.5.2 Solving the RSA Encryption Protocol ................................................ 162 5.5.3 Shor Factoring Algorithm ................................................................ 163 5.6 Simon’s Algorithm ............................................................................................ 165 5.7 Classical/Quantum Computing Complexities and Turing Machines ....................... 166 5.8 Summary ......................................................................................................... 168 5.9 Problems ......................................................................................................... 169 References ............................................................................................................. 172
This chapter considers basic quantum algorithms [1e16]. The chapter starts by revisiting the quantum parallelism concept and describing its power in calculating the global property of a certain function by performing only one evaluation of that function, namely the Deutsch and DeutscheJozsa algorithms. Further, the Grover search algorithm to perform a search for an entry in an unstructured database is described. Next, the quantum Fourier transform is described, which is a basic algorithm used in many other quantum algorithms. An algorithm to evaluate the period of a function is also provided. It is then described how to solve the RivesteShamireAdleman (RSA) encryption protocol. Then, Shor’s factorization algorithm is given. Finally, Simon’s algorithm is described. The quantum computational complexity and Turing machine representation are discussed as well. After summarizing the chapter, a set of problems is given to help getting a deeper understanding of the material presented in this chapter.
Quantum Information Processing and Quantum Error Correction. DOI: 10.1016/B978-0-12-385491-9.00005-8 Copyright 2012 Elsevier Inc. All rights reserved.
145
146
CHAPTER 5 Quantum Algorithms
5.1 QUANTUM PARALLELISM (REVISITED) The quantum computation C implemented on a quantum register maps the input string i1.iN to the output string O1(i).ON(i): 0 1 0 1 O1 ðiÞ i1 @ « A ¼ UðCÞ@ « A; ðiÞ ¼ ði1 .iN Þ : (5.1) 10 2 iN ON ðiÞ The computation basis (CB) states are denoted by ji1 .iN i ¼ ji1 i5.5jiN i;
i1 .iN ˛f0; 1g:
(5.2)
The linear superposition allows us to form the following 2N-qubit state: 1 X (5.3) jjin i ¼ pffiffiffiffiffiffi ji1 .iN i 5j0.0i; 2N i and upon the application of quantum operation U(C), the output can be represented by 1 X (5.4) jjout i ¼ UðCÞjjin i ¼ pffiffiffiffiffiffi ji1 .iN i5jO1 ðiÞ.ON ðiÞi: 2N i The quantum computer has been able to encode all input strings generated by C into jjouti; in other words, it has simultaneously pursued 2N classical paths. This ability of a quantum computer to encode multiple computational results into a quantum state in a single quantum computational step is known as quantum parallelism. The quantum circuit to simultaneously evaluate f(0) and f(1) of the mapping f(x): {0,1} / {0,1} is shown in Figure 5.1. Its output state contains information about both f(0) and f(1). We can show that the quantum operation Uf is unitary as follows: Uf
jx; y4f ðxÞi/jx; ½y4f ðxÞ4f ðxÞi ¼ jx; yi0Uf2 ¼ I: (|0〉+|1〉)/√2
|0〉
H
x
x
ψ =
Uf |0〉
y⊕f(x)
y Uf
x, y → x, y ⊕ f (x ) FIGURE 5.1 Quantum circuit to simultaneously compute f (0) and f (1).
0, f (0 ) + 1, f (1) 2
(5.5)
5.1 Quantum Parallelism (Revisited)
(a)
|0〉
H
ψ =
|0〉
H
(b)
|0〉
. . .
|0〉
0 +1 0 +1 2
00 + 01 + 10 + 11 2
=
2
H
ψ = H
1 2n
∑x
x
FIGURE 5.2 The WalsheHadamard transform: (a) on two qubits; (b) on n qubits.
The action of operation Uf in operator notation can be represented by Uf jx; 0i ¼ jx; f ðxÞi
Uf jx; yi ¼ jx; y4f ðxÞi:
(5.6)
The output of the circuit shown in Figure 5.1 can now be obtained as 1 1 jji ¼ Uf jH050i ¼ Uf pffiffiffi ðj00i þ j10iÞ ¼ pffiffiffi ðj0; f ð0Þi þ j1; f ð1ÞiÞ; 2 2
(5.7)
proving that the circuit in Figure 5.1 can indeed simultaneously evaluate f(0) and f(1). We would like to generalize the computation of f(x) on n þ m qubits. Before we provide the quantum circuit to perform this computation, we need the quantum circuit to create the superposition state from Eq. (5.3). The WalsheHadamard transform on two ancillary qubits in state j00i can be implemented by applying the Hadamard gates on ancillary qubits as shown in Figure 5.2a. The WalsheHadamard transform on n qubits can be implemented as shown in Figure 5.2b. Now, by using the WalsheHadamard transform circuit, the quantum circuit to evaluate f(x): {0,1}n / {0,1} can be implemented as shown in Figure 5.3.
|0〉
H ⊗n
x
x
n
ψ =
Uf |0〉
y
y⊕f(x)
FIGURE 5.3 The quantum circuit to evaluate f (x): {0,1}n / {0,1}.
1 2n
∑x x
f ( x)
147
148
CHAPTER 5 Quantum Algorithms
|x〉
x
x
n
ψ
Uf |z〉
z ⊕f(x)
z m
FIGURE 5.4 The generalization of quantum operation Uf on n þ m qubits. H ⊗ n 0⊗ n = H ⊗n
〉
2n −1
1 2
n/2
∑ x =0
x , x = xn −1
x
x
ψ = U f ( H ⊗ n 0⊗ n ) ⊗ 0⊗ m =
n
Uf 〉
x0 , xi = 0,1
z
z ⊕f(x)
1 2
n/2
2n −1
∑ x =0
x, f ( x )
m
U f x, z = x, z ⊕ f ( x ) , z = zn −1
z0 , zi = 0,1
U f x, 0 ⊗ m = x, f ( x )
FIGURE 5.5 The quantum circuit to evaluate f(x) on n þ m qubits.
The quantum circuit performing Uf on n þ m qubits is shown in Figure 5.4. Its operation can be described as follows: Uf jx; zi ¼ jx; z4f ðxÞi; jzi ¼ jzn1 .z0 i; zi ¼ 0; 1: By setting z ¼ 0.0, the action of this gate is Uf x; 05m i ¼ jx; f ðxÞi;
(5.8)
(5.9)
which is the same as the action of the gate shown in Figure 5.3. By using this circuit, we can generalize the evaluation f(x) to n þ m qubits as illustrated in Figure 5.5. The output state of the quantum circuit shown in Figure 5.5 can be determined as ! n n 2X 1 1 5m 5n 5n 1 1 2X 5m jxi5 0 i ¼ n=2 jx; f ðxÞi: jji ¼ Uf H 0 Þ50 i ¼ n=2 Uf 2 2 x¼0 x¼0 (5.10)
5.2 DEUTSCH AND DEUTSCHeJOZSA ALGORITHMS 5.2.1 Deutsch Algorithm
pffiffiffi Although jji ¼ ðj0; f ð0Þi þ j1; f ð1ÞiÞ= 2 contains information about both f(0) and f(1), there is no advantage to classic computation if a table of f(x) is desired.
5.2 Deutsch and DeutscheJozsa Algorithms
On the other hand, quantum computation allows us to evaluate some global property, say f(0) 4 f(1), by performing only one evaluation of f(x). Although this example is trivial and not very practical, it allows us to describe the basic concepts of quantum computing. The quantum circuit implementing the Deutsch algorithm is shown in Figure 5.6. The state jji after the Hadamard gate stage is given by 1 jji ¼ Hj0i5Hj1i ¼ ðj0i þ j1iÞ ðj0i j1iÞ 2 1 X
1 ¼ 2
! jxi ðj0i j1iÞ:
(5.11)
x¼0
The application of the operator Uf to jji performs the following mapping: • Option 1: f (x) ¼ 0 0 (j0i j1i) / (j0i j1i) • Option 2: f (x) ¼ 1 0 (j0i j1i) / (j1i j0i) ¼ (j0i j1i). By combining these two options, the same mapping can be represented by (j0i j1i) / (1)f (x)(j0i j1i), so that the action of Uf on jji is as follows: ! 1 1 X f ðxÞ ð1Þ jxi ðj0i j1iÞ: (5.12) Uf jji ¼ Hj0i5Hj1i ¼ 2 x¼0 Uf
The operator that performs the mapping jxi/ð1Þf ðxÞ jxi is known as an oracle operator. The upper and lower registers on the right-hand side of the circuit shown in Figure 5.6 are unentangled after the oracle operator. This operator is important in the Grover search algorithm, which will be described later. The functioni operator h pffiffiffi f ð0Þ output state (see Figure 5.6) is given by j4i ¼ ð1Þ j0i þ ð1Þf ð1Þ j1i = 2, and by applying the Hadamard gate we obtain: i i 1h 1h Hj4i ¼ ð1Þf ð0Þ þ ð1Þf ð1Þ j0i þ ð1Þf ð0Þ ð1Þf ð1Þ j1i: 2 2
|0〉
x
H
x
ϕ
Uf |1〉
H
y
H
y⊕f(x)
ψ FIGURE 5.6 The quantum circuit implementing the Deutsch algorithm.
(5.13)
149
150
CHAPTER 5 Quantum Algorithms
By performing the measurement on upper qubit, we can obtain two possible states: • Option 1: Qubit j0i is the final state upon measurement, meaning that f(0) ¼ f(1); in other words, the function f(x) is constant. • Option 2: Qubit j1i is obtained, meaning that f(0) s f(1), indicating that the function f(x) is balanced. Therefore, in this example, we employed quantum parallelism to bypass the explicit calculation of f(x).
5.2.2 DeutscheJozsa Algorithm The DeutscheJozsa algorithm is a generalization of Deutsch’s algorithm. Namely, it verifies if the mapping f(x): {0,1}n / {0,1} is constant or balanced for all values of x ˛ {0,2n 1}. The quantum circuit implementing the DeutscheJozsa algorithm is shown in Figure 5.7. We will describe the DeutscheJozsa algorithm for n ¼ 2 (see Figure 5.8), while the description for arbitrary n is left to the reader. Based on Figure 5.8 we conclude that the action of Uf on jji is given by
H ⊗n
|0〉
x
x
H ⊗n
n
Uf |1〉
H
y⊕f(x)
y
FIGURE 5.7 DeutscheJozsa algorithm implementation.
H ⊗2 00 = |0〉
H
|0〉
H
|1〉
H
1 (0 +1 2
1 ( 0 + 1 ) = 12 ( 00 + 01 + 10 + 11 ) = 1 2 2 2
)
H x
x H
Uf y
ψ
ψ' y⊕f(x)
ϕ Uf ψ
FIGURE 5.8 DeutscheJozsa algorithm implementation for n ¼ 2.
3
∑x x =0
5.3 Grover Search Algorithm # " 3 1X 1 Uf jji ¼ Uf jxi 5pffiffiffi ðj0i j1iÞ 2 x¼0 2 # " 3 1X 1 ¼ ð1Þ f ðxÞ jxi 5pffiffiffi ðj0i j1iÞ: 2 x¼0 2
(5.14)
Clearly the upper and lower registers on the right-hand side of gate Uf are unentangled. By applying the Hadamard gates on upper qubits jj0 i and performing measurement we obtain the following options: • Option 1: f(x) ¼ const, in which case the upper qubits jj0 i can be represented as 1 1 1 jj0 i ¼ ðj00i þ j01i þ j10i þ j11iÞ ¼ pffiffiffi ðj0i þ j1iÞ pffiffiffi ðj0i þ j1iÞ: 2 2 2 (5.15) By applying the corresponding Hadamard gates, the upper qubits jj0 i are transformed to j4i ¼ H 52 jj0 i ¼ j00i:
(5.16)
• Option 2: f(x) ¼ x mod 2, in which case the upper qubits (based on (5.14)) are in fact 1 1 jj0 i ¼ ðj00i j01i þ j10i j11iÞ ¼ ½j0iðj0i j1iÞ þ ðj0i j1iÞj1i: (5.17) 2 2 Now, by applying the Hadamard gates, the upper qubits jj0 i are transformed to: 1 H 52 jj0 i ¼ H 52 ½ðj0i þ j1iÞ5ðj0i j1iÞ ¼ j01i: 2
(5.18)
The result in upper qubits is unambiguous only if jj0 i is a non-entangled state, indicating that it must be ð1Þ f ð0Þþf ð1Þ ¼ ð1Þ f ð1Þþf ð2Þ :
(5.19)
5.3 GROVER SEARCH ALGORITHM The Grover search algorithm performs a search for an entry in an unstructured database. In order to efficiently describe the Grover search algorithm, we use in interpretation similar to that of Le Bellac [1]. If N is the number of entries, a classical algorithm will take on average N/2 attempts, while the Grover search algorithm solves this problem in ~ON operations. The search is conducted under the following
151
152
CHAPTER 5 Quantum Algorithms
assumptions: (1) the database address contains n qubits and (2) the search function is defined by 0; xsy (5.20) f ðxÞ ¼ ¼ dxy ; x˛f0; 1; .; 2n 1g; 1; x ¼ y meaning that the search function result is 1 if the correct item jyi is found. In the previous section, we defined the oracle operator as follows: (5.21) Ojxi ¼ ð1Þ f ðxÞ jxi: Based on the oracle operator, we define the Grover operator as G ¼ H 5n XH 5n O;
(5.22)
where the action of operator X (not related to the Pauli X operator) on state jxi is given by (5.23) Xjxi ¼ ð1Þdx0 jxi; while the corresponding matrix representation 2 1 0 0 0 6 0 1 0 0 6 X^6 6 0 0 1 0 4. « 0 0 0 0
of X is 3 0 07 7 07 7: 5 . 1 . . .
(5.24)
From Eq. (5.24) it is clear that the X operator can be represented as X ¼ 2j0ih0j I, and upon substitution into (5.22), the Grover search operator becomes (5.25) G ¼ H 5n ð2j0ih0j IÞH 5n O: To simplify further the representation of the Grover operator, we represent it in terms of superposition state n 1 1 2X 5n 5n (5.26) jxi; jJi ¼ H j0 i ¼ n=2 2 x¼0 as follows: G ¼ H 5n ð2j0ih0j IÞH 5n O ¼
! H 2 ¼I 2 H 5n j0i h0jH 5n H 5n H 5n |fflfflfflffl{zfflfflfflffl} |fflfflfflffl{zfflfflfflffl} |fflfflfflfflfflffl{zfflfflfflfflfflffl} O ¼ ð2jJihJj IÞO: jJi
hJj
I
(5.27)
The Grover operator implementation circuit for n ¼ 3 is shown in Figure 5.9. The geometric interpretation of the Grover search algorithm, in terms of reflection operator O, is essentially the rotation in a 2D plane as shown in Figure 5.10. The key idea of the Grover search algorithm is to determine the desired entry in an iterative
5.3 Grover Search Algorithm
H
H
X
H
O
⎡1 ⎢0 ⎢ X =⎢0 ⎢ ⎢ ⎢⎣ 0
H
H
H
G
δ xy
O x = ( −1)
X =2 0 0 −I
0 −1
0 0
0 0
0
−1 0
0
0
0
0⎤ 0 ⎥⎥ 0⎥ ⎥ ⎥ −1⎥⎦
x
FIGURE 5.9 The quantum circuit to perform the Grover search.
fashion, by rotating a current state jai in small angles q until we reach the jyi state. The rotation of superposition state jJi for an angle q in counterclockwise fashion can be implemented by two reflections (or equivalently by applying the oracle operator twice), the first reflection of jJi with respect to the state jai to get OjJi, and the second reflection of OjJi with respect to the superposition state jJi to get the resulting state GjJi, which is just the counterclockwise rotation of jJi for q. The state jai is essentially the superposition of all other database entries jxi different from jyi; in other words, we can write X 1 (5.28) jxi: jai ¼ pffiffiffiffiffiffiffiffiffiffiffiffi N 1 xsy
|y〉 G|Ψ〉
|Ψ〉
θ θ/2
|α〉
θ/2
O|Ψ〉
|Φ〉 FIGURE 5.10 The geometric interpretation of the Grover search algorithm.
153
154
CHAPTER 5 Quantum Algorithms
The superposition state, given by (5.26), can now be expressed in terms of (5.28) as follows: rffiffiffiffiffiffiffiffiffiffiffiffi rffiffiffiffi 1 1 (5.29) jJi ¼ 1 jai þ jyi: N N pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi By substituting 1 1=N ¼ cosðq=2Þ; we can rewrite the superposition state jJi as
q q (5.30) jJi ¼ cos jai þ sin jai: 2 2 Let us now apply the oracle operator on ajai þ bjyi to obtain: Oðajai þ bjyiÞ ¼ að1Þday jai þ bð1Þdyy jyi ¼ ajai bjyi;
(5.31)
therefore proving that the action of operator O is a reflection with respect to the direction of jai. The Grover operator action on state ajJi þ bjFi is given by ð2jJihJj IÞðajJi þ bjFiÞ ¼ 2ajJi hJjJi ajJi þ 2bjJi hJjFi bjFi |fflfflffl{zfflfflffl} |fflfflffl{zfflfflffl} ¼1
¼ ajJi bjFi;
¼0
(5.32)
which is just the reflection with respect to the direction of jJi. Therefore, the product of two reflections is a rotation, and from Figure 5.10 we conclude that the angle between GjJi and jai is q þ q/2 ¼ 3q/2, so that we can write
3q 3q jai þ sin jyi: (5.33) GjJi ¼ cos 2 2 In a similar fashion, since the angle between GjJi and jJi is q, G2jJi can be obtained from jJi by rotation by an angle 2q or equivalently from jai by rotation by (2q þ q/2). After k iterations, GkjJi is obtained from jai by rotation by (kq þ q/2) ¼ (2k þ 1)q/2, and we can write
ð2k þ 1Þq ð2k þ 1Þq k (5.34) G jJi ¼ cos jai þ sin jyi: 2 2 The optimum number of iterations can be obtained by aligning GkjJi with jyi or equivalently by setting
ð2k þ 1Þq q q ¼ 05cos kq cos sin kq sin ¼ 0: (5.35) cos 2 2 2 pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi By using pffiffiffiffi the substitution cosðq=2Þ ¼ 1 1=N ; we obtain that cos kq ¼ 1= N , and the optimum number of iteration steps is then " rffiffiffiffi# 1 1 1 cos þ 1: (5.36) ko ¼ q N
5.4 Quantum Fourier Transform
|0 〉
H
|0 〉
H
|0 〉
H
|1 〉
H
G
G
FIGURE 5.11 The quantum circuit to perform the Grover search for n ¼ 3.
If N >> 1 we can use the Taylor expansion and keep the first term to obtain pffiffiffiffi qx2= N and by substituting it into (5.36) we obtain the following approximation for optimum number of interations: rffiffiffiffi pffiffiffiffi pffiffiffiffi N 1 p N 1 cos : (5.37) ko x x 2 N 4 Therefore, in order to successfully complete the Grover search, we need to apply the oracle operator ~ON times. The quantum circuit to perform the Grover search for n ¼ 3 is shown in Figure 5.11. After the optimum number of steps ko, the angle between GkojJi and jyi is less than q/2, so that the probability of error is less than O(1/N). It can be shown that the Grover algorithm is optimal. By taking all gates into account, the total number of operations in the Grover search algorithm is proportional to O(N)logN.
5.4 QUANTUM FOURIER TRANSFORM In this section we are concerned with the quantum Fourier transform. The unitary Fourier transform UFT can be represented by the following matrix elements: hyjUFT jxi ¼ ðUFT Þyx ¼
1 j2pxy=2n e ; 2n=2
jxi ¼ jxn1 .x0 i; xi ¼ 0; 1:
(5.38)
We can show that the UFT operator is unitary as follows: n 2X 1
y¼0
y ðUFT Þx 0 y ðUFT Þyx
¼
n 2X 1
y¼0
ðUFT Þx 0 y ðUFT Þyx
¼
1 2n=2
n 2X 1
0
e j2pðxx Þy=2 ¼ dx0 x : n
y¼0
(5.39)
155
156
CHAPTER 5 Quantum Algorithms
|x n-1 〉
n-1 . . .
|x 0 〉
. . .
U FT
0
FIGURE 5.12 The notation of a quantum FT circuit.
The quantum FT notation is provided in Figure 5.12. Let jJi be a linear superposition of vectors jxi: jJi ¼
n 2X 1
f ðxÞjxi;
(5.40)
x¼0
where f ðxÞ ¼ hxjJi is a projection of jJi along jxi, the probability ampliP while n tudes satisfy the following normalization condition: x2 ¼10 jf ðxÞj2 ¼ 1: By applying the UFT operator on the superposition state we obtain: jFi ¼ UFT jJi ¼ UFT
n 2X 1
hxjJijxi:
(5.41)
x¼0
The probability amplitude of finding the state jyi of the computational basis at the output of the FT block is given by hyjFi ¼
n 2X 1
hyjUFT jxihxjJi ¼
x¼0
1 2n=2
n 2X 1
n
e j2pxy=2 f ðxÞ;
(5.42)
x¼0
which is just the Fourier transform of f(x): n 1 n 1 2X ~ f ðxÞe j2pxy=2 : f ðyÞ ¼ n=2 2 x¼0
(5.43)
The action of UFT on jxi in operator notation is given by UFT jxi ¼
n 2X 1
y¼0
jyihyjUFT jxi ¼
1 2n=2
n 2X 1
n
e j2pxy=2 jyi;
y¼0
where x ¼ x0 þ 2x1 þ 22 x2 þ . þ 2n1 xn1 y ¼ y0 þ 2y1 þ 22 y2 þ . þ 2n1 yn1 :
(5.44)
5.4 Quantum Fourier Transform
For n ¼ 3, N ¼ 2n ¼ 8, we can represent xy as x x xy x1 x0 x0 x0 2 1 þ þ þ ¼ y0 þ y1 þ y2 : 2 4 8 2 4 2 8
(5.45)
We also know that 0$xm xm1 .x1 x0 ¼
xm xm1 x0 þ 2 þ . þ m; 2 2 2
(5.46)
and exp( j2pm) ¼ 1, when m is an integer. By representing jyi ¼ jyn1 .y0 i, from (5.44) we obtain: X 1 e j2pyn1 :x0 .e j2py0 :xn1 .x0 jyn1 .y0 i UFT jxi ¼ n=2 2 y0 ;.;yn1 ! ! X X 1 j2pyn1 :x0 j2py1 :xn2 .x0 ¼ n=2 e e jyn1 i . jy1 i 2 yn1 y1 X
! e
j2py0 :xn1 .x0
jy0 i :
(5.47)
y0
By representing (5.47) in the developed form we obtain: UFT jxi ¼
1 2n=2
ðj0n1 i þ e j2p:x0 j1n1 iÞ.ðj01 i þ e j2p:xn2 .x0 j11 iÞ
ðj00 i þ e j2p:xn1 .x0 j10 iÞ:
(5.48)
By following a similar procedure, for n ¼ 2, N ¼ 2 ¼ 4, the application of UFT on jxi yields n
1 UFT jxi ¼ UFT jx1 x0 i ¼ ðj01 i þ e j2p:x0 j11 iÞ ðj00 i þ e j2p:x1 x0 j10 iÞ 2 1 j2p:x1 x0 ¼ ðj00i þ e j01i þ e j2p:x0 j10i þ e j2pð:x1 x0 þ:x0 Þ j11iÞ: 2
(5.49)
The quantum circuit to perform FT for n ¼ 3 is shown in Figure 5.13.
|x 2 〉
H
|x 1 〉
R1
R2 H
0 ⎞ ⎛1 Rd = ⎜ ⎜ 0 e jπ / 2d ⎟⎟ ⎝ ⎠
R1
|x 0 〉
FIGURE 5.13 The quantum circuit to perform the FT for n ¼ 3.
H
157
158
CHAPTER 5 Quantum Algorithms pffiffiffi pffiffiffi Since Hj0i2 ¼ ðj0i2 þ j1i2 Þ= 2; Hj1i2 ¼ ðj0i2 j1i2 Þ= 2, the action of the Hadamard gate on qubit jx2i (see Figure 5.13) is given by 1 Hjxi2 ¼ pffiffiffi ðj0i2 þ e j2p:x2 j1i2 Þ: (5.50) 2 In Figure 5.13 we denote by Rd the discrete-phase shift gate whose action in matrix representation is given by 1 0 d : (5.51) Rd ¼ 0 e jp=2 Let Cij(Rd) denote the control-Rd gate, where i is the control qubit and j the target qubit. If x1 ¼ 0, the action of C12(Rd) is given by 1 C12 ðR1 ÞHjx2 i ¼ pffiffiffi ðj0i2 þ e j2p:x2 j1i2 Þ 2
(5.52)
On the other hand, if x1 ¼ 1 then the action of C12(Rd) is given by 1 C12 ðR1 ÞHjx2 i ¼ pffiffiffi ðj0i2 þ e jp=2 e j2p:x2 j1i2 Þ: 2
(5.53)
Equations (5.52) and (5.53) can be jointly combined into 1 C12 ðR1 ÞHjx2 i ¼ pffiffiffi ðj0i2 þ e j2p:x2 x1 j1i2 Þ: 2
(5.54)
To determine the final state in the top branch of Figure 5.13, we further apply C02(R2) on C12(R1)jx2i and obtain: 1 C02 ðR2 ÞC12 ðR1 ÞHjx2 i ¼ pffiffiffi ðj0i2 þ e j2p:x2 x1 x0 j1i2 Þ: 2
(5.55)
The final state of the FT circuit in Figure 5.13 is then given by 1 jJ0 i ¼ pffiffiffi ðj0i0 þ e j2p$x0 j1i0 Þðj0i1 þ e j2p:x1 x0 j1i1 Þðj0i2 þ e j2p$x2 x1 x0 j1i2 Þ: 8
(5.56)
We can see that the qubits are arranged in the opposite order so that additional swap gates are needed. Another option would be to redefine the CB states as jxi ¼ jx0 x1 .xn1 i: The quantum circuit to perform FT for arbitrary n can be obtained by generalization of the corresponding circuit in Figure 5.13, and it is shown in Figure 5.14. Regarding the complexity of the FT circuit, the number of required Hadamard gates is n, while the number of controlled gates is given by n þ ðn 1Þ þ . þ 1x
n2 : 2
Therefore, the overall complexity of the FT computation circuit is O(n2).
(5.57)
5.5 The Period of a Function and Shor Factoring Algorithm
|x n-1 〉
H
R1
|x n-2 〉
|x 1 〉
…
0 + e j 2π . xn−1
x0
1
0 + e j 2π . xn−2
x0
1
R n-1 H
…
R n-3
R n-2
. . .
0 + e j 2π . x1x 0 1 H
R1
|x 0 〉
H
0 + e j 2π . x0 1
FIGURE 5.14 The quantum circuit to perform FT for arbitrary n.
5.5 THE PERIOD OF A FUNCTION AND SHOR FACTORING ALGORITHM 5.5.1 Period of a Function The Shor factorization algorithm [12e15] is based on the possibility of determining in polynomial time the period of a given function f(x). The function f(x) in Shor’s algorithm is defined as f(x) ¼ bx mod N. This function has a period r: f(x) ¼ f(x þ r), x ˛ {0,1,.,2n 1}. For the algorithm to be successful it is important that 2n > N2. A classical algorithm requires O(N) elementary operations. The corresponding quantum algorithm requires O(n3) elementary operations. The function bx mod N behaves as random noise over a period in the classical case. To describe the algorithm for determination of the period of function, we use an interpretation similar to that of Le Bellac [1]. The initial state of n þ m qubits N is given by ! n 2X 1 1 (5.58) jxi 5j0.0i: jFi ¼ n=2 2 x¼0 By applying the function operator Uf on initial state jFi, the final state is n 2X 1 Ff i ¼ Uf jFi ¼ 1 jx; f ðxÞi: 2n=2 x¼0
(5.59)
If we now perform the measurement of the output register and obtain the result f0, the corresponding final state of the first register will be “the state vector collapse”: X 1 (5.60) jxi jJ0 i ¼ N x: f ðxÞ¼f 0
159
160
CHAPTER 5 Quantum Algorithms
where the summation is performed over all values of x for which f(x) ¼ f0, and N is the normalization factor. Since f(x þ r) ¼ f(x), we expect that pr, where p is an integer, to be the period as well: f(x þ pr) ¼ f(x). Let x0 denote the minimum x to satisfy f(x0) ¼ f0, then Eq. (5.60) can be rewritten as follows: 1 1 KX jx0 þ kri; K ¼ ½2n =r or ½2n =r þ 1; jJ0 i ¼ pffiffiffiffi K k¼0
(5.61)
where [z] denotes the integer part of z. A schematic description of the quantum circuit to calculate the period is shown in Figure 5.15. The state of the input register is an incoherent superposition of vectors jJii: i 1 1 KX jJi i ¼ pffiffiffiffiffi jxi þ kri; Ki k¼0
(5.62)
where the minimum x to satisfy f(xi) ¼ fi is denoted by xi. The input register density operator can be written, based on (5.59), as 1 X (5.63) rtot ¼ Jf ihJf ¼ n jx; f ðxÞihz; f ðzÞj; 2 x;z and the density operator of the input register can be obtained by applying the trace operator over output register states: 1 X (5.64) rin ¼ Trout rtot ¼ n jxihzjhf ðxÞjf ðzÞi: 2 x;z As an illustration, let the function f(x) take the value f0 exactly N0 times and the value f1 exactly N1 times, so that N0 þ N1 ¼ 2n, then the following is valid: 0; f ðxÞsf ðzÞ h f ðxÞj f ðzÞi ¼ : (5.65) 1; f ðxÞ ¼ f ðzÞ
|x 〉 Input
Data
|y 〉 UFT
The qubits of the input register are entangled with the qubits of output register; we have to trace over the output register states
FIGURE 5.15 The quantum circuit to determine the period of f(x).
5.5 The Period of a Function and Shor Factoring Algorithm
Upon substitution of (5.65) into (5.64), we obtain: X
1 rin ¼ n 2
jxihzj þ
x;z: f ðxÞ¼f ðzÞ¼f0
!
X
jxihzj :
(5.66)
x;z: f ðxÞ¼f ðzÞ¼f1
Therefore, the density operator rin represents the incoherent superposition of states jJ0i and jJ1i, each occurring with probability pi ¼ N0/2n (i ¼ 0,1), defined as 1 jJ0 i ¼ pffiffiffiffiffiffi N0
X
1 jJ1 i ¼ pffiffiffiffiffiffi N1
jxi
x: f ðxÞ¼f0
X
jxi:
(5.67)
x: f ðxÞ¼f1
Based on (5.61), we can rewrite (5.66) as follows: rin ¼
r 1 K i 1 X 1 X jxi þ ki rihxi þ kj r : n 2 i¼0 k ;k ¼0 i
(5.68)
j
In order to determine the probability amplitude of finding the CB state jyi, we can employ the FT of state: jJi ¼
n 2X 1
f ðxÞjxi; f ðxÞ ¼ hxjJi;
x¼0
n 2X 1
j f ðxÞj2 ¼ 1;
(5.69)
x¼0
pffiffiffiffi which becomes jF0i for f ðxÞ ¼ 1= K ; x ¼ x0 þ kr: Since jF0 i ¼ UFT jJ0 i, the probability amplitude of finding the CB state jyi is given by aðF0 /yÞ ¼ hyjF0 i ¼
1 n 1 KX p ffiffiffiffi e j2pyðx0 þkrÞ=2 ; 2n=2 K k¼0
1
(5.70)
and the corresponding probability is
2 X 1 K1 j2pyðx0 þkrÞ=2n pðyÞ ¼ jaðF0 /yÞj ¼ n e : 2 K k¼0 2
(5.71)
By using the geometric series formula we obtain: K 1 X k¼0
n
n
e j2pykr=2 ¼
n 1 e j2pyKr=2 jpðK1Þr=2n sinðpyKr=2 Þ ; n ¼ e n j2pyr=2 sinðpyr=2 Þ 1e
By using (5.72), the probability p(y) for 2n/r ¼ K can be written as 1 sin2 ðpyÞ 1=r; y ¼ iK pðyÞ ¼ n ¼ : 2 0; otherwise 2 K sin ðpy=KÞ
(5.72)
(5.73)
By substituting yi ¼ i2n =r þ di , we can rewrite Eq. (5.73) as pðyi Þ ¼
1 sin2 ðpdi Kr=2n Þ : 2n K sin2 ðpdi r=2n Þ
(5.74)
161
162
CHAPTER 5 Quantum Algorithms
It can be shown that di satisfies the following inequality: 2n jdi j ¼ yi i < 1=2; r
(5.75)
so that the probability p(y) can be lower bounded by pðyi Þ
4 K 4 1 : x p2 2 n p 2 r
(5.76)
It can be shown that the function p(y) has sharp maxima when the value of y is close to i2n/r. The value i/r can be determined by developing y/2n in continued fractions, repeatedly applying the split and invert method. For example, 5/13 can be represented by using the continued fractions expansion as 1
:
1
2þ 1þ
1 1þ
1 2
The fraction i/r is then obtained as an irreducible fraction i0/r0. If i and r do not have a common factor, then we can immediately obtain r ¼ r0. The probability that two large numbers do not have a common factor is larger than 60%. Therefore, with probability 0.4 0.6 (0.4 comes from the probability of finding yi close to i2n/r), the protocol above will directly give the period r ¼ r0. If f(x) s f(x þ r0), we try f(x) ¼ f(x þ kr0) with small multiples of r0 (such as 2r0, 3r0, .). If all these trials are unsuccessful, it means jdij > 1/2 and the protocol needs to be repeated. This procedure requires O(n3) elementary operations, O(n2) for FT, and O(n) for the calculation of bx.
5.5.2 Solving the RSA Encryption Protocol Once we determine the period r, we can solve the RivesteShamireAdleman (RSA) encryption protocol. Before we describe how to do so, we briefly overview the RSA encryption protocol, which is illustrated in Figure 5.16. Bob chooses two primes p and q, determines N ¼ pq, and a number c that does not have a common divisor with the product (p 1)(q 1). He further calculates d, the inverse for mod (p 1)(q 1) multiplication, by cdh1 mod ðp 1Þðq 1Þ
(5.77)
By a nonsecure path, using a classical communication channel, he sends Alice the values of N and c (but not p and q of course). Alice then sends Bob an encrypted message, which must be represented as a number a < N. Alice calculates bhac mod N
(5.78)
5.5 The Period of a Function and Shor Factoring Algorithm
N, c
Bob
Alice
b d =a
b = ac
b
FIGURE 5.16 The RSA encryption protocol.
and sends the result b over the nonsecure channel. Bob, upon receiving b, calculates bd mod N ¼ a;
(5.79)
and recovers the encrypted number. Example. Let p ¼ 3 and q ¼ 7, meaning that N ¼ 21 and (p 1)(q 1) ¼ 12. We further choose c ¼ 5, which does not have a common divisor with 12. Next, d is determined as the inverse per mod 12 as 5, from cd mod 12 ¼ 25 mod 12 ¼ 1. Let us assume that Alice wants to send a ¼ 4. She first computes ac mod 12 ¼ 45 mod 21 ¼ (1024 ¼ 21 28 þ 16) ¼ 16 ¼ b, and sends it to Bob. Bob computes b5 mod 21 ¼ 165 mod 21 ¼ (49932 21 þ 4) mod 21 ¼ 4 mod 21 and therefore recovers the encrypted number a. After this short overview of RSA protocol, we now describe how to solve it. Eve obtains b, N, c from the public channel, and calculates d0 from cd 0 h1 mod r: She further calculates 0
0 bd
(5.80)
mod N as follows: 0
bd mod N ¼ acd mod N ¼ a1þmr mod N ¼ aðar Þm mod N ¼ a mod N; ar h1mod N:
(5.81)
5.5.3 Shor Factoring Algorithm In order to factorize N we must write ar 1 as ar 1 ¼ ðar=2 1Þ ðar=2 þ 1Þ;
(5.82)
163
164
CHAPTER 5 Quantum Algorithms
while ar/2 s 1 mod N. If the two factors are integers (and ar/2 s 1 mod N), then the product of integers (ar/2 1)(ar/2 þ 1) is divisible by N ¼ pq. The values of p and q are obtained by p ¼ gcdðN; ar=2 1Þ and q ¼ gcdðN; ar=2 þ 1Þ:
(5.83)
From the fundamental arithmetic theorem we know that any positive integer N can be factorized as N¼
k Y
plii ;
(5.84)
i¼1
where pi are the primes and li are their corresponding powers. To factorize N we can generate an integer b between 1 and N 1 randomly, and apply the classical Euclidean algorithm to determine if gcd(b,N) ¼ 1, which requires O[(log2N)3] (classical steps). If gcd(b,N) > 1, then b is a nontrivial factor of N. If, on the other hand, gcd(b,N) ¼ 1, we choose the order of b to be r, i.e. br mod N ¼ 1, and N divides br 1. Further, if r is even we can factorize br 1 as (br/2 1)(br/2 þ 1), and we can find the factors of N using (5.83). Based on the previous discussion, we can summarize the Shor factorization algorithm as follows: 1. Randomly generate an integer b between 0 and N 1, and determine gcd(b,N). If gcd(b,N) > 1, then b is a nontrivial factor of N; otherwise go to the next step. 2. Prepare two quantum registers initialized to the j0i state as follows: jJin i ¼ j0i5m j0i5n ; n ¼ Qlog2 NS:
(5.85)
3. By applying the m-qubit Hadamard transform on the first register, create the superposition state: jJ1 i ¼
1
m 2X 1
2m=2
jxij0i5n :
(5.86)
x¼0
4. Apply the unitary transformation performing the following mapping: jJ2 i ¼ C
m 2X 1
jxijbx mod Ni;
(5.87)
x¼0
where C is a normalization constant. 5. Perform measurement on the second register in the CB to obtain f0, while leaving the first register in uniform superposition of all states for which f(x) ¼ f0: jJ3 i ¼ C 0
K 1 X k¼0
jx0 þ krijf0 i; K ¼ Q2m =rS:
(5.88)
5.6 Simon’s Algorithm
6. Apply the inverse quantum FT on the first register to obtain: jJ4 i ¼ C 00
m 2X 1 K 1 X
e j2pðx0 þkrÞl=2 jlijf0 i: m
(5.89)
l¼0 k¼0
7. Perform the measurement on the first register to obtain l/r, as described in the discussion for inequality (5.75). 8. Apply the continuous fractions expansion algorithm to determine an irreducible fraction l0/r0, followed by the procedure described in the paragraph below Eq. (5.76) that determines the period r. 9. If r is even and br/2 s 1 mod N, then compute gcd(br/2 1,N) ¼ p and gcd(br/2 þ 1,N) ¼ q to check if either p or q is a nontrivial factor. Repeat the procedure above until full prime factorization in the form of Eq. (5.84) is obtained.
5.6 SIMON’S ALGORITHM The Shor factorization algorithm requires the determination of the period of a function. An alternative to this algorithm is Simon’s algorithm [16], which represents a particular instance of the more general problem known as the Abelian hidden subgroup problem. Let us observe the function f from (F2)N to itself, represented by the following unitary map: Uf
jxij0i/jxij f ðxÞi cx: H0
(5.90)
N
Let be a subgroup of (F2) for which the function f is a unique constant for every right coset of H0 . Simon’s algorithm performs O(N) evaluations of the oracle f in combination with classical computation to determine the generators of subgroup H0 . Simon’s algorithm can be formulated as follows: 0. Initialization. Prepare two N-qubit quantum registers initialized to the j0i state: jJin i ¼ j0i5N j0i5N :
(5.91)
1. Superposition state. By applying the N-qubit Hadamard transform on the first register, create the superposition state: 1 X jxij0i5N : (5.92) jJ1 i ¼ N=2 2 N x˛F 2
2. Unitary operation Uf application. Upon applying the Uf operator on the second register we obtain: 1 X jxijf ðxÞi: (5.93) jJ2 i ¼ N=2 2 x˛F N 2
165
166
CHAPTER 5 Quantum Algorithms
3. Measurement step. Perform the measurement on the second register to obtain a value y, which yields the coset of the hidden subgroup in the first register: jJ3 i ¼
1
X
jH 0 j1=2
x: f ðxÞ¼y
jxijyi:
(5.94)
4. Hadamard transform followed by measurement. Apply the N-qubit Hadamard transform to the first register, followed by measurement on the first register in the computational basis. 5. Repeat steps 1e4 approximately N times. The result of this algorithm will be the orthogonal complement of H0 with respect to the scalar product in (F2)N. 6. Solve the system of linear equations by Gauss elimination to obtain the kernel of a square matrix, which contains the generators of H0 .
5.7 CLASSICAL/QUANTUM COMPUTING COMPLEXITIES AND TURING MACHINES Quantum algorithms have raised some questions on the accuracy of some statements from classical algorithm theory where algorithm complexity is concerned. Namely, some problems that appear to be “intractable” (the complexity is exponential in the number of bits n) in classical computing can be solved polynomially in n by means of quantum computers. For example, if prime factorization is an intractable problem, which was suggested by practice but not proven, then Shor’s algorithm discussed above contradicts this observation, as it can represent a composite number in terms of primes in a number of steps that is polynomial in n. The key advantage of quantum algorithms is that they can explore all branches of a nondeterministic algorithm in parallel, through the concept of quantum parallelism. Classical algorithms can be classified as effective when the number of steps is a polynomial function of size n. The computational complexity of these algorithms is typically denoted as P. The class of problems that are solvable nondeterministically in polynomial time are called NP. The subclass of these problems, which are the most difficult ones, are NP-complete problems. For example, the Traveling Salesman Problem belongs to this subclass. If one of these problems can be solved efficiently, then all of them can be solved. The class of problems that can be solved with the amount of memory polynomial in input size is called PSPACE. Further, the class of problems that can be solved with high probability by the use of a random generator is known as BPP, originating from “bounded error probability polynomial in time.” Finally, the class of problems that can be solved in polynomial time, if sums of exponentially many contributors are themselves computable in polynomial time, is denoted as P#P. The different classes of problems discussed above can be related as follows: P3BPP; P3NP3P#P 3PSPACE:
(5.95)
5.7 Classical/Quantum Computing Complexities and Turing Machines
Turing defined a class of machines, known as Turing machines, which can be used to study the complexity of a computational algorithm. In particular, there exist so-called universal machines, which can be used to simulate any other Turing machine. Interestingly enough, the Turing machine can be used to simulate all operations performed on a modern computer. This led to the formulation of the ChurcheTuring thesis as follows: The class of functions that can be computed by a Turing machine corresponds exactly to the class of functions that one would naturally consider to be computable by an algorithm. This thesis essentially establishes the equivalence between rigorous mathematical description (Turing machine) and an intuitive concept. There exist problems that are not calculable and there is no known algorithm to solve them. For example, the halting problem of a Turing machine belongs to this class. The ChurcheTuring thesis is also applicable to quantum algorithms. In the previous paragraph we said that an algorithm is effective if it can be solved in a polynomial number of steps. We also learned that Turing machines can be used to describe these effective algorithms. These two observations can be used to formulate a strong version of the ChurcheTuring thesis: Any computational model can be simulated on a probabilistic Turing machine with a polynomial number of computational steps. There exist several types of Turing machines depending on the type of computation. The deterministic, probabilistic, and multitape Turing machines are described briefly next. The deterministic Turing machine is described by an alphabet A, a set of control states Q, and by a transition function d: d : Q A/Q A D; D ¼ f1; 0; 1g:
(5.96)
The elements of the alphabet are called letters, and by concatenating the letters we obtain words. The set D is related to the read-write head, with the elements 1, þ1, and 0 denoting the movement of the head to the left, right, and standing respectively. The deterministic Turing machine can be defined as (Q,A,d,q0,qa,qr), where the state of the machine is specified by q ˛ Q. In particular, q0,qa,qr ˛ Q denote the initial state, the accepting state, and rejecting state respectively. The configuration of the Turing machine is given by c ¼ (q,x,y), where x,y ˛ A0 , with A0 being the set of all words obtained by concatenating the letters from A. The Turing machine has a tape (memory), specified by xy with x being the scanning (reading). A computation is a sequence of configurations beginning with an initial configuration c0, until we reach the halting configuration. The computation halts after t computation steps when either one of the configurations does not have a successor or if its state is qa or qr. The probabilistic Turing machine is more general, as the transition function assigns probabilities to possible operations: d : Q A Q A D/½0; 1:
(5.97)
In other words, a probabilistic Turing machine is a nondeterministic Turing machine that randomly selects possible transitions according to some probability distribution. As a consequence, the machine-state transitions can be described by a stochastic
167
168
CHAPTER 5 Quantum Algorithms
matrix. A given configuration is a successor configuration with probability d. A terminal configuration can be computed from an initial configuration with a probability given by the product of probabilities of intermediate configurations leading to it by a particular computation, defined by a sequence of states. The deterministic Turing machine is just a particular instance of a probabilistic Turing machine. An m-type deterministic Turing machine is characterized by m tapes, an alphabet A, a finite state of control states Q, and the following transition function: d : Q Am /Q ðA DÞm ;
(5.98)
and defined by (Q,A,d,q0,qa,qr). The configuration of an m-type machine is given by (q,x1,y1,.,xm,ym), where q is the current state of the machine, (xi,yi) ˛ A0 A0 , and xiyi denotes content of the ith type. The m-type machines are suitable for problems involving parallelism. If the computational time needed for a one-type machine is t, then the computation time needed for an m-type machine is O(t1/2), while in terms of computational complexity they are comparable. The quantum Turing machine is characterized by the following transition function: d : Q A Q A D/C ;
(5.99)
which moves a given configuration to a range of successor configurations, each occurring with a quantum probability amplitude, which corresponds to a unitary transformation of a quantum state (we denote the set of complex numbers by C ). Bennett has shown that m-type Turing machines can be simulated by reversible Turing machines, with a certain reduction in efficiency [17]. Further, Toffoli has shown that arbitrary finite mapping can be computed reversibly by padding strings with zeros, permuting them, and projecting some of the bit strings to other bit strings [18]. The elementary reversible gates can be used to implement permutations of bit strings. Finally, Benioff has shown that unitary quantum state evolution (that is reversible) is at least as powerful as a Turing machine [19,20]. The probabilistic classical process can be represented by a tree, which grows exponentially with possible outcomes. The key difference in quantum computing is that we assign the quantum probability amplitudes to the branches in a tree, which can interfere with each other.
5.8 SUMMARY This chapter has presented various quantum algorithms: (i) Deutsch and DeutscheJozsa algorithms (Section 5.2); (ii) Grover search algorithm (Section 5.3); (iii) quantum Fourier transform (Section 5.4); (iv) period-finding and Shor’s factorization algorithms (Section 5.5); and (v) Simon’s algorithm (Section 5.6). Section 5.1 contains a review of the quantum parallelism concept. In Section 5.5 a procedure to solve the RSA encryption protocol was also described. In Section 5.7 classical/quantum computing complexities and Turing machines are considered.
5.9 Problems
In Section 5.9 a set of problems to help the reader gain a deeper understanding of these topics is provided. In addition, problems have been included as regards finding the phase algorithm, the quantum discrete logarithm algorithm, Kitaev’s algorithm, and quantum simulation.
5.9 PROBLEMS 1. By using mathematical induction prove that the circuit in Figure 5.P1 can be used to implement the DeutscheJozsa algorithm e that is, to verify whether the mapping {0,1}n / {0,1} is constant or balanced. 2. By using mathematical induction, prove that the circuit in Figure 5.P2 can be used to calculate the FT for arbitrary n. 3. Assume that a unitary operator U has an eigenket jui with eigenvalue exp(j2p4u). The goal of phase estimation is to estimate the phase 4u. Describe how the quantum Fourier transform can be used for phase estimation. 4. This problem relates to the shift-invariance property of quantum Fourier transform. Let G be a group and H be a subgroup of G. If a function f on G is constant on cosets of H, then the FT of f is invariant over cosets of H. Prove the claim.
H ⊗n
|0〉
x
H ⊗n
x
n
Uf |1〉
H
y⊕f(x)
y
FIGURE 5.P1 Deutsch-Jozsa algorithm implentation circuit
|x n-1 〉
H
R1
…
x0
1
0 + e j 2π . xn−2
x0
1
R n-1
|x n-2 〉
|x 1 〉
0 + e j 2π . xn−1
H
…
R n-3
R n-2
. . .
|x 0 〉
FIGURE 5.P2 Quantum FT implementation circuit
0 + e j 2π . x1x 0 1 H
R1 H
0 + e j 2π . x0 1
169
170
CHAPTER 5 Quantum Algorithms
5. The quantum circuit to perform the Grover search for n ¼ 3 was shown in Figure 5.11. Provide the quantum circuit that can be used to perform a Grover search for arbitrary n. Explain the operating principle and prove that this circuit can indeed be used for any n. 6. Provide the quantum circuit to implement the Shor factorization algorithm for n ¼ 15. Describe the operating principle of this circuit. 7. This problem is devoted to quantum discrete logarithms. Let us consider the following function f ðx1 ; x2 Þ ¼ abx1 þx2 mod N; where all variables are integers. Let r be the smallest positive integer for which ar mod N ¼ 1. This integer can be determined by using the order-finding algorithm. Clearly, this function is periodic as f ðx1 þ i; x2 ibÞ ¼ f ðx1 ; x2 Þ; where i is an integer. The discrete logarithm problem can be formulated as follows: given a and c ¼ ab, determine b. This problem is important in solving the RSA encryption protocol, as discussed in Section 5.5. Your task is to provide a quantum algorithm that can solve this problem by using one query of a quantum block U that performs the following unitary mapping: Ujx1 ijx2 ijyi/ jx1 ijx2 ijy4f ðx1 ; x2 Þi: 8. In Problem 6 you were asked to provide the quantum circuit to implement the Shor factorization algorithm for n ¼ 15. By using Simon’s algorithm, describe how to perform the same task. Provide the corresponding quantum circuit. Analyze the complexity of both algorithms. 9. Suppose that the list of numbers x1,.,xn are stored in quantum memory. How many memory accesses are needed to determine the smallest number in the list with success probability 1/2? 10. Provide the quantum circuit to perform the following mapping: p1 1 X j2pmn=p e jni; jmi/pffiffiffi p n¼0
where p is a prime. 11. Design a quantum circuit to perform the mapping jxi / jx þ c mod 2ni, where x ˛ [0,2n 1] and c is a constant, by using quantum FT. 12. The circuit in Figure 5.P12 can be used to perform addition. Describe the operating principle and provide the result of addition. Can you generalize this addition problem? 13. This problem relates to Kitaev’s algorithm, which represents an alternative way to estimate the phase. Consider the quantum circuit in Figure 5.P13, where jui is an eigenket of U with eigenvalue exp(j2p4u). Show that the result of the measurement being 0 appears with probability of p ¼ cos2(p4). Since the eigenket is insensitive to measurement of the operator U, it can be replaced by U m, where m is an arbitrary positive integer. Show that by repeating this circuit appropriately we can obtain the arbitrary precision of p and consequently estimate the phase 4 with desired precision. Compare the complexity of Kitaev’s algorithm with respect to that of Problem 3.
5.9 Problems
|x 1 〉 |x 2 〉 |x 3 〉 |y 1 〉
|z 1 〉
|y 2 〉
|z 2 〉
|y 3 〉 |0 〉
|z 3 〉
|c 1 〉 |c 2 〉
|0 〉
|c 3 〉
|0 〉 carry
FIGURE 5.P12 Circuit.
Ancillary |0 〉
H
H
|u〉
|u〉
U
FIGURE 5.P13 Kitaev’s algorithm implentation
14. The state ket after application of Hadamard gates of the circuit in Figure 5.P14 can be written in the following form: jji ¼
|0〉
H
|0〉
H
|0〉
H
|1〉
H
1 X N 1=2
að0Þ jxi; x x
G
FIGURE 5.P14 Quantum circuit to perform Grover search (n ¼ 3)
að0Þ x ¼ 1:
G
171
172
CHAPTER 5 Quantum Algorithms
The application of operator GO on jji leads to the following ket: jji ¼
1 X N 1=2
að1Þ jxi: x x ð1Þ
ð0Þ
Establish the connection between coefficients ax and ax : 15. This problem relates to quantum simulation. For a Hamiltonian H that can be represented as the sum of a polynomial of many terms Hm, namely H ¼ SmHm, each of which can be efficiently implemented, we can efficiently simulate the j j evolution operator exp Ht and approximate jjðtÞi ¼ exp Ht jjð0Þi: Z Z j Q j Hk t e Z : However, If for all m,n [Hm,Hn] ¼ 0, then we can write exp Ht ¼ Z k if [Hm,Hn] s 0, then the previous equation is not valid. The following formula, known as the Trotter formula, can be used for approximations leading to quantum simulation algorithms, lim ðejU1 t=n ejU2 t=n Þ ¼ ejðU1 þU2 Þt ; where U1 and U2 are n/N
Hermitian operators. Prove the Trotter formula. Prove also the following useful approximations: ejðU1 þU2 ÞDt ¼ ejU1 Dt ejU2 Dt þ OðDt2 Þ; ejðU1 þU2 ÞDt ¼ ejU1 Dt=2 ejU2 Dt ejU1 Dt=2 þ OðDt3 Þ: Finally, the following approximation, known as the BakereCampbelleHausdorf formula, is also useful in quantum simulation: 2 eðU1 þU2 ÞDt ¼ eU1 Dt eU2 Dt e½U1 ;U2 Dt =2 þ OðDt3 Þ: Prove it. Consider now a single particle with one-dimensional potential V(x), governed by the Hamiltonian H ¼ p2 =ð2mÞ þ VðxÞ: Perform the computation jjðtÞi ¼ expðjHt=ZÞjjð0Þi by using the approximations above. 16. Construct the quantum circuit to simulate the Hamiltonian H ¼ Z1Z2.Zn, performing the unitary transform jjðtÞi ¼ expðjHt=ZÞjjð0Þi for arbitrary Dt.
References [1] M. Le Bellac, An Introduction to Quantum Information and Quantum Computation, Cambridge University Press, 2006. [2] M.A. Neilsen, I.L. Chuang, Quantum Computation and Quantum Information, Cambridge University Press, 2000. [3] F. Gaitan, Quantum Error Correction and Fault Tolerant Quantum Computing, CRC Press, 2008. [4] G. Jaeger, Quantum Information: An Overview, Springer, 2007. [5] D. Petz, Quantum Information Theory and Quantum Statistics, Theoretical and Mathematical Physics, Springer, Berlin, 2008. [6] P. Lambropoulos, D. Petrosyan, Fundamentals of Quantum Optics and Quantum Information, Springer-Verlag, Berlin, 2007. [7] G. Johnson, A Shortcut Through Time: The Path to the Quantum Computer, Knopf, New York, 2003. [8] J. Preskill, Quantum Computing (1999). Available at: http://www.theory.caltech.edu/ ~preskill/.
References
[9] [10] [11] [12]
[13] [14] [15]
[16]
[17] [18]
[19]
[20]
J. Stolze, D. Suter, Quantum Computing, Wiley, New York, 2004. R. Landauer, Information is physical, Phys. Today 44 (5) (May 1991) 23e29. R. Landauer, The physical nature of information, Phys. Lett. A 217 (1991) 188e193. P.W. Shor, Algorithms for quantum computation: discrete logarithm and factoring, Proc. IEEE 35th Annual Symposium on Foundations of Computer Science (1994) p. 124. P.W. Shor, Polynomial-time algorithms for prime number factorization and discrete logarithms on a quantum computer, SIAM J. Comput. 26 (1997) 1484. A. Ekert, R. Josza, Shor’s factoring algorithm, Rev. Mod. Phys. 68 (1996) 733e753. T. Beth, M. Ro¨tteler, Quantum algorithms: Applicable algebra and quantum physics, in: G. Alber, T. Beth, M. Horodecki, P. Horodecki, R. Horodecki, M. Ro¨tteler, H. Weinfurter, R. Werner, A. Zeilinger (Eds.), Quantum Information, Springer-Verlag, Berlin, 2001, pp. 96e150. D.R. Simon, On the power of quantum computation, in: S. Goldwasser (Ed.), Proc. IEEE 35th Annual Symposium on the Foundations of Computer Science, Los Alamitos, CA, 1994, p. 116. C.H. Bennett, Time/space trade-offs for reversible computation, SIAM J. Comput. 18 (1989) 766e776. T. Toffoli, Reversible computing, in: G. Goos, J. Hartmanis (Eds.), Automata, Languages and Programming, Lecture Notes in Computer Science 85, SpringerVerlag, Berlin, 1980, p. 632. P. Benioff, The computer as a physical system: A microscopic quantum mechanical Hamiltonian model of computers as represented by Turing machines, J. Stat. Phys. 22 (5) (1980) 563e591. P. Benioff, Models of quantum Turing machines, Fortschr. Phys. 46 (1998) 423.
173