0% found this document useful (0 votes)
15 views

QFT FFT

Uploaded by

jbustamante
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

QFT FFT

Uploaded by

jbustamante
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

The Quantum Fourier Transform and a Comparison with the Fast Fourier

Transform

Peter Young
(Dated: November 2, 2019)

I. INTRODUCTION

This handout introduces the quantum Fourier transform (QFT), which is at the heart of Shor’s
algorithm for period finding, and hence for factoring. The appendices make a detailed comparison
with the (classical) Fast Fourier Transform(FFT). The FFT is not part of the course so if you are
not interested in this comparison you can ignore the appendices.

II. QUANTUM FOURIER TRANSFORM (QFT) FOR N = 4

In this section we describe a simple example, that of N = 4 states, i.e. n = 2 qubits.


Firstly, a reminder about notation. A state of n qubits is labeled either by a single n-bit integer,
x say, or by the values of the individual qubits xi , which form the binary representation of x. As
an example, the four computational basis states for two qubits are

|0i2 ≡ |00i ,

|1i2 ≡ |01i ,

|2i2 ≡ |10i ,

|3i2 ≡ |11i , (1)

To prevent any ambiguity, we will, when necessary, indicate the number of qubits in a state by a
subscript, e.g. |xin has n qubits so x will be an n-bit integer, whose bits indicate the state of the
individual qubits.
We now describe the Quantum Fourier Transform (QFT) for n = 2 qubits.
In the Quantum Fourier Transform (QFT) one starts from an initial state |xi2 ≡ |x1 x0 i in the
computational basis and generates the following superposition
3
1X
exp 2πixy/22 |yi2 ,
 
|ψx i2 = (2)
2
y=0

where |yi2 ≡ |y1 y0 i. Note this has the same structure as a standard Fourier Transform, but here we
are performing a change of basis of a quantum system, rather than transforming a set of data. The
2

|ψx i2 form a basis just as the |xi2 form a basis because one can show that they are orthonormal,
i.e.

2 hψx1 |ψx2 i2 = δx1 ,x2 . (3)

Noting that y = y0 + 2y1 and x = x0 + 2x1 we can simplify the argument of the exponential:

2πixy 2πi(x0 + 2x1 )(y0 + 2y1 ) n x


0 x1  x
0
o
= = 2πi y 0 + + y 1 + x 1 . (4)
22 22 4 2 2

Now exp(2πiy1 x1 ) = 1 so the factor y1 x1 above can be neglected. Hence Eq. (2) becomes
  
1 1
1 X h x
0 x 1
i 1 X h x i
0 
|ψx i2 =  √ exp 2πiy0 +  √ exp 2πiy1 |y1 y0 i. (5)
2 y0 =0 4 2 2 y1 =0 2

Next we will explain how to perform the operations in Eq. (5) using quantum gates.
Consider the second factor on the RHS of Eq. (5), which involves a sum over y1 . The exponential
is 1 for y1 = 0 and is −1 for y1 = 1 provided x0 = 1. This functionality is provided by a Hadamard
gate H,
 
1 1 1
H=√   (6)
2 1 −1

so

1
H|0i = √ (|0i + |1i) ,
2
1
H|1i = √ (|0i − |1i) , (7)
2
Recall that in terms of components
   
1 0
|0i ≡   , |1i ≡   . (8)
0, 1

More compactly, we can write


1 1
1 1 X 1 X
H|x0 i = √ (|0i + (−1)x0 |1i) = √ (−1)x0 y1 |y1 i = √ exp[2πiy1 x0 /2]|y1 i , (9)
2 2 y1 =0 2 y1 =0

where we denote by y1 the dummy variable to be summed over (coming from the effects of the
Hadamard) in order to correspond with the second factor on the RHS of Eq. (5). We therefore see
that the second factor on the RHS of Eq. (5) is generated by the Hadamard gate shown in Fig. 1.
What about the first factor on the RHS of Eq. (5) which involves y0 ? There are two pieces in
the exponential. The one involving 2πiy0 x1 /2 can be dealt with by a Hadamard, similar to Fig. 1
3

y1
x0 H ψ
0

FIG. 1: The output from the Hadamard gate is |ψ0 i = √12 (|y1= 0i + (−1)x0 |y1= 1i). This can be expressed
P1 P1
as √12 y1 =0 (−1)x0 y1 |y1 i = √12 y1 =0 exp[2πiy1 x0 /2]|y1 i. Recall that x0 takes a fixed value 0 or 1.

but with the left hand qubit being x1 and the right hand qubit being labeled by y0 . However, the
piece involving 2πiy0 x0 /4 is different. It induces a phase shift of eiπ/2 for y0 = 1 provided that x0
is also 1. This requires a controlled phase gate. We define a phase gate Rd by1
 
1 0
Rd =  d
. (10)
0 eπi/2

Acting on |0i, Rd makes no change while acting on |1i, Rd changes the phase by π/2d . Note that
R0 is just the Z gate. Here we need R1 .
The exponential in the first term on the RHS of Eq. (5) can be generated by a Hadamard
followed by a controlled R1 gate as shown for the top qubit in Fig. 2. Note that the R1 phase gate
on the upper qubit is controlled by the lower qubit. Including the Hadamard on the lower qubit,
Fig. 2 generates both factors on the RHS of Eq. (5).
To make sure we understand we understand what is happening in the circuit in Fig. 2 we now
write down the state at each of the steps shown in the figure. After the first Hadamard the state
is
1
1 X 2πiy0 x0 /2
|φ1 i2 = √ e |y0 x0 i, (11a)
2 y0 =0

where we denote by y0 the dummy variable that is summed over in order to agree with Eq. (5).
After the controlled-R1 gate we have
1
1 X 2πiy0 x0 /2 2πiy0 x1 /4
|φ2 i2 = √ e e |y0 x0 i. (11b)
2 y0 =0

The final state after the Hadamard on the lower qubit is therefore
  
1 1
1 X 1 X
|ψx′ i2 =  √ e2πiy0 x0 /2 e2πiy0 x1 /4   √ e2πiy1 x0 /2  |y0 y1 i. (11c)
2 y0 =0 2 y1 =0

1
This is the definition of Rd given in Vathsan’s book, and I find it convenient. Some other authors adopt a slightly
d d
different definition with e2πi/2 instead of eπi/2 .
4

ϕ ϕ ψ’
1 2 2 2 x 2
y0
x1 H R1

y
1
x0 H

FIG. 2: The initial state on the left is the single quantum state |xi2 ≡ |x1 x0 i in the computational basis.
P3
The final state on the right is the superposition |ψx′ i2 = (1/2) y=0 exp(2πixy/22 )|y0 y1 i, which is almost
|ψx i2 , the QFT of |xi2 ≡ |x1 x0 i given in Eq. (5), except that the order of the bits in the final state is the
reverse of what it should be according to Eq. (5). This can be corrected by a swap gate as shown in Fig. 3.
Note the controlled-R1 phase gate. The general phase gate Rd is defined in Eq. (10).

ϕ ϕ ψ’ ψ
1 2 2 2 x 2 x 2
y0 y
1
x1 H R1 X

y y0
H 1 X
x0

FIG. 3: The same as Fig. 2 but with the addition of a swap gate on the right (the dashed line with crosses
P3
at the ends). The final state is now precisely |ψx i2 = (1/2) y=0 exp(2πixy/22 )|y1 y0 i, the QFT given in
Eq. (5).

|ψx′ i is almost the desired QFT in Eq. (5), except that the order of the qubits on in the final state
on the right has been reversed. This can be compensated for by adding a swap gate on the right
as shown in Fig. 3. Hence Fig. 3 displays the circuit to implement the QFT for 2 qubits written
out in Eq. (5).
We now make an extremely important point. We have shown the QFT for a fixed basis state
x (in the computational basis) inputted to the left of the circuit diagrams. However, since the
circuit is linear (because quantum mechanics is linear) the circuit will act in parallel on a linear
superposition of basis states. This is where the power of the QFT lies.
5

III. QFT WITH THREE OR MORE QUBITS

With three qubits the QFT, analogous to Eq. (5) is


7
1 X
|ψx i3 = √ exp[2πixy/23 ]|yi3 (12)
8 y=0
  
1 1
1 X h  x0 x1 x2   1
i X h  x0 x1  i
= √ exp 2πiy0 + + √ exp 2πiy1 +
2 y0 =0 8 4 2 2 y1 =0 4 2
  (13)
1
1 X h x0 i
×  √ exp 2πiy2 |y2 y1 y0 i.
2 y2 =0 2

ϕ1 ϕ2 ϕ3 ϕ4 ψx’ ψx
3 3 3 3 3 3

y0 y
2
x2 H R1 R2 X

y y
1 1
x1 H R1

y y0
H 2
x0 X

FIG. 4: Circuit diagram for performing the QFT with n = 3 qubits. It generates the transformation shown
in Eq. (13). The phase gates, Rd , are defined in Eq. (10). The dashed line with crosses at the ends indicates
a swap gate between qubits 0 and 2. This serves to reverse the order of the qubits.

Following along the lines in the previous section, the circuit diagram which will perform this
is shown in Fig. 4. To make sure we understand this circuit we will write down the state at each
stage indicated on the figure. (Although these expressions look rather complicated is useful to
make the effort to understand them. In particular, you will appreciate why the order of the qubits
6

is reversed in |ψx′ i3 .)
 
1
1 X h  x2 
i
|φ1 i3 =  √ exp 2πiy0 |y0 x1 x0 i, (14a)
2 y0 =0 2
 
1
1 X h  x0 x1 x2  i
|φ2 i3 =  √ exp 2πiy0 + + |y0 x1 x0 i, (14b)
2 y0 =0 8 4 2
  
1 1
1 X h  x0 x1 x2   1 i X h  x1 
i
|φ3 i3 =  √ exp 2πiy0 + + √ exp 2πiy1 |y0 y1 x0 i, (14c)
2 y0 =0 8 4 2 2 y1 =0 2

  
1 1
1 X h x
0 x 1 x 2
i 1 X h x
0 x 1
i
|φ4 i3 =  √ exp 2πiy0 + +  √ exp 2πiy1 + 
2 y0 =0 8 4 2 2 y1 =0 4 2 (14d)

|y0 y1 x0 i,

  
1 1
1 X h x
0 x 1 x 2
i 1 X h x
0 x 1
i
|ψx′ i3 =  √ exp 2πiy0 + +  √ exp 2πiy1 + 
2 y0 =0 8 4 2 2 y1 =0 4 2
  (14e)
1
1 X h x0 
i
× √ exp 2πiy2 |y0 y1 y2 i.
2 y2 =0 2

|ψx′ i is almost the desired QFT in Eq. (13), except that the order of the qubits on in the final
state on the right has been reversed. This can be compensated for by adding a swap gate between
qubits 1 and 3. Hence |ψx i in the figure is the desired QFT for 3 qubits given in Eq. (13).
Comparing with the case for two qubits shown in Fig. 3, and that for three qubits in Fig. 4, the
generalization to an arbitrary number of qubits, where
n
2 −1
1 X
|ψx in = √ exp[2πixy/2n ]|yin (15)
2n y=0

can be deduced and is shown in Fig. 5. Note that the controlled phase gate between qubits xi and
xj is R|i−j| , which makes the structure fairly simple.
For an n-qubit QFT one needs n Hadamard gates. The number of controlled phase gates is
1 + 2 + · · · + n − 1 = n(n − 1)/2. Also [n/2] swaps are required, where [k] denotes the largest integer
less than or equal to k. The circuit therefore provides an algorithm for performing the QFT in
O(n2 ) steps. By contrast the FFT requires O(n2n ) steps which is exponentially greater.
However, we cannot obtain the 2n Fourier amplitudes from the QFT since a measurement
will just give one of the basis states with a probability proportional to the square of the ab-
solute value of its Fourier amplitude. The QFT can, however, give useful information if the
7

x n−1 H R1 Rn−2 Rn−1 y0

x n−2 H R
n−3
Rn−2 y
1

x1 H R1 y
n−2

x0 H y
n−1

FIG. 5: Circuit diagram for performing the QFT with an arbitrary number of qubits. For clarity the final
swaps are not shown, so the input states on the left, xi , and the output states on the right, yi , are in opposite
order. Note that the controlled phase gate between qubits xi and xj is R|i−j| , which makes the structure
fairly simple.

P
input state is a linear combination x ax |xi where the ax are periodic in x with some pe-
riod r. As we shall see in the handout Shor’s Algorithm for Period Finding on a Quantum
Computer, https://young.physics.ucsc.edu/150/shor.pdf, the Fourier amplitudes are then
strongly peaked at multiples of 2n /r, so there is a high probability of getting a value for y at, or
close to, a multiple of 2n /r, from which it turns out that one can deduce r with high probability.
Hence the QFT is useful for period finding.
As we saw in the handout Using Period Finding to Factor an Integer, period finding can
be used to factor integers. If one could factor large integers, one would be able to decode
messages sent down the internet which have been encoded with the standard RSA encryption
method. We discussed RSA encryption in the handout RSA (Rivest-Shamir-Adleman) Encryp-
tion, https://young.physics.ucsc.edu/150/rsa.pdf.
8

Appendix A: Fast Fourier Transform (FFT) for N = 4

For comparison with the QFT we write out the Fast Fourier Transform (FFT) for N = 4. The
Fourier transform for this case is

1
y0 = 2 ( x0 + x1 + x2 + x3 ) , (A1a)

x0 + ix1 + i2 x2 + i3 x3 ,
1

y1 = 2 (A1b)

x0 + i2 x1 + x2 + i2 x3 ,
1

y2 = 2 (A1c)

x0 + i3 x1 + i2 x2 + ix3 ,
1

y3 = 2 (A1d)

where the xj are the original data, the yj are the Fourier transformed data, and we have used that

exp(2πi/4) = i . (A2)

To evaluate Eqs. (A1) efficiently, the FFT proceeds recursively. We firstly define Fourier trans-
forms of length 2:

u0 = √1 (x0
2
+ x2 ) = √1 (x0
2
+ i2k x2 ) (k = 0) , (A3a)

u1 = √1 (x1
2
+ x3 ) = √1 (x1
2
+ i2k x3 ) (k = 0) , (A3b)

u2 = √1 (x0
2
− x2 ) = √1 (x0
2
+ i2k x2 ) (k = 1) , (A3c)

u3 = √1 (x1
2
− x3 ) = √1 (x1
2
+ i2k x3 ) (k = 1) , (A3d)

(A3e)

Pairs of quantities in Eqs. (A3) are combined to form the Fourier Transform in Eqs. (A1):

y0 = √1 (u0
2
+ u1 ) = √1 (u0
2
+ ik u1 ) (k = 0) , (A4a)

y1 = √1 (u2
2
+ i u3 ) = √1 (u2
2
+ ik u3 ) (k = 1) , (A4b)

y2 = √1 (u0
2
− u1 ) = √1 (u0
2
+ ik u1 ) (k = 2) , (A4c)

y3 = √1 (u2
2
− iu3 ) = √1 (u2
2
+ ik u3 ) (k = 3) , (A4d)

(A4e)

Let’s check that this works by evaluating y1 . We have

y1 = √1 (u2 + i u3 ) , (A5a)
2

u0 + ix1 + i2 x2 + i3 x3 ,
1 1

= 2 ( x0 − x2 + i(x1 − x3 ) ) = 2 (A5b)

(A5c)
9

which agrees with Eq. (A1b).


It is instructive to write the linear transformations in Eqs. (A1), (A3), and (A4) in matrix form.
Equation (A1) is written in matrix formulation as

~y = U~x , (A6)

where
 
1 1 1 1
 

1 i i 2 i3 
1  
U=  . (A7)
21 i 2 1 i 2 

 
3
1 i i i2

Equation (A3) in matrix form is

~u = U1 ~x , (A8)

where
 
1 0 1 0
 
0 1 0 1
 
1 
U1 = √  . (A9)
2
1 0 i2 0 

 
0 1 0 i 2

Equation (A4) in matrix form is

~y = U2 ~u , (A10)

where
 
1 1 0 0
 
0 0 1 i
 
1 
U2 = √  . (A11)
2
1 i2 0 0 

 
0 0 1 i 3

With some matrix manipulations one can verify that

U = U2 U1 , (A12)

as required. (I used Mathematica.)


10

Appendix B: Comparison between FFT and the QFT for N = 4

The QFT is generated by the unitary matrix U in Eq. (A7). The classical FFT is written as
the product of two sparse matrices, U = U2 U1 , see Eq. (A12), where U1 is given in Eq. (A9) and
U2 is given in Eq. (A11). We will now see that there is a close connection between the FFT and
the QFT, in particular, that the transformations U1 and U2 correspond to different parts of the
diagram in Fig. 3.
The swap gate interchanges states |1i and |2i, see Eq. 1, so it has the matrix representation
 
1 0 0 0
 
0 0 1 0 
 
S=
 .
 (B1)
0 1 0 0 
 
0 0 0 1

The Hadamard gate acting on the lower qubit of Fig. 3 was shown in Eq. (9). Including now also
the (unchanged) upper qubit, the matrix representation of the transformation induced by this gate
is
 
1 1 0 0
 
1 1 −1 0 0 
 
Hl = √  . (B2)
2
0 0 1 1

 
0 0 1 −1

The Hadamard on the upper qubit has a similar representation, except that the two qubits have
been interchanged, i.e.
 
1 0 1 0
 
1 0 1 0 1
 
Hu = √  . (B3)
2
1

0 −1 0 
 
0 1 0 −1

The controlled R1 phase gate gives a multiplicative factor of i if y0 and x0 are both 1, i.e. state
|3i. Hence
 
1 0 0 0
 
0 1 0 0
 
R1 = 

.
 (B4)
0 0 1 0
 
0 0 0 i
11

y0 y
1
x1 H R1 X

ψ
2

y y0
1
x0 H X

U1 U2

FIG. 6: The same as Fig. 3 but also showing the correspondence with the breakup of the FFT into two
operations U = U2 U1 , see Eqs. (B6).

The total effect of the quantum circuit in Fig. 3, reading from left to right on the circuit, is
given by the matrix product SHl R1 Hu . Note that one reads from from right to left in a product of
operators because the operators act on the right. It can be confusing that the direction of time in
the circuit diagram is opposite to that in an expression of operators. Multiplying these out these
matrices using Mathematica one gets the expected result,

SHl R1 Hu = U , (B5)

where U is the Fourier transform, shown in Eq. (A7). Recall that S is the swap, Hl is the Hadamard
on the lower qubit, R1 is the controlled phase gate, and Hu is the Hadamard on the upper qubit.
Hence the gates in the quantum circuit in Fig. 3 do indeed affect a Fourier transform for 2 qubits.
In the FFT we decomposed U into a product of two sparse matrices, U = U2 U1 , see Eq. (A12).
We can also make a connection between the individual matrices U2 and U1 of the FFT and the
individual matrices S, Hl , Hu and R1 of the QFT. One finds

U 1 = Hu , (B6a)

U2 = SHl R1 . (B6b)

The first is obtained by inspection and the second I checked with Mathematica. Hence the first
operation U1 in the FFT for N = 4 corresponds, in the QFT, to the Hadamard on the upper qubit
in Fig. 3, while the second operation U2 in the FFT corresponds to the remaining operations in
the QFT: the controlled phase gate on the upper qubit, the Hadamard on the lower qubit, and the
swap. This breakup is shown in Fig. 6.
To conclude this section, we have seen that there is close connection between the breakup used
in the FFT and that used in the QFT. This should not be a surprise. In the FFT we iteratively
12

divide the FT into two FTs of half the length, while in the QFT we have a binary representation
of the states and treat each bit in turn, so clearly there is a connection. For N = 4, this connection
is expressed in Eqs. (B6).

Appendix C: Comparison of FFT and QFT for N = 8

In this appendix we show how the breakup of the FFT for N = 8 is related to the circuit for
the QFT. Our final result will be Fig. 7, which is the analog of Fig. 6 for N = 4.
As shown in the handout entitled The Fast Fourier Transform
https://young.physics.ucsc.edu/150/FFT.pdf the FFT for N = 8 can be written as

(8) (8) (8)


U (8) = U3 U2 U1 (C1)

where
 
1 1 1 1 11 1 1
ω ω2 ω3 ω4 ω5 ω6 ω7 
 
1
 
 
1 2 4 6 2
ω ω ω 1 ω ω ω  4 6
 
 
3 6 4 7 2 5
1
1  ω ω ω ω ω ω ω 
U (8) =√  , (C2)

8
1 ω4 1 ω4 1 ω4 1 ω4  
 
1
 ω5 ω2 ω7 ω4 ω ω6 ω3 
 
1 ω6 ω4 ω2 1 ω6 ω4 ω2 
 
 
1 ω7 ω6 ω5 ω4 ω3 ω2 ω

 
1 0 0 0 1 0 0 0
 
0 1 0 0 0 1 0 0
 
 
0 0 1 0 0 0 1 0
 
 
(8) 0
1  0 0 1 0 0 0 1
U1 =√  , (C3)

2
1 0 0 0 ω4 0 0 0 
 
0
 1 0 0 0 ω4 0 0 
 
0 0 1 0 0 0 ω4 0
 
 
0 0 0 1 0 0 0 ω4
13

 
1 0 1 0 0 0 0 0
 
0 1 0 1 0 0 0 0
 
 
0
 0 0 0 1 0 ω2 0 
 
2
(8) 0
1  0 0 0 0 1 0 ω 
U2 =√  , (C4)

2
1 0 ω4 0 0 0 0 0 
 
0
 1 0 ω4 0 0 0 0 
 
0 0 0 0 1 0 ω6 0
 
 
0 0 0 0 0 1 0 ω6

and
 
1 1 0 0 0 0 0 0
 
0 0 1 ω 0 0 0 0
 
 
0 2
0 0 0 1 ω 0 0
 
 
3
(8) 0
1  0 0 0 0 0 1 ω 
U3 =√  . (C5)

2
1
4
ω 0 0 0 0 0 0 
 
0 5
0 1 ω 0 0 0 0
 
 
6
0 0 0 0 1 ω 0 0
 
 
0 0 0 0 0 0 1 ω 7

One can verify by doing the matrix multiplication (using Mathematica helps) that Eq. (C1) is
satisfied.
One can see from Fig. 4 that the QFT can be written as2

(8) (8) (8) (8) (8)


U (8) = S02 Hl (8)
R1,m Hm R2,u R1,u Hu(8) , (C6)

2
Recall that we work from right to left in operator equations like Eq. (C6) but from left to right in circuit diagrams
such as Fig. 4.
14

in a fairly obvious notation, where


 
1 0 0 0 0 0 0 0
 
0 0 0 0 1 0 0 0
 
 
0 0 1 0 0 0 0 0
 
 
0 0 0 0 0 0 1 0
(8)
S02 = , (C7)
 
0 1 0 0 0 0 0 0
 
 
0 0 0 0 0 1 0 0
 
 
0 0 0 1 0 0 0 0
 
 
0 0 0 0 0 0 0 1

 
1 1 0 0 0 0 0 0
 
1 −1 0 0 0 0 0 0 
 
 
0 0 1 1 0 0 0 0
 
 
(8) 0
1  0 1 −1 0 0 0 0 
Hl =√  , (C8)

2
0 0 0 0 1 1 0 0 
 
0 0 0 0 1 −1 0 0 
 
 
0 0 0 0 0 0 1 1
 
 
0 0 0 0 0 0 1 −1

 
1 0 0 0 0 0 0 0
 
0 1 0 0 0 0 0 0
 
 
0 0 1 0 0 0 0 0
 
 
0 0 0 i 0 0 0 0
(8)
R1,m = , (C9)
 
0 1 0 0 1 0 0 0
 
 
0 0 0 0 0 1 0 0
 
 
0 0 0 0 0 0 1 0
 
 
0 0 0 0 0 0 0 i
15

 
1 0 1 0 0 0 0 0
 
0 1 0 1 0 0 0 0
 
 
1 0 −1 0 0 0 0 0
 
 
(8) 0
1  1 0 −1 0 0 0 0
Hm =√  , (C10)

2
0 0 0 0 1 0 1 0
 
0 0 0 0 0 1 0 1
 
 
0 0 0 0 1 0 −1 0
 
 
0 0 0 0 0 1 0 −1

 
1 0 0 0 0 0 0 0
 
0 1 0 0 0 0 0 0
 
 
0 0 1 0 0 0 0 0
 
 
0 0 0 1 0 0 0 0
(8)
R2,u = , (C11)
 
0 1 0 0 1 0 0 0
 
 
0 0 0 0 0 ω 0 0
 
 
0 0 0 0 0 0 1 0
 
 
0 0 0 0 0 0 0 ω

 
1 0 0 0 0 0 0 0
 
0 1 0 0 0 0 0 0
 
 
0 0 1 0 0 0 0 0
 
 
0 0 0 1 0 0 0 0
(8)
R1,u = , (C12)
 
0 0 0 0 1 0 0 0
 
 
0 0 0 0 0 1 0 0
 
 
0 0 0 0 0 0 i 0
 
 
0 0 0 0 0 0 0 i
16

 
1 0 0 0 1 0 0 0
 
0 1 0 0 0 1 0 0
 
 
0 0 1 0 0 0 1 0
 
 
0
1  0 0 1 0 0 0 1
Hu(8) =√  , (C13)

2
1 0 0 0 −1 0 0 0
 
0 1 0 0 0 −1 0 0
 
 
0 0 1 0 1 0 −1 0
 
 
0 0 0 1 0 1 0 −1

One may verify Eq. (C6) using Mathematica. Note that S02 swaps qubits 0 and 2, as required to
reverse the order of the qubits.
(8) (8) (8)
Can we make a connection between the individual matrices, U1 , U2 , and U3 , in the FFT,
(8) (8) (8) (8) (8) (8) (8)
Eq. (C1), and the individual matrices, S02 , Hl , R1,m , Hm , R2,u , R1,u , and Hu , in the QFT,
Eq. (C6)?
(8) (8)
One immediately sees that U1 = Hu . However to make a connection between the other parts
(8) (8)
of the FFT, U2 and U3 , we introduce the swap operator between qubits 1 and 2:
 
1 0 0 0 0 0 0 0
 
0 1 0 0 0 0 0 0
 
 
0 0 0 0 1 0 0 0
 
 
0 0 0 0 0 1 0 0
(8)
S12 =  , (C14)
 
0 0 1 0 0 0 0 0
 
 
0 0 0 1 0 0 0 0
 
 
0 0 0 0 0 0 1 0
 
 
0 0 0 0 0 0 0 1
We also need to realize that we can move the R2 gate in Fig. 4 to the right as long as it does
not cross the Hadamard on the lowest qubit (since this is the control qubit). Hence we can also
write Eq. (C6) as
(8) (8) (8) (8) (8)
U (8) = S02 Hl (8)
R1,m R2,u Hm R1,u Hu(8) , (C15)
(8)
where we have moved R2,u to the left. We then find that
(8)
U1 = Hu(8) , (C16a)
(8) (8)
(8) (8)
U2 = S12 Hm R1,u , (C16b)
(8) (8) (8) (8) (8) (8)
U3 = S02 Hl R1,m R2,u S12 , (C16c)
17

y
2
x2 H R1 X X R2 X

y
x1 H X X R1 1
ψ
3

y0
x0 H X

U1 U2 U3

FIG. 7: Like Fig. 4 except that the R2 gate has been moved to the right of the Hadamard on the middle
qubit (which has no effect) and that a pair of reversals of the order of qubits 1 and 2 have been added (which
also has no effect). The reversal is accomplished by a swap gate. Note that the final reversal of the order of
all three qubits (on the right of the diagram) is also accomplished by a single swap gate. The correspondence
with the breakup of the FFT (U = U3 U2 U1 ) is indicated, see Eqs. (C16). To see this correspondence it is
necessary to include the pair of reversals of the order of qubits 1 and 2.

(8) 2
 
which agrees with Eqs. (C15) and (C1) since S12 is the identity (swapping twice makes no
change). This breakup is shown in Fig. 7. Apart from the reversals of qubit order, the correspon-
dence between the QFT and the FFT is straightforward to see.
Following the structure of Fig. 6 for two qubits, and Fig. 7 for three qubits the generalization
to four qubits is shown in Fig. 8. The correspondence with the FFT is clear, the only complication
being that, in order to show the correspondence, pairs of reversals of the order of the qubits (which
cancel each other out) have to be introduced, with one reversal being in one stage of the FFT
and the other reversal in the next stage of the FFT. Reading Fig. 8 from left to right, the first
reversal pair reverses qubits 2 and 3 (which needs a single swap gate between qubits 2 and 3), the
next reversal reverses qubits 1, 2 and 3 (which only needs a single swap gate between qubits 1 and
3), and the last reversal (not a pair because this is the last one so there is no additional stage to
compensate it) reverses all 4 qubits (which needs two swap gates, one between qubits 0 and 3 and
the other between qubits 1 and 2).
We see that there is a close parallel between the breakup of the FFT and circuit of the QFT. The
details are slightly complicated because one needs reversals of the order of the qubits to make the
correspondence precise. Note that Fig. 1 in https://arxiv.org/pdf/1005.3730.pdf is related
to the results presented here.
18

x3 H R1 X X R2 X X R3 X y3

x2 H X X R1 R2 X y
2

ψ
4

x1 H X X R1 X y
1

x0 H X y0

U1 U2 U3 U4

FIG. 8: The generalization of Figs. 7 and 6 to the case of four qubits. The correspondence with the breakup
of the FFT (U = U4 U3 U2 U1 ) is indicated.

You might also like