In the last post, I discussed the Fourier Transform on finite groups . Here I’ll discuss in more detail the case , the finite cyclic groups. This is what is usually called the Discrete Fourier Transform.

The (Quantum) Fourier Transform is a unitary transformation on , which in the standard basis is expressed by the matrix

with . It turns out that if and we interpret the Hilbert space as the state space of qubits, can be implemented efficiently, using only about elementary (1- and 2-qubit) gates.

**Efficient Circuit for the QFT**

Consider an -qubit state

The -qubit QFT acts on this state as follows:

where the and gates are phase and controlled phase gates defined implicitly, and is the Hadamard gate. Therefore, we have

The controlled phase gate can be implemented with elementary (2-qubit) controlled gates, and the Hadamard gate is a single qubit gate, so if we can implement the -qubit QFT, we just need additional elementary gates to implement the -qubit QFT. The 1-qubit QFT is just a Hadamard gate, so we can implement the -qubit QFT with elementary 1- and 2-qubit gates. I won’t reproduce the circuit here – nice drawings are available anywhere qubits are sold.

That’s the good news. The bad news is that the QFT is not an algorithm for the Discrete Fourier Transform in the sense we would really like it to be, i.e. a black box that takes a vector of classical data and outputs, as classical (i.e., readable) data, the Fourier transform of that vector. Instead, the QFT is a unitary transformation that takes as input a quantum state and gives as output another quantum state. So the QFT is not an exponentially faster replacement for the classical FFT algorithm, which does precisely this in time . In order to make use of the QFT as a limited replacement for the FFT, we need to figure out (1) what classical data can be efficiently encoded in the proper form and (2) what data can be efficiently extracted from the output state.

**Efficiently Encodable Data**

One example of data that can be efficiently encoded into a quantum state, given that it is already stored in a quantum accessible manner, is the following. Suppose that we have an oracle that was capable of performing the transformation where is a -valued function. Such an oracle can be efficiently implemented with the QRAM protocol (see e.g. https://arxiv.org/pdf/0708.1879.pdf). Then applying to the even superposition over all computational basis states (efficiently preparable from the zero state of qubits via Hadamard gates), measuring the second register in the computational basis, and post-selecting for outcome 1, we obtain the state

where is the normalization factor. This is a state of the form

with , so now the QFT can be used to Fourier transform .

If we assume that a constant fraction of the values of have , then we can prepare the state with exponentially high probability in the number of tries.

**Efficiently Extractable Data**

Here I’ll show that the QFT can be used in an efficient procedure for estimating the period of a quantum state. Since this application is at the heart of Shor’s algorithm, it’s probably the most famous use of the QFT.

Suppose that the vector is periodic with period , i.e. for all . Suppose also that divides . We have that where is the shift operator. Using the unitarity of the QFT, we then have

Expanding in the Fourier basis, this gives

where the hat denotes change of basis into the Fourier basis. It is simple to verify that , so that in order for this equation to hold, must be zero unless is a multiple of or, equivalently, is a multiple of (which we assumed was an integer). There are such values of .

This analysis shows that if we apply the QFT to and measure in the computational basis, we will obtain a value of such that . Suppose we prepare copies of and apply the QFT to each one, then measure in the computational basis. We obtain values , with . If the gcd of the is one, then the gcd of the is , and since is known, we obtain . Of course, it’s possible that the are exponentially small except for some a multiple of , in which case we’ll underestimate with high probability unless is exponentially large, in which case the quantum speedup is lost. However, in this case, is very close to a state with the period we estimated, so it’s not unreasonable to be satisfied with this performance.

On the other hand, suppose that all of the non-zero have roughly the same magnitude. Then the probability that with samples we correctly find is the same as the probability that the gcd of integers drawn uniformly at random from is one. It is not too hard to see that this probability is bounded exponentially (in ) close to one. If we didn’t do the classical post-processing of the outcomes and just looked for the smallest value of that appeared, we would not get this performance.

**Failed Example**

Combining these three parts (state preparation/data entry, transformation/data processing, and measurement/data extraction), we can try to build a quantum algorithm that gives with high probability a speedup over a classical computer for a simple problem. Suppose that we’re given a string of bits, stored either in a classical RAM or in a QRAM, and would like to determine the period of the data. Assume that a constant fraction of the bits are 1. Then with a constant expected number of calls to the QRAM, we can prepare the -qubit state whose amplitudes encode the unknown bitstring. With elementary gates, we perform the QFT on this state. Then we make a single -qubit measurement to obtain a value of present with non-zero amplitude in it’s Fourier transform. We need to repeat this procedure several times in order to give an estimate of the period. But how many?

Suppose that a malicious user designs a family of classical inputs and of lengths , where the have period and the are identical to the except that the first 1 in the second half of the string is changed to a 0, and the first 0 to a 1, so that they have period . Then the corresponding quantum states and are exponentially close in , meaning that the error probability for distinguishing and with a single measurement is exponentially close to 1/2. Therefore, it is exponentially unlikely that, given state , we measure an odd value of after performing the QFT, as if it were more likely, the discrimination procedure that reports if an even is measured and if an odd is measured would have a lower error probability than is possible given the distance between the states. This means that given the inputs , we need to repeat the basic QFT procedure above exponentially many times in order to have a large probability of obtaining an odd value of and accurately determining the period.

This counterexample tells us that, even for this very contrived problem, the QFT does not give a speedup over the classical algorithm, at least for the worst case. However, it’s worth pointing out that for some applications, it might be a feature that the quantum algorithm with sub-exponentially many runs of the QFT is insensitive to small deviations from perfect periodicity.

Scott Aaronson has written a paper about these kinds of issues in the context of quantum machine learning.