 # Quantum algorithm for doubling the amplitude of the search problem's solution states

In this paper we present a quantum algorithm which increases the amplitude of the states corresponding to the solutions of the search problem by a factor of almost two.

## Authors

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction and preliminaries

We denote the set of natural number excluding the 0 element by . If , then we say that is a computational state. We denote by the binary representation of where is the most significant bit of the binary representation of . Let also denote by . If , we denote by the sum . Furthermore, for any , , we denote by a natural number obtained from by considering only the least significant bits, that is, if the binary representation of is then the binary representation of is . The

gate for a single qubit is represented by the following matrix:

 S=∣∣∣100i∣∣∣ (1)

## 2 The effect of applying Hadamard, S and Hadamard gates to |0⟩⊗n

In this section we want to determine the effect of applying the Hadamard, S and Hadamard gates on quantum state , that is, we want to determine a formula for

 |α⟩=H⊗nS⊗nH⊗n|0⟩⊗n (2)

and we show that in the final superposition the amplitude of a sigle state depends by .

It is known  that given any computational state ,

 |ψ⟩=H⊗n|x⟩=1√2n2n−1∑z=0(−1)x⋅z|z⟩ (3)

###### Lemma 1.

Let

 S⊗n|x⟩=iw(x)|xn−1xn−2…x0⟩
###### Proof.

By induction on being the base case with straightforward. So suppose that the statement holds for . Then

 S⊗n|x⟩ =S|xn−1⟩⊗S|xn−2⟩⋯⊗S|x0⟩=S⊗n−1|xn−1…x1⟩⊗S|x0⟩= =i∑n−1j=1xj|xn−1…x1⟩⊗S|x0⟩= (by induction hypothesys) =i∑n−1j=1xj|xn−1…x1⟩⊗ix0|x0⟩= =iw(x)|xn−1xn−2…x0⟩

Now by Lemma 1 and equation (3), we have that

 |ψ1⟩=S⊗nH⊗n|0⟩⊗n=S⊗n1√2n2n−1∑x=0|x⟩=1√2n2n−1∑x=0iw(x)|x⟩

and applying the Hadamard to , by (3), we have that

 |ψ2⟩=H⊗n|ψ1⟩=1√2n2n−1∑x=0iw(x)[1√2n2n−1∑z=0(−1)x⋅z|z⟩]

and reordering the term of the sum we have that

 |ψ2⟩=12n2n−1∑z=02n−1∑x=0(−1)x⋅ziw(x)|z⟩=12n2n−1∑z=0(2n−1∑x=0iw(x)(−1)x⋅z)|z⟩

So in order to compute the amplitudes of we need to compute the sum

 2n−1∑x=0iw(x)(−1)x⋅z

for every . We will do this in the following two theorems. First of all we need the following Lemma.

###### Lemma 2.

Let and and let and be the binary representation, respectively, of and . We have that

 22m+1−1∑x=22m iw(x)(−1)∑2mj=0zj⋅xj=i(−1)z2m22m−1∑x=0iw(x)(−1)∑2m−1j=0zj⋅xj (4)
###### Proof.

We note that, on the left hand of the equation (4), for every element of the sum, we have that . Therefore . Based on this we have that

 22m+1−1∑x=22m iw(x)(−1)∑2mj=0zj⋅xj=(−1)z2m22m+1−1∑x=22miw(x)(−1)∑2m−1j=0zj⋅xj

Furthermore for the same reason above, if and if then we have that and this prove the equation (4). ∎

###### Theorem 3.

Let , . If is even we have that

 2n−1∑x=0iw(x)(−1)z⋅x=(−1)w(z)im+w(z)2m (5)
###### Proof.

We prove the equation (5) on induction on being the base case with easily verifiable for all . So suppose the statement holds for all and for all . Then, for any we have

 22m+2−1∑x=0iw(x)(−1)z⋅x= 22m−1∑x=0iw(x)(−1)∑2m−1j=0zj⋅xj (6) + 22m+1−1∑x=22miw(x)(−1)∑2mj=0zj⋅xj+ (7) + 22m+2−1∑x=22m+1iw(x)(−1)∑2m+1j=0zj⋅xj (8)

Now, by equation (4) and by induction hypothesys, we have that (7) is equal to

 22m+1−1∑x=22m iw(x)(−1)∑2mj=0zj⋅xj=i(−1)z2m22m−1∑x=0iw(x)(−1)∑2m−1j=0zj⋅xj= =i(−1)z2m(−1)w(z-2)im+w(z-2)2m (9)

Likewise, in the term (8), for each is the sum, the bit is always set to 1, so we have that (8) is, by equation (4), equal to

 22m+2−1∑x=22m+1 iw(x)(−1)∑2m+1j=0zj⋅xj=i(−1)z2m+122m+1−1∑x=0iw(x)(−1)∑2mj=0zj⋅xj (10)

Now by repeatedly applying equation (4) and the induction hypothesys we have that the sum in right hand of equation (10) is

 22m+1−1∑x=0 iw(x)(−1)∑2mj=0zj⋅xj= (11) = 22m−1∑x=0iw(x)(−1)∑2m−1j=0zj⋅xj+22m+1−1∑x=22miw(x)(−1)∑2mj=0zj⋅xj= =(−1)w(z-2)im+w(z-2)2m+i(−1)z2m22m−1∑x=0iw(x)(−1)∑2m−1j=0zj⋅xj= =(−1)w(z-2)im+w(z-2)2m[1+i(−1)z2m] (12)

So if we replace (12) in (10) and if we sum togheter (6), (9) and (10) we obtain

 az= (−1)w(z-2)im+w(z-2)2m[1+i(−1)z2m+i(−1)z2m+1+i2(−1)z2m+z2m+1]= = (−1)w(z-2)im+1+w(z-2)2m[−i+(−1)z2m+(−1)z2m+1+i(−1)z2m+z2m+1] (13)

Now if we denote by we have that (13) is

 az=⎧⎪⎨⎪⎩2P if z2m=z2m+1=0% −2iP if z2m≠z2m+1 −2P if z2m=z2m+1=1

and it is now easy to verify that

 az=(−1)w(z)im+1+w(z)2m+1

for every , and this proves the induction step. ∎

###### Theorem 4.

Let

an odd natural,

and let , . Then

 2n−1∑x=0iw(x)(−1)z⋅x=(−1)w(z)im+w(z)2m(1+i) (14)
###### Proof.

First of all we note that equation (14) holds if and . So in the following we suppose that . We have that

 az =22m+1−1∑x=0iw(x)(−1)z⋅x= = 22m−1∑x=0iw(x)(−1)∑2m−1j=0zj⋅xj+22m+1−1∑x=22miw(x)(−1)∑2mj=0zj⋅xj

and, by Theorem 3, and by equation (4), we have

 az =(−1)w(z-1)im+w(z-1)2m+i(−1)z2m22m−1∑x=0iw(x)(−1)∑2m−1j=0zj⋅xj= = (−1)w(z-1)im+w(z-1)2m+i(−1)z2m(−1)w(z-1)im+w(z-1)2m= = (−1)w(z-1)im+w(z-1)2m[1+i(−1)z2m] (15)

Let be the binary representation of . Suppose first that . Then equation (2) become

 (−1)w(z)im+w(z)2m+(−1)w(z)im+w(z)+12m (16)

and the Theorem is therefore proved. So suppose that . Then equation (2) become

 (−1)w(z)−1im+w(z)−12m+(−1)w(z)im+w(z)2m (17)

but observing that

 (−1)w(z)im+w(z)+1=(−1)w(z)−1im+w(z)−1 (18)

we have that also in this case the Theorem is satisfied. ∎

As an example we have computed the amplitudes (disregarding the normalization factor) for and we report them on Table 1.

## 3 Doubling the amplitude of the search problem’s solution states

In this section we consider a quantum circuit for doubling the amplitude of solution’s states of the search problem. For a search problem we refer, in general, to the problem of finding a solution of some NP-complete problem. Like in the Groover algorithm we will use the intrinsic quantum mechanical parallelism and an oracle , specifically designed for the specific problem at hand, which return is is a solution of the problem and otherwise.

In particular, in order to present in the detail the results of this paper, we will use a quantum oracle for the Partition Problem (PP). In the PP we have a finite set of elements and a function . We want to find a subset such that . From now on we do not loss generality if we consider the set equal to the set of the first naturals, that is we always consider . Furthermore we note that if PP has a solution then is also a solution of the PP:

The partition problem (PP) is well known to be an NP-complete problem .

We describe, in the following, an application of the gates described in the previous section in a quantum circuit to deal with PP (see Figure 1). While the following results apply specifically to the PP they can be applied to any other search problem.

Denote by . Recall that PP problem has a solution only if is an integer. We use the two’s complements representation of requiring qubits. Then for each , we use qubits to encode . These qubits will remain constant in every phase of the circuit and therefore we will not consider them in the reasoning that follows. We use qubits to encode a subset of . If is the state of those qubits, then an element , , is included in the set if and only if . We will use qubits, denoted in the following by , to store the sum for the elements selected in . In this way for a solution of the PP. We also use a control qubit .

So we have four groups of bits: , , and the sets of qubits used to represent the constants for each element of . Note that the number of qubits of the circuit, , is polynomial in the size of a coincise specification of the PP.

At the beginning of the circuit we have the following superposition:

 |φ0⟩=|0⟩⊗n|σ⟩|c⟩

where is set to the two’s complement of and is set to . Then, we apply the Hadamard gate to the first qubits obtaining

 |φ1⟩ =(H⊗n⊗Im+1)|φ0⟩=1√2n2n−1∑x=0|x⟩|σ⟩|c⟩

Next, we uses each qubit to conditionally sum the element to . If there exist a solution to the PP then, in the final superposition of , the amplitude of the state will be not . The states for which is zero wil be referred as the solutions states of the PP. The control qubit will be set to zero exactly for those states for which . At this point we apply an uncomputational step in order to set . Now if we apply the gate to the first qubits we obtain, by Lemma 1

 |φ2⟩ =(S⊗n⊗Im+1)|φ1⟩=1√2n2n−1∑x=0iw(x)|x⟩|σ⟩|c⟩

After this we apply again the Hadamard gate to the first qubits. This operation is controlled by the control qubit in a way that the Hadamard port is applied only to non solution states. For the sake of simplicity we suppose in the following, that the PP has only two solution whose numeric representation are and its bitwise complement . By equation (4), we obtain

 |φ2⟩ contr H⊗n−−−−−−−→|φ3⟩=1√2n∑z∈{y,¯y}iw(z)|z⟩|σ⟩|0⟩+ + 12n2n−1∑z=0∑x∉{y,¯y}iw(x)(−1)x⋅z|z⟩|σ⟩|1⟩= = 12n⎡⎣√2n∑z∈{y,¯y}iw(z)|z⟩|σ⟩|0⟩+2n−1∑z=0∑x∉{y,¯y}iw(x)(−1)x⋅z|z⟩|σ⟩|1⟩⎤⎦ (19)

Now we want to quantify the amplitude of the state and of equation (19). We consider only the state since the same arguments can be applied to state . The amplitude fr the state (in the following we disregard the normalization factor ) is given by the following formula

 by=∑x∉{y,¯y}iw(x)(−1)x⋅y (20)

We may write the above sum as

 by=∑x∉{y,¯y}iw(x)(−1)x⋅y=2n∑x=0iw(x)(−1)x⋅y−∑x∈{y,¯y}iw(x)(−1)x⋅y (21)

We have that

 ∑x∈{y,¯y}iw(x)(−1)x⋅y =iw(y)(−1)y⋅y+in−w(y)(−1)¯y⋅y= = iw(y)(−1)w(y)+in−w(y)= (22)

Then, recalling that when is even and when is odd, we have two cases: is even and then

 iw(y)(−1)w(y) +in−w(y)=iw(y)(−1)w(y)+in+w(y)= =iw(y)(1+in) (23)

while if is odd

 iw(y)(−1)w(y) +in−w(y)=iw(y)(−1)w(y)−in+w(y)= =−iw(y)(1+in) (24)

For simplicity of notation in the following we denote as simply . We have that if is even then, by Theorem 3, is

 by=⎧⎪ ⎪⎨⎪ ⎪⎩(−1)¯¯¯wim+¯¯¯w2m−i¯¯¯w(1+i2m) if ¯¯¯¯w is % even(−1)¯¯¯wim+¯¯¯w2m+i¯¯¯w(1+i2m)% if ¯¯¯¯w is odd (25)

while if is odd, by Theorem 4, is

 by=⎧⎪ ⎪⎨⎪ ⎪⎩(−1)¯¯¯wim+¯¯¯w2m(1+i)−i¯¯¯w(1+i2m+1) if ¯¯¯¯w % is even(−1)¯¯¯wim+¯¯¯w2m(1+i)+i¯¯¯w(1+i2m+1) if ¯¯¯¯w is odd (26)

It is immediate to check that in the above equations (25) and (26) the term become trascurable, with respect to the other term in the equation, as become bigger. We conclude that the amplitude of the state is almost the same of the amplitude of state , thus effectively duplicating the chances of state at the end of the circuit. For example if and we have that

, so that the probability of getting

is, by (19), which is exactly the output of the quirk simulator.