You are on page 1of 11

# Ph219a/CS219a

Solutions Nov 8, 2013

Problem 3.1
(a) Constructing the unitary transformation U1 as given in the circuit, we have U1 = (H ⊗ I)Λ(P)(H ⊗ I). In the standard basis, H and P are given by 1 H= √ 2 1 1 1 −1 P = 1 1 0 i (1)

so that H ⊗ I and Λ(P) have the block diagonal form: 1 H⊗I= √ 2 I I I −I Λ(P) = I ∅ ∅ P (2)

where ∅ is the 2 × 2 zero matrix and I is the 2 × 2 identity matrix. Thus,   2 0 0 0 1 0 1+i 0 1−i  1 I+P I−P  =  U1 = 0 2 0  I−P I+P 2 2 0 0 1−i 0 1+i

(3)

Similarly, U2 is given by U2 = (I ⊗ H)Λ(P)(I ⊗ H) = (SWAP)U1 (SWAP), since Λ(P) acts symmetrically on the input qubits. Interchanging the second and third rows and columns of U1 , we have,   2 0 0 0 1 0 2 0 0   U2 =  (4)  0 0 1 + i 1 − i  2 0 0 1−i 1+i It is easy to see that U1 and U2 act trivially on the states |u1 = |00 and |u2 = |10 + |11 ) U1 |00 U2 |00 = = |00 |00 1 U1 √ (|01 + |10 + |11 ) = 2 1 U2 √ (|01 + |10 + |11 ) = 2 1 √ (|01 + |10 + |11 ) 2 1 √ (|01 + |10 + |11 ) 2
1 √ (|01 2

+

(5)

1

Similarly. when restricted to the two dimensional subspace spanned by |u3 and |u4 . √ (7) (U1 )new = √ 3+i 4 3(−1+i) 4 3(−1+i) 4 1+3i 4 (U2 )new = 3+i √ 4 3(1−i) 4 √ 3(1−i) 4 1+3i 4 (8) (c) Working in the basis consisting of identity and the Pauli matrices. we get. so that.1 1 (|10 − |01 ) and |u4 = √ (|01 + |10 − 2 |11 ). 0.σ 2 2 i −i (√ ) 2 2 (9) i (10) √ i/2(− 3i/2). 0. The unitary matrix that transforms from the computational basis to the {|ui } basis is   1 0 0 0 1 1 1  0 √  √ √  3 3 3  V= (6) 1 1 0   0 √2 − √2  1 2 1 √ 0 √ −√ 6 6 6 To express U1 and U2 in the new basis. suppose U1 = α1 I + β1 X + γ1 Y + δ1 Z. U2 = √ where n ˆ2 = ( 3/2. 1/2)T . √ with n ˆ1 = (− 3/2. together with |u1 (b) Notice that |u3 = √ 2 6 and |u2 .σ 2 2 i/2. solving for the expansion coeﬃcients of U2 . we simply need to conjugate with V   1 0 0 0  0 1  0 0   √ (U1 )new = VU1 V† =   3( − 1+ i ) i  0 0 √ 3+  4 4 3(−1+i) 1+3i 0 0 4 4   1 0 0 0  0 1  0 0   √ (U2 )new = VU2 V† =  3(1−i)  3+i  0 0 √ 4  4 3(1−i) 1+3i 0 0 4 4 Thus. 1/2)T . U1 = = 2δ1 = √ 1−i ⇒ δ1 = 2 1 1 √ − i√ n ˆ1 . α2 = √ γ2 = 0 and δ2 = i/2(−i/ 2). 2 √ i 1 1 √ − i√ n ˆ2 . form an orthonormal basis for the 2-qubit space. β2 = (11) . Equation(7) gives: 1+i i 2α1 = 1 + i ⇒ α1 = = 2 2 √ √ 3(−1 + i) i 3i ⇒ β1 = ( ) Tr(U1 X) = 2β1 = 2 2 2 Tr(U1 Y) = 2γ1 = 0 ⇒ γ1 = 0 Tr(U1 I) = Tr(U1 Z) Thus.

n ˆ2 = −1/2 and √ n ˆ1 × n ˆ2 = (0.σ )(n ˆ2 . Dividing A(x) by the rational polynomial P (x). R(x) must vanish for all values of x.σ + (n ˆ1 . so that.σ )(n ˆ2 . al bm xl+m l. (c) Let A(x) = l al xl and B (x) = C ( x) = k m bm x m .n ˆ2 + iσ (n ˆ1 × n ˆ2 ).σ (13) 4 4 √ √ ˆ = (−2/ 5. given that A(x) and B (x) are integral.σ 2 2 2 2 1 i 1 − (n ˆ1 − n ˆ2 ). Substituting the value x = a. R(x) = 0. This leads to a contradiction since P (x) is given to be the minimal degree rational polynomial with root a. implying that R(a) = 0.σ ) = n ˆ1 . cr+s = ar bs + l=r. Since A(x) and B (x) are primitive. √ 1 15 ˆ −1 U2 U1 = I − i k. From equation(15).σ ˆ2 . we have. axis k 2 4 Problem 3. Thus we see that the operation U−1 U1 is a rotation about the with k 2 ˆ. ie. 0)T . 1/ 5. we have. Therefore the θ minimal degree monic rational polynomial that has ei 2 as a root must be of atleast degree 2. say there exists a prime p that divides all of the coeﬃcients ck . Let ar be the lowest-order coeﬃcient of A(x) that is not divisible by p and let bs be the lowest-order coeﬃcient of B (x) that is not divisible by p. p does not divide all the al ’s or bm ’s. ∀x. and computing n ˆ1 .m=s:l+m=r +s al bm (17) 3 .σ ) 2 2 2 −i2 (12) Now using the identity (n ˆ1 . we see that A(a) = 0 and P (a) = 0. 1 U− 2 U1 = = 1 i 1 i √ I+ √ n √ I− √ n ˆ1 . Since complex roots of rational polynomials must occur in pairs.2 (a) A monic rational polynomial of degree 1 has exactly one rational root. 0)T . ie.m ck xk = A(x)B (x) = (16) Clearly. Lets assume C (x) is not primitive. Therefore. by an angle θ such that cos( θ ) = 1 . we obtain rational polynomials Q(x) and R(x) such that A(x) = P (x)Q(x) + R(x) (15) where R(x) has degree less than that of P (x). Consider the (r + s)th order coeﬃcient of C (x). so that A(x) = xn − 1 = P (x)Q(x).(d) Using the results of part(c). 3/2. we can construct the monic rational polynomial of degree 2 as follows θ θ θ 1 P (x) = (x − ei 2 )(x − e−i 2 ) = x2 − 2 cos( )x + 1 = x2 − x + 1 2 2 (14) (b) Let A(x) = xn − 1. so is C (x).

thus leading to a contradiction. since xn − 1 is integral. Now. and so are all the terms in the summation on the RHS . either l < r so that al is divisible by p or m < s and bm is divisible by p. QED! Problem 3. Since P (x) part(c). the highest order coeﬃcient of k A(x) is k . Using the result of Given P (x) = A(x)B (x) = rs A( ˜ ˜ ˜x) and B ( ˜x) are primitive integral. This contradicts our initial assumption that r is the smallest integer such that rA(x) ˜x) = rA(x) must be primitive. r = s = 1. an = 1. Then there exists an integer k > 1 such that k A(x) is integral or equivalently. Then part(b) implies that there exists a monic rational polynomial Q(x) such that xn − 1 = P (x)Q(x). cr+s is divisible by p. By a similar argument. using part(d). (e) Let a be a root of unity. By reductio ad absurdum. one of ar or bs is divisible by p. A(x)B (x) is primitive integral. ie. and since k A(x) is r integral. HXH HYH HZH PXP−1 PYP−1 PYP−1 = = = = = = 1 2 1 2 1 2 1 0 1 0 1 0 1 1 1 1 1 1 0 i 0 i 0 i 1 −1 1 −1 1 −1 0 1 0 −i 1 0 0 1 0 −i 1 0 1 0 i 0 0 −1 1 0 i 0 0 −1 1 0 1 0 1 0 1 2 1 2 1 2 0 −i 0 −i 0 −i 1 1 1 1 1 1 1 −1 1 −1 1 −1 = = = 0 −i 0 1 1 0 = = = i 0 1 0 0 −1 1 0 0 −1 0 −i 0 1 i 0 1 0 =Y =X =Z (18) =Z = −Y =X (b) The action of K on the standard basis is given by 1 K = HP−1 HPH = √ 2 4 0 1−i 1+i 0 (19) . P (x) must be integral too. rs = 1 or equivalently.By our assumption. Since A(x) is monic. since A(x)B (x) is primitive. 1 ˜x)B ( ˜x) is a monic integral polynomial. is integral. C (x) must be primitive. r is the ˜x) where A( ˜x) is integral. for some integer n and P (x) be the minimal degree monic rational polynomial that has a as a root. A( ˜ ˜ we can ﬁnd an integer s such that B (x) = 1 s B (x) where B (x) is primitive integral. ie. This implies that ar bs is divisible by p. Therefore. suppose A( ˜x) is not smallest integer such that rA(x) = A( 1 ˜ r primitive. Finally. either rs must divide all the coeﬃcients of A( ˜ ˜ is not possible. (d) Let r be the lowest common denominator of the coeﬃcients of A(x). k A(x) r r r is integral. Thus we have found an integer k = l < r such that A ˜ (x) = lA(x) is integral.3 (a) Representing all gates in the standard basis. Therefore. By reductio ad absurdum. since A( ˜x)B ( ˜x) or rs = 1. k must divide r. The ﬁrst alternative is integral.for every term.

we can trivially construct Λ(P) ⊗ I using Λ2 (X). I. by simple matrix multiplication we can prove the following identities KXK KYK = = 1 √ 2 1 √ 2 1 √ 2 0 1−i 1+i 0 0 1−i 1+i 0 0 1−i 1+i 0 0 1 0 i 1 0 1 0 1 0 1−i 0 −i √ = =Y 1+i 0 i 0 2 1 0 1−i −i 0 1 √ = =X 1+i 0 0 1 0 2 1 0 0 1−i −1 0 √ = = −Z −1 1+i 0 0 1 2 KZK = (c) To construct Λ2 (Y) using the gate set {H. 0. iI) diag(I. Λ2 (X)}. 0. 1. XYZ) Λ2 (XYZ) = Λ2 (X)Λ2 (Y)Λ2 (Z) (21) . 1 → (diag(1. 1. i). y ) ⊗ |0 + (diag(1. 0. Λ(P)R . 1.Once again. so that Λ2 (Y) = |00 00| ⊗ I + |01 01| ⊗ I + |10 10| ⊗ I + |11 11| ⊗ Y = = = (|00 00| + |01 01| + |10 10|) ⊗ PP−1 + |11 11| ⊗ PXP−1 (I ⊗ P) [(|00 00| + |01 01| + |10 10|) ⊗ I + |11 11| ⊗ X] (I ⊗ P−1 ) (I ⊗ P)Λ2 (X)(I ⊗ P3 ) (20) Similarly. y. to construct Λ2 (Z) we use the identity HXH = Z so that Λ2 (Z) = (I ⊗ H)Λ2 (X)(I ⊗ H). Schematically. 1. (d) Recall that Λ(P) = diag(1. (a) Λ(Y) (b) Λ(Z) Finally. we use the identity PXP−1 = PXP3 = Y (proved above). 0) |x. Λ2 (Y) and Λ2 (Z). I. 0 |x. 0) |x. since Λ(P) ⊗ I = = = where we have used XYZ = iZ2 = iI. 1) |x. 0. acts as follows: Λ(P)R : |x. I. P. I. The real orthogonal matrix corresponding to this. y ) ⊗ |1 → (−diag(0. 1. 1) |x. y. 1. y ) ⊗ |0 + (diag(0. y ) ⊗ |1 5 (22) diag(I.

we can construct Λ2 (Z) using the Toﬀoli gate and the Hadamard gate: Λ2 (Z) = (I⊗H)Λ2 (X)(I⊗H). This corresponds to doing an XZ gate on the third qubit (conditioned on the ﬁrst two qubits being in the |11 state). since XZ = 0 1 1 0 1 0 0 −1 = 0 1 −1 0 (23) Hence Λ(P)R is simply a controlled-controlled-XZ gate.Thus Λ(P)R acts trivially on all inputs except those with x = y = 1. it leaves the ﬁrst two qubits unchanged and acts on the third qubit as follows: |0 → |1 and |1 → − |0 . Λ2 (XZ) = Λ2 (X)Λ2 (Z) = Λ2 (X)(I⊗H)Λ2 (X)(I⊗H). Λ(P)R = Λ2 (XZ). Schematically.   1 0 0 0  0 −1 2 0   X⊗X+Y⊗Y+Z⊗Z=  0 2 −1 0  = 2(SWAP) − I4 0 0 0 1 6 (26) . ie. Therefore. we see that. (e) First we note that Λ2 (XZ) = Λ2 (X)Λ2 (Z) Λ 2 (X) Λ (Z) ⇒ Λ2 (X)Λ2 (Z) 2 = = = = (|00 00| + |01 01| + |10 10|) ⊗ I + |11 11| ⊗ X (|00 00| + |01 01| + |10 10|) ⊗ I + |11 11| ⊗ Z (|00 00| + |01 01| + |10 10|) ⊗ I + |11 11| ⊗ XZ Λ2 (XZ) (24) Then. as shown in part(c).4 (a) Recall that the action of the SWAP gate on  1  0 SWAP =   0 0 the computational basis is given by  0 0 0 0 1 0   1 0 0  0 0 1 (25) Writing out X ⊗ X + Y ⊗ Y + Z ⊗ Z in the computational basis. Problem 3. In this case.

−i. (c) Given any operator A and a unitary U. 0.where I4 is the 4 × 4 identity matrix. π π exp[ i Z ⊗ Z] 4 π ei 4 diag(1. −i. 0. 4 . θy . upto an overall phase. 0. 0. θy . θz ) = = = exp[ i(I ⊗ X)(θx X ⊗ X + θy Y ⊗ Y + θz Z ⊗ Z)(I ⊗ X) ]V exp[ i(θx X ⊗ X + θy Y ⊗ XYX + θz Z ⊗ XZX) ]V exp[ i(θx X ⊗ X − θy Y ⊗ Y − θz Z ⊗ Z) ]V(θx . we have. 0. so that π π Λ(X) = e−i 4 (I ⊗ H)(P ⊗ P)V(0. θy . we simply conjugate with the Hadamard gate. θz ) (I ⊗ Z)V(θx . θy . )(I ⊗ H) (30) 4 showing that V(0. 0) Similarly. θz )(I ⊗ Z)V(θx . θy . . π ) 4 = = = Then. −θy . 0. we can use this identity to get. (I ⊗ X)V(θx . 0) = V(0. θz ) = V(2θx . θy . we can show. (I ⊗ Y)V(θx . π π Thus. π 4 ) in the computational basis. we have used the identity eiθA = (cos θ)I + i(sin θ)A for any real θ and any A such that (A)2 = I. e−i 4 (P ⊗ P)V(0. 2θz ) (33) . 1) ei 4 (|0 0| ⊗ P−1 − i |1 1| ⊗ P) π (28) π ) 4 = |0 0| ⊗ I + |1 1| ⊗ P2 = Λ(Z) (29) since P2 = Z. V(0. θz )(I ⊗ Y)V(θx . π π π π V( . Now to get the CNOT operation. π 4 ) is indeed locally equivalent to Λ(X). ) = exp[ i (X ⊗ X + Y ⊗ Y + Z ⊗ Z) ] 4 4 4 4 π = exp[ i (2SWAP − I4 ) ] 4 π −i π 4 exp[ i SWAP] = e 2 π π −i π = e 4 [ (cos )I + i(sin )SWAP ] 2 2 π = ei 4 SWAP (27) In the penultimate step. Therefore. 2θy . −θz )V(θx . (b) Writing down V(0. θz ) 7 = V(0. UeiA U† = eU(iA)U † (31) Since the Pauli operators are unitary. θz ) (32) = V(θx . θy . θy . V( π 4 . 4 ) is simply the SWAP operation. θz )(I ⊗ X)V(θx . 0.

4θ) = e−2iθZ is a rotation about the z ˆ axis. θz ) can be used. 4 θ ) U† ˆ R(ˆ n ˆ = = = Un ˆ e−2iθ 0 0 e2iθ U† n ˆ (37) e−2iθ |n ˆ. 4θ)] where R(ˆ z . equation(34) implies [I ⊗ Θ]V(0. + n ˆ . we have. 4θ)] ˆ )(I ⊗ Θ)V(0. conjugating both sides of equation(36) with I ⊗ Un ˆ .(d) Once again.σ . we need to conjugate by a unitary that rotates between the eigenvectors of z ˆ. a controlled rotation by 2θz about the z-axis. working in the computational basis. 4θ) ⇒ (I ⊗ Θ)V(0.σ (= Z) and n ˆ . θ) is indeed locally equivalent to a controlled rotation about an arbitrary axis on the Bloch sphere. let us consider the following two cases: (i) π/4 is an integral multiple of 2|θz | :In this case. 0. the required unitary operation is Un ˆ . (e) We know from parts (c) and (d) that any 2-qubit. θ) = = Let Θ= Then. entangling gate of the form V(θx . 0. this is locally equivalent to Λ[R(ˆ z . θy . to prove the Lemma. ) 2 ≡ Λ(X) (from part(b)) 8 (40) . Further. + 0| + |n ˆ .σ . e−iθ . 0. If |n ˆ . θ) = Λ[R(ˆ z . This shows an equivalence between V(0. θ )(I ⊗ Un ˆ ) = Λ[R(ˆ (39) showing that V(0. −| R(ˆ n. θy . 0. † (I ⊗ Un n. 4qθz )] π = Λ[R(ˆ z . θ) = |0 0| ⊗ I + |1 1| ⊗ e−2iθ 0 0 e2iθ (36) exp[iθZ ⊗ Z] = diag(eiθ . 0. θz ) ≡ Λ[R(ˆ z . +| + e2iθ |n ˆ. 0. e−iθ . 4θz )] = Λ[R(ˆ z . 4θz )] → (q times) Λq [R(ˆ z . V(0. Now. − denote the eigenvectors of n ˆ . 4θ)] ie. 2θz ). π/2)] ≡ V(0. eiθ ) eiθ 0 e−iθ |0 0| ⊗ + |1 1| ⊗ 0 e−iθ 0 e−iθ 0 0 eiθ 0 eiθ (34) (35) = |0 0| ⊗ I + |1 1| ⊗ R(ˆ z . − 1| ˆ = |n so that Un z . 2q |θz | = π/4 for some positive integer q . 4θ) (38) Thus. 4θz )]. Now to get a controlled rotation about an arbitrary axis n ˆ . 0. and the Lemma is proved trivially V(θx . in combination with single qubit unitaries to realize a gate of the form V(0. a controlled rotation by 4θ about the z ˆ axis. θ) and Λ[R(ˆ z . + and |n ˆ . − n ˆ . 0.

and θ . Thus. 2θz ]. the product Λ[R(ˆ z . we need to implement the local unitary U† m ˆ . we need to implement Λ[R(ˆ z . π Λ[R(ˆ z . θy . 4qθz )]Λ[R(ˆ z. θz )] for an appropriate choice of n ˆ . (ii) π/4 is not an integral multiple of 2|θz | :In this case. b] → R is continuous and that u is a real number satisfying f (a) < u < f (b) or f (a) > u > f (b). θz ) (provided θx = θy = θz ) = {0.] denotes the greatest integer function. n n. α varies continuously as a function of n ˆ . to realize Λ(X). which was deﬁned in equation(37) above. a controlled rotation by 0 < |α| = π/4 − 2q |θz | < 2|θz | about the z-axis. To construct such a gate. it takes all possible values in the interval [0. θz )] is a controlled rotation Λ[R(m. V(θx . to rotate the axis of rotation from m ˆ to the z-axis. θz )]Λ[R(ˆ n. To summarize. θz )](I m ˆ )Λ[R(ˆ ⊗ Um ˆ) = = Putting together cases (i) and (ii). by the Intermediate Value 1 Theorem . 4θz )](I ⊗ U† z . θz )] for some arbitrary axis n ˆ (as described in part(d)). we see that Λ(X) ≡ Λ[R(ˆ z. ˆ α)]. α)]. Then for some c ∈ [a. θ)] ˆ and Λ[R(n . α = π/4 − 2q |θz |. It is therefore possible to choose n ˆ such that we get the desired angle of rotation. θz )] (I ⊗ U† ˆ α)](I ⊗ Um ˆ) m ˆ )Λ[R(m. Let q = [ π/8|θz | ]. b]. thus proving the Lemma! Problem3 3.n ˆ sin(θz ) cos(θz )(ˆ z+n ˆ ) − sin2 (θz )(ˆ n⊗z ˆ) (41) For a given θz . θz )]Λ[R(ˆ n. Finally. if we construct the gate Λ[R(ˆ on n ˆ. θ. 4θz )]Λ[R(ˆ z . ie. θz )]Λ[R(ˆ n. (43) ≡ Λq [R(ˆ z . ﬁrst note that the product of two controlled rotations Λ[R(ˆ n.where ≡ implies that two gates are locally equivalent. θ )] is also a controlled rotation whose axis of rotation and magnitude depends ˆ . π 4 }). θz )] ≡ Λ[R(ˆ n.5 a) A problem of size n is in BQP if there exists a polynomial-size uniform circuit family that depends on n. θz )]Λ[R(ˆ n. where for each such circuit the state for the ﬁrst output qubit is |0 (resp. Then. θy . where [. θz )](I ⊗ Um ˆ) m ˆ )Λ[R(ˆ Λ[R(ˆ z . |1 ) 1 Suppose that f : [a. obtained by solving equations(41). = = π )] 2 Λ[R(ˆ z . whose axis of rotation m ˆ and angle of rotation α are given by cos(α) sin(α)m ˆ = = cos2 (θz ) − sin2 (θz )ˆ z . − 2q |θz |)] 4 (42) π − 2q |θz |)] 4 Λq [R(ˆ z . Then. we need to use another gate to make up for the diﬀerence. θz ) ≡ (I ⊗ U† z . The gates in the ﬁnal step are all locally equivalent to a generic 2-qubit gate of the form V(θx . f (c) = u 9 .

. our classical simulation will need to compute the matrix element 0|VL .. We can now view V = U † (P0 ⊗ In−1 )U as a new matrix. l=0 m=0 The result now follows. 1). and let us denote by h the number of Hadamard gates it contains. so that the classical simulation of the quantum computation executed by U reduces to the calculation of the matrix element 0|V |0 . k ⊕ ij . (46) Similarly. √ We now note that 2H acts in the computation basis as √ 1 (44) 2 H : |i → j =0 (−1)ij |j . Then. j. for the Toﬀoli gate Λ(X ) : |i. For every Toﬀoli gate in this expression. j. For every Hadamard gate initially in V .with probability at least 2/3 if the correct answer is 0 (resp. or a Toﬀoli gate (Λ(X )). (47) which. . we can use Eq.e. The initial state is a state in the computation basis (i. . 1 l=0 1 (48) (−1)(k⊕ij ⊕m)l |i. V2 V1 |0 . computation in which no “junk” bits are produced and which can be performed with zero thermodynamic cost) is possible. where In−1 is the identity operator acting on all qubits except for the ﬁrst. Recall that. k → (−1)(k⊕ij )l |i. we can insert the identity in the form I = H 2 following it on its target qubit. l . This is reminiscent of the idea used by Bennett to show that reversible classical computation (i. or a projection P0 tensored with the identity on all qubits on which it acts trivially. Let P0 be the projector onto the state (|0 0|)1 on the ﬁrst qubit. If U is the unitary implemented by the quantum circuit. of size S ≤ 2L. (45) 2h √ where for every Hadamard gate in V we have collected the 1/ 2 normalization in front of the √ expression and replaced the corresponding gate Va = H by the gate Va = 2H . m . Therefore. the output state is therefore U |0 . This way we obtain a new V . becomes 1 (I ⊗ I ⊗ H )Λ(X ) (I ⊗ I ⊗ H 2 )Λ(X ) : |i. . . the input qubits to each circuit are prepared in the standard state |0 ⊗n which we will denote as |0 for simplicity.e. the probability of obtaining the outcome 0 after measuring the ﬁrst output qubit is P (0) = 0|U † (P0 ⊗ In−1 )U |0 . k → : |i. j. all qubits in the state |0 ). We note that V consists ﬁrst of the unitary U . j. j. (46) to generate a new 10 . then of the projector onto the |0 state on the ﬁrst qubit. V2 V1 where each Vi is either a Hadamard gate (H ). according to our model. . say V . . b) We can write V = VL . when combined with the two Hadamard gates following it by the construction of V . j. Then we need to compute 1 P (0) = √ 0|VS . and ﬁnally of the inverse of the quantum circuit U −1 . k → |i. V2 V1 |0 .

2h (50) 11 . (45) to the calculation of a sum over h ≤ 2L intermediate binary indices of the form 1 P (0) = √ (−1)φ(x) . (49) 2h x where x is a binary vector with the h intermediate indices as components and φ(x) is a polynomial of degree at most three in the intermediate indices.index and express the output state in the computation basis. N1 ) is the number of values of x for which φ(x) = 0 (resp. Thus we have reduced the calculation of P (0) in Eq. (48) to generate two new indices. φ(x) = 1). At the end of the computation we “project” onto the |0 state. If N0 (resp. it follows that 1 P (0) = √ (N0 − N1 ) . For every Λ(X ) gate initially in V . we can group it with the two Hadamard gates we inserted to obtains V and use Eq. so that all free indices at that point are forced to take the value 0.