Amplitude Amplification
Amplitude Amplification
1 Abstract: In this paper we investigate on the effects of a quantum algorithm which increases the
2 amplitude of the states corresponding to the solutions of the partition problem by a factor of almost
3 two. The study is limited to one iteration.
32 | E| natural numbers, that is, we always consider E = {0, 1, . . . , n − 1}. Furthermore, we note that if PP
33 has a solution E0 then E − E0 is also a solution of the PP.
34 The literature is abundant in the study of this problem, for which the dynamic programming
35 solving strategy is the most commonly applied. More recently, it has also been approached from the
36 point of view of quantum computing, among these references we can mention [5], where an instance
37 of the subset-sum problem can be implemented by a quantum algorithm using nuclear magnetic
38 resonance (NMR) technique. In that paper, even at a very early stage and with a low number of qubits,
39 they limit themselves to showing that the problem can be approached from this new perspective.
40 In [6], the authors studied the problem through both an asymptotic heuristic and a new data
41 structure for using quantum gates. There, being possible to obtain an improvement over classical
42 algorithms is shown, specifically the Howgrave-Graham–Joux [7] which of course is fully coherent
43 with the NP ⊆ BQP conjecture, obtaining a bound time Õ(22/3n ).
44 More recently, in 2018, Helm and May [8] proposed a quantum algorithm that reduces the heuristic
45 time to Õ(20.226n ). A couple of years later, Li and Li [9] reduce this time beyond that, i.e. to Õ(20.209n ).
46 In this work we will get rid of the heuristics of these studies to better go for the modest approach
47 of [5]. In this sense, we propose a piece of quantum code using a quantum circuit to model the
48 problem, consequently we devise a transformation that will allow us to increase the amplitudes of
49 those corresponding to the solution by 50%, leaving the line of how and how many times this process
50 could be iterated, as the key issue to be dealt with. In fact, we think that we could find the same
51 limitations than those from Grover’s algorithm. Anyway, we believe that this line of research deserves
52 to be addressed.
53 Let x ∈ N, 0 ≤ x < 2n then we say that | x i is a computational state which binary representation is
54 | xn−1 xn−2 . . . x0 i being xn−1 the most significant bit of the binary representation of | x i.
55 The S gate for a single qubit is represented by the following matrix:
" #
1 0
S=
0 i
√
56 Another usual gates, are Pauli X gate, also known as NOT gate, and X gate.
" # " #
0 1 √ 1 1+i 1−i
X= X=
1 0 2 1−i 1+i
58 While the same gate for n qubits is represented by the following matrix
n √
" #
n 2 1 1
H⊗ =
O
i =1
2 1 −1
59 As stated before, we are interested in amplifying amplitudes for the search problem. In order to
60 do this we make use of sequences of quantum gates in the way Hadamard - S - Hadamard. Let´s start
61 describing graphically the effect of such quantum gates so resorting to the positions of the state vector
62 represented in the Bloch sphere.
63 The effect of applying a H q-gate over a qubit represented on the Bloch Sphere can be seen as
64 “first rotating an angle of π radians around Z axis and then rotating an angle of π2 radians around the
65 Y axis" (fully equivalent to “first rotating an angle of π2 radians around the Y axis and then rotating an
66 angle of π radians around X axis" which are the movements made by H in figure 1). Hadamard q-gate
67 application changes a qubit from a computational basis to a Hadamard basis. For better understanding
Version July 27, 2021 submitted to Mathematics 3 of 11
68 the effects of the sequence H - S - H we start, as usual, from a qubit initialized to |0i, i.e. located at the
69 north pole of the Bloch s. which moved through a Hadamard gate gets located at the equator of the
70 Bloch s., specifically on the X axis, in the position usually known as a |+i, which corresponds to the
71 qubit
√ √
2 2
|+i = |0i + |1i
2 2
72 After this gate, we apply a S gate, the effect of which is a rotation of the state vector through an
73 angle of π2 radians around the Z axis. This places the qubit at position |i i.
√ √
2 2
|i i = |0i + i · |1i
2 2
74 Finally, the effect of the second application of gate H is reseting the computational base, and then,
75 the vector from position |i i moves to the opposite point on the Y axis, that is, to the position
√ √
2 2
| − ii = |0i − i · |1i
2 2
76 In general, we have the following result
√
HSH = X
π
77 That is, a HSH gate is equivalent to a 2 radiants clockwise rotation around X axis as figure 1
78 shows over a single qubit initialized to |0i.
It is well known, see [3], that given any computational state | x i where 0 ≤ x < 2n
2n −1
n 1
|ψi = H ⊗ | x i = √
2n
∑ (−1)x·z |zi (2)
z =0
Proof. By induction on n being the base case with n = 1 straightforward. So suppose that the statement
holds for n − 1. Then
n n −1
S ⊗ | x i = S | x n −1 i ⊗ S | x n −2 i · · · ⊗ S | x 0 i = S ⊗ | x n −1 . . . x 1 i ⊗ S | x 0 i =
∑nj=−11 xj
=i | xn−1 . . . x1 i ⊗ S| x0 i = (by induction hypothesis)
∑nj=−11 xj
=i | x n −1 . . . x 1 i ⊗ i x0 | x 0 i =
= i w ( x ) | x n −1 x n −2 . . . x 0 i
90
2n −1 2n −1
n n n n 1 1
|ψ1 i = S⊗ H ⊗ |0i⊗ = S⊗ √
2n
∑ |xi = √
2n
∑ i w( x ) | x i
x =0 x =0
2n −1 2n −1
" #
⊗n 1 1
|ψ2 i = H |ψ1 i = √
2n
∑ i w( x )
√
2n
∑ (−1) x ·z
|zi
x =0 z =0
2n −1 2n −1 2n −1 2n −1
!
1 1
|ψ2 i = n
2 ∑ ∑ (−1) x ·z w( x )
i |zi = n
2 ∑ ∑ i w( x )
(−1) x ·z
|zi
z =0 x =0 z =0 x =0
2n −1
∑ iw( x) (−1) x·z (3)
x =0
91 for every 0 ≤ z < 2n . We will do this in the following two theorems. First of all we need the next
92 Lemma which will be heavily used int the rest of the paper.
Lemma 2. Let 0 ≤ z < 22m+1 and 0 ≤ x < 22m+1 and let z2m z2m−1 . . . z0 and x2m x2m−1 . . . x0 be the binary
representation, respectively, of z and x. We have that
22m+1 −1 22m −1 −1
2m
∑2m
∑ iw( x) (−1)∑ j=0 j =0 z j · x j
zj ·xj
= i (−1)z2m ∑ iw( x) (−1) (4)
x =22m x =0
Version July 27, 2021 submitted to Mathematics 5 of 11
Proof. We note that, on the left hand of the equation (4), for every element of the sum, we have that
2m−1
x2m = 1. Therefore ∑2m
j=0 z j · x j = ∑ j=0 z j · x j + z2m . Based on this we have that
22m+1 −1 22m+1 −1 −1
2m
∑2m
∑ iw( x) (−1)∑ j=0 j =0 z j · x j
zj ·xj
= (−1)z2m ∑ iw( x) (−1)
x =22m x =22m
93 Furthermore for the same reason above, if 22m ≤ x < 22m+1 and if 0 ≤ x̄ < 22m then we have that
94 w( x ) = w( x̄ ) + 1 and this prove the equation (4).
2n −1
∑ iw( x) (−1)z· x = (−1)w(z) im+w(z) 2m (5)
x =0
Proof. We prove the equation (5) on induction on m being the base case with m = 1 easily verifiable
for all z ∈ {0, 1, 2, 3}. So suppose the statement holds for all h ≤ m and for all 0 ≤ z < 22m . Then, for
any 0 ≤ z < 22m+2 we have
22m+2 −1 22m −1 −1
∑2m
j =0 z j · x j
∑ iw( x) (−1)z· x = ∑ iw( x) (−1) (6)
x =0 x =0
22m+1 −1 2m
∑ iw( x) (−1)∑ j=0
zj ·xj
+ + (7)
x =22m
22m+2 −1 +1
∑2m
j =0 z j · x j
+ ∑ iw( x) (−1) (8)
x =22m+1
Now, by equation (4) and by induction hypothesis, we have that (7) is equal to
22m+1 −1 22m −1 −1
2m
∑2m
∑ iw( x) (−1)∑ j=0 j =0 z j · x j
zj ·xj
= i (−1)z2m ∑ iw( x) (−1) =
x =22m x =0
Likewise, in the term (8), for each x is the sum, the bit x2m+1 is always set to 1, so we have that (8) is,
by equation (4), equal to
22m+2 −1 +1 22m+1 −1
∑2m 2m
∑ j =0 z j · x j
∑ iw( x) (−1)∑ j=0
w( x ) z2m+1 zj ·xj
i (−1) = i (−1) (10)
x =22m+1 x =0
Now by repeatedly applying equation (4) and the induction hypothesis we have that the sum in right
hand of equation (10) is
22m+1 −1 2m
∑ iw( x) (−1)∑ j=0
zj ·xj
= (11)
x =0
22m −1 −1 22m+1 −1
∑2m 2m
∑ j =0 z j · x j
∑ iw( x) (−1)∑ j=0
zj ·xj
= iw( x) (−1) + =
x =0 x =22m
22m −1 −1
∑2m
j =0 z j · x j
= (−1)w(z-2 ) im+w(z-2 ) 2m + i (−1)z2m ∑ iw( x) (−1) =
x =0
= (−1)w(z-2 ) im+w(z-2 ) 2m [1 + i (−1)z2m ] (12)
Version July 27, 2021 submitted to Mathematics 6 of 11
95 So if we replace (12) in (10) and if we sum together (6), (9) and (10) we obtain
h i
az =(−1)w(z-2 ) im+w(z-2 ) 2m 1 + i (−1)z2m + i (−1)z2m+1 + i2 (−1)z2m +z2m+1 =
96 for every 0 ≤ z < 22m+2 , and this proves the induction step.
2n −1
∑ iw( x) (−1)z· x = (−1)w(z) im+w(z) 2m (1 + i ) (14)
x =0
Proof. First of all we note that equation (14) holds if m = 0 and z ∈ {0, 1}. So in the following we
suppose that m > 1. We have that
22m+1 −1
az = ∑ iw( x) (−1)z· x =
x =0
22m −1 −1 22m+1 −1
∑2m 2m
∑ j =0 z j · x j
∑ iw( x) (−1)∑ j=0
zj ·xj
= iw( x) (−1) +
x =0 x =22m
22m −1 −1
∑2m
j =0 z j · x j
az = (−1) w(z-1 ) m+w(z-1 ) m
i 2 + i (−1) z2m
∑ iw( x) (−1) =
x =0
=(−1)w(z-1 ) im+w(z-1 ) 2m + i (−1)z2m (−1) w(z-1 ) m+w(z-1 ) m
i 2 =
=(−1)w(z-1 ) im+w(z-1 ) 2m [1 + i (−1)z2m ] (15)
Let z2m z2m−1 . . . z0 be the binary representation of z. Suppose first that z2m = 0. Then equation (15)
become
(−1)w(z) im+w(z) 2m + (−1)w(z) im+w(z)+1 2m (16)
and the Theorem is therefore proved. So suppose that z2m = 1. Then equation (15) become
98 As an example we have computed the amplitudes az (disregarding the normalization factor) for
99 n ∈ {3, 4} and we report them on Table 1.
Version July 27, 2021 submitted to Mathematics 7 of 11
|zi az
|0000i −4
|0001i 4i
|0010i 4i
|zi az |0011i 4
|000i −2 + 2i |0100i 4i
|001i 2 + 2i |0101i 4
|010i 2 + 2i |0110i 4
|011i 2 − 2i |0111i −4i
|100i 2 + 2i |1000i 4i
|101i 2 − 2i |1001i 4
|110i 2 − 2i |1010i 4
|111i −2 − 2i |1011i −4i
|1100i 4
|1101i −4i
|1110i −4i
|1111i −4
Table 1. Left the amplitudes of az for n = 3. Right the amplitudes of az for n = 4. In order to get the
final amplitudes one should multiply them by a suitable normalization factor.
where σ is set to the two’s complement of −S and |ci is set to |1i. Then, we apply the Hadamard
q-gate to the first n qubits so obtaining
2n −1
n
1
| ϕ 1 i = H ⊗ ⊗ I m +1 | ϕ 0 i = √
2n
∑ | x i|σi|ci
x =0
Next, we uses each qubit xe to conditionally sum the element s(e) to |σ i. If there exist a solution to the
m
PP then, in the final superposition of |σ i, the amplitude of the state | x i|0i⊗ |ci will not be 0. The states
| x i for which |σi is zero will be referred as the solutions states of the PP. The control qubit |ci will be set
Version July 27, 2021 submitted to Mathematics 8 of 11
m
to zero exactly for those states for which |σ i = |0i⊗ . At this point we apply an uncomputational step
in order to set |σ i = | − Si. Now if we apply the S gate to the first n qubits we obtain, by Lemma 1
2n −1
n 1
| ϕ 2 i = S ⊗ ⊗ I m +1 | ϕ 1 i = √
2n
∑ iw( x) | x i|σ i|ci
x =0
Afterwards Hadamard gate is applied to the first n qubits controlled by the control qubit |ci such that
it only affects non solution states (see Figure 2). For the sake of simplicity we suppose that PP has only
two solutions whose numeric representation are y and its bitwise complement y. By equation (3), we
obtain
n
contr H ⊗ 1
| ϕ2 i −−−−−→ | ϕ3 i = √
2n
∑ iw(z) |zi|σ i|0i+
z∈{y,y}
2n −1
1
+
2n ∑ ∑ iw( x) (−1) x·z |zi|σ i|1i =
z =0 x ∈
/ {y,y}
2n −1
1 √ n
= n 2 ∑ iw(z) |zi|σ i|0i + ∑ ∑ iw( x) (−1) x·z |zi|σ i|1i (19)
2 z∈{y,y} z =0 x ∈
/ {y,y}
Now we want to quantify the amplitude of the state |yi|σ i|1i and |yi|σ i|1i of equation (19). We
consider only the state |yi|σ i|1i since the same arguments can be applied to state |yi|σi|1i. The
amplitude by of the state |yi|σ i|1i (in the following we disregard the normalization factor 1/2n ) is
given by the following formula
2n −1
by = ∑ i w( x )
(−1) x ·y
= ∑ iw( x) (−1) x·y − ∑ iw( x) (−1) x·y (21)
x∈
/ {y,y} x =0 x ∈{y,y}
We have that
118 Then, recalling that i x = i− x when x is even and i− x = −i x when x is odd, we have two cases:
• w(y) is even
• w(y) is odd
For simplicity of notation in the following we denote w(y) as simply w. We have that if n = 2m is even
then, by Theorem 3, by is
w m+w 2m − i w (1 + i2m )
(−1) i
if w is even
by = (25)
(−1)w im+w 2m + iw (1 + i2m )
if w is odd
119 It is immediate to check that in the above equations (25) and (26) the term iw (1 + in ) become negligible,
120 with respect to the other term in the equation, as m becomes bigger. We conclude that the amplitude of
121 the state |yi|σ i|1i is almost the same of the amplitude of state |yi|σ i|0i, thus effectively duplicating
122 the chances of state |yi at the end of the circuit.
123 Figure 2 captures on Quirk simulator the instance of the PP where elements in E are s(0) =
124 2, s(1) = 1 and s(2) = 3 thus −S = −3 which in two’s complement is represented with four bits
125 σ = 1101 so depicted from row 4th to row 7th (top - down referring). Control qubit is located in 8th
126 row, and qubits 9th to 14th are used for the function s. Since n = 2m + 1 = 3 and |yi = |011i we have
1 h √ 2 i 26
127 that by = 3 − 3i, thus the probability of getting |yi is, by (19), |2 2| + |3 − 3i |2 = = 0.40625
64 64
128 which is exactly the output of Quirk simulator as it can be checked in [10].
138
139 1. Shor, P. Algorithms for quantum computation: discrete logarithms and factoring. Proceedings 35th Annual
140 Symposium on Foundations of Computer Science, 1994, pp. 124–134. doi:10.1109/SFCS.1994.365700.
141 2. Deutsch, D.; Jozsa, R. Rapid solution of problems by quantum computation. Proceedings
142 of the Royal Society of London. Series A: Mathematical and Physical Sciences 1992, 439, 553–558,
143 [https://royalsocietypublishing.org/doi/pdf/10.1098/rspa.1992.0167]. doi:10.1098/rspa.1992.0167.
144 3. Nielsen, M.A.; Chuang, I.L. Quantum Computation and Quantum Information: 10th Anniversary Edition, 10th
145 ed.; Cambridge University Press: USA, 2011.
146 4. Karp, R. Reducibility among combinatorial problems. In Complexity of Computer Computations; Miller, R.;
147 Thatcher, J., Eds.; Plenum Press, 1972; pp. 85–103.
148 5. Chang, W.L.; Ren, T.T.; Feng, M.; Lu, L.C.; Lin, K.W.; Guo, M. Quantum Algorithms of the Subset-Sum
149 Problem on a Quantum Computer. 2009 WASE International Conference on Information Engineering,
150 2009, Vol. 2, pp. 54–57. doi:10.1109/ICIE.2009.15.
151 6. Bernstein, D.J.; Jeffery, S.; Lange, T.; Meurer, A. Quantum Algorithms for the Subset-Sum Problem.
152 Post-Quantum Cryptography; Gaborit, P., Ed.; Springer Berlin Heidelberg: Berlin, Heidelberg, 2013; pp.
153 16–33.
154 7. Howgrave-Graham, N.; Joux, A. New generic algorithms for hard knapsacks. Cryptology ePrint Archive,
155 Report 2010/189, 2010. https://eprint.iacr.org/2010/189.
156 8. Helm, A.; May, A. Subset Sum Quantumly in 1.17n . 13th Conference on the Theory ofQuantum
157 Computation, Communication and Cryptography; , 2018; pp. 5:1–5:16.
158 9. Li, Y.; Li, H. Improved quantum algorithm for the random subset sum problem. CoRR 2019, abs/1912.09264,
159 [1912.09264].
160 10. Mezzini, M. Quirk’s url of an instance of the Partition Problem. https://tinyurl.com/kp38rajd, 2021.
161 11. Beals, R.; Buhrman, H.; Cleve, R.; Mosca, M.; de Wolf, R. Quantum Lower Bounds by Polynomials. J. ACM
162 2001, 48, 778–797. doi:10.1145/502090.502097.
163 Author Contributions: Individual contributions are as follows: Conceptualization Mauro Mezzini and Jose J.
164 Paulet; Formal analysis Mauro Mezzini, Fernando Cuartero and Fernando L Pelayo; Investigation Mauro Mezzini,
165 Jose J Paulet, Fernando Cuartero, Hernan Indibil and Fernando L Pelayo; Writing – original draft Mauro Mezzini,
166 Jose J. Paulet, Hernan Indibil and Fernando Cuartero; Writing – reviewing & editing Mauro Mezzini and Fernando
167 L Pelayo
168 Conflicts of Interest: “The authors declare no conflict of interest.”
169 © 2021 by the authors. Submitted to Mathematics for possible open access publication
170 under the terms and conditions of the Creative Commons Attribution (CC BY) license
171 (http://creativecommons.org/licenses/by/4.0/).