Quantum Circuit for the Fast Fourier Transform

We propose an implementation of the algorithm for the fast Fourier transform (FFT) as a quantum circuit consisting of a combination of some quantum gates. In our implementation, a data sequence is expressed by a tensor product of vector spaces. Namely, our FFT is defined as a transformation of the tensor product of quantum states. It is essentially different from the so-called quantum Fourier transform (QFT) defined to be a linear transformation of the amplitudes for the superposition of quantum states. The quantum circuit for the FFT consists of several circuits for elementary arithmetic operations such as a quantum adder, subtractor and shift operations, which are implemented as effectively as possible. Namely our circuit does not generate any garbage bits. The advantages of our method compared to the QFT are its high versatility, and data storage efficiency in terms, for instance, of the quantum image processing.


Introduction
Quantum computing, which utilizes quantum entanglement and quantum superpositions inherent to quantum mechanics, is rapidly gaining ground to overcome the limitations of classical computing. Shor's algorithm [1] solving the integer factorization problem in a polynomial time, and Grover's algorithm [2] making it possible to substantially speed up the search in unstructured databases are one of the best-known examples of the astounding properties of quantum computing (see [3], for example, for various applications of quantum computing).
An implementation of the Fourier transform as a quantum circuit sometimes plays a crucial role on quantum computing. Indeed, the quantum Fourier transform (QFT) [4] is a key ingredient of Shor's and Grover's algorithms. Here, the QFT is the Fourier transform for the amplitudes of a quantum state: where we set N = 2 n , and the amplitudes {X k } are the classical discrete Fourier transform of the amplitudes {x j } 2) where W N := exp(−2πi/N ). Due to the superposition of the state (1.1) and quantum parallelism, the QFT can be implemented in a quantum circuit consisting of O(n 2 ) quantum gates, which is much more efficient than the fast Fourier transform (FFT) [5] whose complexity of the computation is O(n2 n ). The Fourier transform that we consider in this paper is somewhat different from the QFT: we propose a quantum implementation of the algorithm of the FFT rather than the QFT. In our procedure, a data sequence is expressed in terms of a tensor product of vector spaces: N −1 j=0 |x j . We define the Fourier transform as where the data sequence {X k } is the Fourier transform of {x j } as expressed in (1.2). We adopt the reversible FFT [6] as an algorithm of the above Fourier transform, and implement it as a quantum circuit whose computational complexity is O(n2 n ). In this point of view, the processing speed is the same as the classical one, as long as we consider only a single data sequence. Nevertheless, there are following advantages compared to the classical FFT, and even compared to the QFT. The first is due to quantum parallelism. Namely, utilizing quantum superposition of multiple data sets, we can simultaneously process them. The second is due to its high versatility: the method is always applicable to data sets that can be processed by the conventional FFT. The third advantage is its data storage efficiency in terms, for instance, of the quantum image (see [7,8,9,10] for some applications of the QFT to quantum data sets). Let us illustrate the third advantage above with a simple example: an L × L pixel image with a grayscale value ranging from 0 to M − 1 (M = 2 m ) (see Fig. 1 for L = 2). (This problem is equivalent to a lattice quantum many-body problem on an L × L square lattice with each site occupied by a particle with M degrees of freedom.) This quantum image |ψ (α) (α denotes the label of the image) can be represented by a tensor product of vector spaces [11,12,13,14]: Since |ψ (α) ∈ (C 2 ) ⊗mL 2 , it uses mL 2 qubits. By use of the quantum superposition, the quantum FFT (let us denote it as QFFT) can simultaneously process at most 2 mL 2 quantum x 0,0 Figure 1: A 2 × 2 pixel image with a grayscale value ranging from 0 to M − 1 (M = 2 m ) is depicted in the left panel. x j,k in the right panel denotes the value of the grayscale on the (j, k)-site. The quantum image can be represented as |x 0,0 ⊗|x 0,1 ⊗|x 1,0 ⊗|x 1,1 ∈ (C 2 ) ⊗4m . images: On the other hand, to apply the QFT to the above image processing, we need to prepare the quantum image in the form of where | ψ (α) ∈ (C 2 ) ⊗2 log 2 L which uses only 2 log 2 L qubits (cf. (1.4) for the QFFT) [15,16,17]. However, since the Fourier coefficients (see (1.1) and (1.2)) are expressed as the amplitudes of the superposition, it takes exponentially long time to extract all of them completely. Furthermore, to properly perform the Fourier transform for the multiple 2 mL 2 quantum images, they must be represented as Namely, for the QFT, (2 mL 2 +1 ) log 2 L qubits are required to process the 2 mL 2 quantum images, which are much larger than mL 2 qubits for the QFFT. Moreover, the QFT must be applied to each image individually 1 . As a result, the total processing time for the QFFT is shorter than that for the QFT, when the number of the quantum images is sufficiently large.
In this paper, we construct a quantum circuit of the above explained QFFT, by implementing some elementary arithmetic operations such as a quantum adder [18,19,20,21,22,23], subtractor [24,25,26,27] and newly developed shift-type operations, as efficiently as possible: our quantum circuit does not generate any garbage bits. 1 The multiple quantum images can also be represented as 2 mL 2 α=1 |ψ (α) ∈ (C 2 ) 2 log 2 L+mL 2 which uses 2 log 2 L + mL 2 qubits. However, the resulting Fourier image obtained by the QFT are no longer the same as any of the Fourier images of the individual quantum images.
The outline of the paper is as follows. In the subsequent section, introducing the algorithm of the FFT, we show the elementary arithmetic operations required for the implementation of the QFFT as a quantum circuit. In section 3, we actually implement these elementary arithmetic operations into quantum circuits. In section 4, combining these elementary circuits efficiently, we construct a quantum circuit for the FFT. Section 5 is devoted to a summary and discussion. Some technical details are deferred to the appendices.

Elementary operations required for the QFFT
In this section, we briefly introduce the algorithm of the FFT and pictorially represent several arithmetic operations required for the implementation of the FFT as a quantum circuit. (See [28], for instance, for the detailed algorithm of the FFT.)

Algorithm of the FFT
Note that G where 0 ≤ k ≤ N/2 − 1. Here the broken line means the multiplication by −1. For convenience, we also denote it as a matrix-like notation: Here the matrix-like operation is defined as Repeating this procedure, one obtains the following recursion relation: The initial states are given by Most importantly, in each step given by (2.8), the computational complexity is O(2 n ). Namely the total computational complexity of the Fourier transform is reduced from O(2 2n ) for (1.2) to O(2 n n) for the above procedure. This is the algorithm of the FFT. In Fig. 2, we pictorially depict the FFT for N = 8.

Elementary operations in the FFT
As seen in (2.4), to implement the FFT in a quantum circuit, the multiplication of the matrices should be carried out in terms of quantum computation. The first one is separated into an adder, a subtractor and shift operators by the LDU decomposition Utilizing the matrix-like notation as in (2.4), the action of the first matrix defined in (2.4) on states |a and |b can be graphically interpreted as Note again that the above operation differs from the conventional matrix operations. On the other hand, the second matrix is simply expressed as Thus the butterfly diagram as in (2.3) or (2.4) can be written as Consequently, the QFFT can be implemented into a quantum circuit consisting of adders, subtractors and shift operators. In the next section, we explain these arithmetic operators. An actual implementation of these operators into the butterfly operations (2.14) is deferred to section 4.

Quantum circuits for arithmetic operations
In this section, we pictorially present a concept of some quantum arithmetic operations such as a quantum adder, subtractor and shift operators, which are required to implement the QFFT as a quantum circuit. Some detailed implementations for these operators are deferred to appendices.

Sign extension
In the actual computation, to avoid overflow, we sometimes need to increase the number of bits (a so-called sign extension). This operation can be achieved by just inserting a ± 's to the representation: For instance, the representation for the m-qubit system can be extended to that for the l-qubit system (l > m): |a ± · · · a ± m−n a n−1 · · · a 0 −→ |a ± · · · a ± l−n a n−1 · · · a 0 . (3.4) In Fig. 3, we show a quantum circuit to increase the number of digits from 4-qubit to 6-qubit.

Adding and subtracting operations
Let us consider an adder and a subtractor, by slightly modifying the arguments developed in [23,27]. A quantum adder is defined as a transformation of the state: |a ⊗ |b −→ |a ⊗ |a + b . In Appendix A, we implement this adder as a quantum circuit (see Fig. 8).
On the other hand, using the identity a + b = a − b, we define a quantum subtractor as which can be implemented by just inserting NOT gates (denote it by the symbol ) to the above defined adder (3.6) [27]:

Arithmetic shift operations
Let us implement an operation to multiply by 2 p (p ∈ N): |a −→ |2 p a . Let us pictorially express this operation as In a similar manner, we can define an arithmetic right shift which is an operation to multiply by 2 −p : where a −k (1 ≤ k ≤ j − p) are the fractional part of a. Note that, in the above operation, p significant digits are lost. We also graphically denote this operation The actual implementation of these shift operations into quantum circuits can be accomplished by certain combinations of SWAP and CNOT gates. In Fig. 4, we show a quantum circuit for the left (right) shift operation for m = 3, n = 3 and p = 1.
Combining the adder, the subtractor and the shift operations, we can arithmetically manipulate an arbitrary number.

Decomposition of the butterfly operation
Now we decompose the butterfly operation (2.14) (see also (2.3)), which plays a central role on the QFFT, into the elementary arithmetic operations shown in previous section. First, Loss of signicant digits Figure 5: A quantum circuit of an adder with a right shift operation (4.6) for p = 2. Though two additional qubits are required for this right shift operation, these two qubits are reusable. Moreover this quantum circuit does not generate any garbage bits. Some elements of the circuit is defined in Fig. 6.
we decompose the butterfly operation into elementary operations: In the butterfly operation, the input states consist of |(W k N )a . Let us abbreviate the component W k N = exp −i 2π N k to exp (iθ) for simplicity. The calculation of |exp (iθ) a is decomposed into |exp(iθ)a = |(cos θ + i sin θ)(a r + ia i ) = 1 i cos θ − sin θ sin θ cos θ |a r |a i , where a r and a i are, respectively, the real and imaginary part of a. The rotation matrix is further decomposed into adding (resp. subtracting) operators (3.6) (resp.  Because to apply the right shift operator, we use (4.3) for θ ∈ [− π 2 , π 2 ), while, for θ ∈ [−π, − π 2 ] ∪ ( π 2 , π], we use (4.4). The each matrix in the RHS of the above decomposition is schematically given by (4.6) In fact, this decomposition makes it possible to efficiently implement the elementary arithmetic operations required for the QFFT. Namely, we develop an implementation of the above procedure into a quantum circuit so as not to generate any garbage bits. For p = 2, the quantum circuit is shown in Fig. 5. The circuit consists of the Toffoli gate [30] and the Peres gate [31] defined as in Fig. 6, where V and V † are, respectively, given by Thanks to the circuit (4.6), we can construct quantum circuits of adding and subtracting for an arbitrary number: Thus, the decompositions (4.3) and (4.4) are summarized graphically: (4.9) Considering that quantum circuit is reversible, the calculation of inverse FFT requires two matrices which are also decomposed into an adder, a subtractor and shift operators.

Summary and Discussion
In this paper, we have discussed the implementation of the FFT as a quantum circuit. The quantum version of the FFT (QFFT) is defined as a transformation of a tensor product of quantum states. The QFFT has been constructed by a combination of several fundamental arithmetic operators such as an adder, subtractor and shift operators which have been implemented into the quantum circuit of the QFFT without generating any garbage bits.
One of the advantages of the QFFT is due to its high versatility: the QFFT are applicable to all the problems that can be solved by the conventional FFT. The frequency domain filtering of digital images is one of the possible applications of the QFFT. The major advantage of using the QFFT lies in its quantum superposition: multiple images are processed simultaneously (see Fig. 7 as a conceptual image of quantum parallelism). It is even superior to the QFT when the number of images is sufficiently large. Thus, the QFFT will be a great help in the industries including security, healthcare, and marketing research, where numerous images are involved. In particular we can create a high pass filter for edge detection (Fig. 7).
There are several issues remaining to be solved. The first one is how to effectively generate a quantum superposition of multiple data sets as in (1.5). Though, in principle, one can generate it using the Hadamard gate and the Pauli-X gate, it is still a difficult problem to superpose arbitrary data sets with arbitrary probability amplitudes. The second is how to use the resultant multiple data sets obtained by performing the QFFT. The QFFT sustains all the information of Fourier coefficients until the moment the quantum state is measured. If the quantum state that contains the Fourier coefficients of multiple data sets was passed on to some quantum device directly and there were some proper techniques to handle it, it would play a key role in the field of quantum machine learning.

Acknowledgment
The present work was partially supported by Grant-in-Aid for Scientific Research (C) No. 16K05468 from the Japan Society for the Promotion of Science.

A Implementation of the adder circuit
Let us consider the addition of two n-bit numbers |a and |b with the binary representation |a = |a n−1 · · · a 0 , |b = |b n−1 · · · b 0 ({a j , b j ∈ 0, 1}). It is calculated as where the carry bit c j and the sum bit s j (j = 1, · · · n) are defined by .
Note that the symbol ⊕ denotes exclusive disjunction. In terms of a quantum circuit, this addition is implemented in the transformation of the state |a ± |a ± Figure 8: An adder circuit. The circuit consists of the Toffoli and the Peres gates defined as in Fig. 6.
and Fig. 8 shows the actual circuit which is a slightly modified version of a quantum adder originally developed in [23].

B Number of extra qubits a ± required for the QFFT
The key structure of the QFFT is the butterfly operation combined with the multiplication of W k N . In the whole QFFT process, we have log 2 N layers of this structure. By counting the ratio of the possible value ranges of the input and output of this structure, and multiplying it by log 2 N , we can estimate the number of qubits a ± required for the QFFT.
Let I r and I i be the real and imaginary part of the input I and impose the following conditions on I: −2 n ≤ I r , I i ≤ 2 n − 1 Because the initial input is a real number (I i = 0), it satisfies the above conditions. The multiplication of W k N is essentially a rotation in the complex space. Namely, it preserves the distance: where the suffixes i and r represent the real and imaginary part, respectively. The output O of the butterfly structure then satisfies .

(B.3)
The absolute value of the output is doubled compared to that of the input. Therefore, one extra qubit a ± is required for one layer and log 2 N a ± 's for the total QFFT.