Measuring the quantum Fourier-transformed state reveals information about the phases of the qubits.
I’ve been wanting to write an article on Shor’s Algorithm but every time I start I find that I need to devote a large chunk of writing to explaining the Quantum Fourier Transform component, which ends up just taking up way too much of the article.
So instead, I thought I’d write this article to explain, at a high level, why a quantum algorithm would need a QFT in it in the first place; and then tackle Shor’s algorithm in a later article once the groundwork is laid.
Understanding why a QFT is useful in an quantum circuit can lead to a better understanding of the circuit design in general, and this understanding can scale to many other algorithms too.
So we are going to try to get to the point that when you see a “QFT” block in a quantum circuit diagram you won’t have to ask: “why is that there?”.
When a register of qubits is entangled and in a superposition, they can contain a huge amount of information, exponentially more than classical bits. The problem is: measuring the register results in the exact same amount of information as would measuring a classical register, i.e. one, single result.
But qubits can potentially contain an infinity of possible results – after all, they are essentially probability distributions. So who is to say the one we measured is correct?
Enter the mighty quantum Fourier transform.
If a problem is framed correctly (and we’ll talk more about that later), then a register of qubits can be transformed in to a new state whereby the measurement of that new state has had all the information focused in to one point with an infinite amplitude.
We also want to keep in the back of our mind the number one application of this process: Shor’s Algorithm.
Briefly, Shor’s Algorithm finds an integer’s prime factors. For example, the integer can be written as where each are prime. More precisely, SA finds the order of an element modulo . And so, the problem of finding a non-trivial (e.g. prime) factor of an integer is reduced to finding the order of a non-trivial (e.g. prime) element of the multiplicative quotient group .
If that’s too high-brow for you, don’t worry, we’ll get to this in the next article. First, we need to know what QFT can do for us and only then will we start to realise how it can be useful in the problem of finding prime factors.
The General Idea Behind Using QFTs in Quantum Algorithms
In general, you will use a QFT in a quantum algorithm when you have already used superposition and entanglement to encode a problem on to an array of qubits, and you now what to measure those qubits to obtain an answer to the problem.
The problem with measuring a register of entangled qubits in superposition is that you will only ever get one single result (destroying the others) with only some probability that it is the correct one.
Instead, if you could somehow transform the register of entangled qubits in to another state altogether that, not only singles-out the correct result but also gives the associated probability of the singled-out result being correct (including the constraint that the sum of all probabilities equal one), then that would be marvelous!
But does such a transformation exist?
where is knows as the phase. Also assume that the number of qubits is some power of two, i.e. . Then, if we make these assumptions about , and they are quite strong assumptions, then two very interesting things happen that allows us to single-out correct results:
First Interesting Thing
You can split additions in the exponent in to multiplications:
Let’s initiate the pattern again…
Doing this more times:
and we have the main result:
What does this mean?
It means that anywhere we see we can replace it with , something which we will be doing in the following calculation.
Now let’s make this a controlled unitary operation on qubits. All this means is that you apply on in the target register only if in the control register.
This means we need two registers, denoted , consisting of qubits each.
We also apply the Hadamard gate to the first register to get them all in to a superposition, so we have:
Second Interesting Thing
After applying controlled operations to each of the qubits in the target register (controlled by states of the control register ), the combined state of the control register (remember, after the Hadamard gate has been applied to each qubit) is:
This is nothing but:
where is the binary representation of , i.e. it is the computational basis (see the previous article here with a more in-depth explanation) But notice that since all the change is in the global phase part of the summation, the target register is essentially (physically) left completely unchanged!
Applying the Inverse Quantum Fourier Transform
The form of the target qubit register above inspires us to apply the inverse quantum Fourier transform, which yields
Now, we would like to perform a measurement on this second register (as it contains our answers!). However, by definition, quantum measurements must yield real results and therefore are modelled by performing inner products with the measurement state. Probabilities associated with measurement are then found by taking the absolute value squared, in the usual way:
Our problem here is that we have no value of in our expression, we only have , , , and . Uh oh!
How can we get one in there?
Phase Approximation Representation
This is where the phase approximation part comes in!
Take that little exponent . We know that , thus . Thus, is a real number, not an integer. We can always split real numbers out in to integers plus an difference, i.e. we always have , where is always less than or equal to one-half, so long as is the nearest integer to .
We don’t need that bit in the exponent. So we approximate it as
for all , where is the nearest integer to , and the difference (which scales with ) satisfies the bounds
Now we have an expression, with a discretised, approximated phase that includes an in it:
Performing measurement in the computational basis on the first, control, register yields the result with probability:
Evaluating the left-hand side of the inner product first we see that we get in the exponent, so that part reduces to 1. We can also pull out the outside of the absolute value squared to get . Lastly, since the cancellation leaves us with no terms with in them, the -summation disappears as well, and we are left with:
What can we say about this measurement?
When , which implies that is precisely an integer and no approximation is necessary, then (remember, going from zero to is, in fact, terms!):
In other words, the qubit register, when measured, yields the correct result with probability 100%.
If , i.e. is not an integer, then the qubit register, when measured, yields the correct result with probability bounded below by 40.5%. Which is a pretty good lower bound, and, in fact, can be increased to practically 100% by including more and more qubits in the register.
So what have we done so far?
Well, we have assumed that our mathematical problem can be expressed as a unitary operator on the input register of qubits. Using the properties of the unitary operator and the fact that we have exactly number of qubits we found that we could express the unitary operator as an exponential with phase equal to some factor of , in other words, the size of the register becomes part of the phase of the mathematical problem. Then we found that the exponential could be factored in to a product of factors, where those factors themselves were motivated by the potential to implement each one as a Hadamard and Rotation gate in a quantum circuit. But then we noticed that the expanded, factored expression is precisely that of the quantum Fourier transform that we found in the previous article here.
Thus, assuming unitarity, power of two sizes of qubit registers, and the factors being Hadamard and Rotation gates, we find that the exponentiated factorisation has precisely the same form as if we had just applied a quantum Fourier transform!
The beauty of this result looking like the quantum Fourier transform is that all the transforming going on is only occurring with the global phases of the qubits, and not with their actual physical components. Thus, if we had encoded a mathematical problem in to a register of qubits, then our assumptions of unitarity, size, and factoring in to H and R-style gates, does not alter the state of the qubit – only their phases. One could say that all the information of the problem is now encoded in to the global phase of the register – which is essentially something we can do as much as we like without destroying the structure of the problem.
To get an actual result, however, we have to transform the information held in the global phase back in to a target register of qubits . To do this we applied the inverse quantum Fourier transform and found that if the phase (which is a real number with modulus) was exactly an integer then the global phase transforms back in to one single result with 100% probability! This is because the inverse QFT maps the exponentiated factored input register back in to a state that has focused all the amplitudes.
Which is utterly amazing in my opinion.
However, the likelihood that the global phase is exactly an integer is minuscule. But the neat thing about this setup is: when the phase is not a integer the global phase transforms back in to one single result with a non-zero probability – not a zero probability as if it were, say, a uniform probability distribution (which is what it is in the beginning). In fact, the probability is dependent on the size of the input qubit register, and repeated measurements will only serve to increase the probability of obtaining a correct answer, theoretically to 100% in the infinite limit.
While we have enforced quite a number of assumptions in this setup, it is still truly remarkable, yet completely mathematically logical, that performing, essentially what is a discrete quantum Fourier transform and then applying the inverse quantum Fourier transform gathers together the amplitudes and focuses them in to a delta-like function right at the point that we need it to. The algorithm knows to do this because that point where all the amplitudes are focused is an eigenvalue of the unitary operator.
Therefore, the quantum phase estimation algorithm utilises the power of linear algebra to manipulate the global phases of a register of entangles qubits in superposition such that the inverse quantum Fourier transform provides the answer that we are looking for with an infinite amplitude, a.k.a. 100% surety.
In the next article we will be discussing Shor’s algorithm and how it used the sorcery of quantum phase estimation to find prime factors.
 Cleve, Ekert, Macchiavello, Mosca – Quantum algorithms revisited, Proceedings of the Royal Society 454 (1998).
 Nielsen, N. & Chuang, I. L. – Quantum Computation and Quantum Information, Cambridge University Press, (2010).