Quantum Fourier transform

At the heart of Shor's Algorithm is the Quantum Fourier Transform (QFT), which we shall now examine. That this function should be of interest to us is perhaps not surprising. Recall that for simple oracle problems the aim is to determine some global property of a function. Within quantum mechanics, we are very much used to this sort of situation -- how often have you simplified a problem by transforming it from a position representation to a momentum representation i.e. applied the Fourier Transform? Formally, the QFT is expected to be useful in determining the period math of a function i.e. when math for all math.

We shall start by defining the QFT operation acting on math qubits (math),

math

We can verify that this is a unitary operator by calculating

math

separately analyzing the cases of math and math. In the latter, we must sum a geometric progression,

math

How should we construct a circuit to implement this operation? We should start with a more careful examination of the representations of the number math. The number math has a decimal representation in the range math to math, but it also has a binary representation with digits math where math is the math least significant bit. The decimal and binary descriptions can be related by

math

This means that the state

math

(math) can be written as

math

Inserting the expansion for math, the term

math

Given that this is being exponentiated, any term math that is an integer contributes a factor of math to the phase, and makes no difference to the final result. This means that the state we wish to create can be written as

math

To make life easier, we will now swap the order of qubits in the register i.e. if we have a register of math qubits where the most significant bit of the input is at the top, and the least significant bit at the bottom, then we shall read our output as having the least significant bit at the top, and the most significant at the bottom:

math

This means that the state of the math output qubit only depends on qubits math to math, and requires the addition of a phase math if the input bit math and output bit math are both in the math state (i.e. we should be looking at applying controlled-phase gates). When math, this simply requires the application of a Hadamard gate (giving a phase of math). Thefore, we should start from qubit math and apply a Hadamard gate. Then, we apply controlled-phases from all other inputs. Then we move up to qubit math, apply Hadamard, and controlled-phases from all qubits except qubit math. This should work down towards qubit math, on which we apply just a Hadamard.