Some curious facts about quantum factoring
DOI: 10.1063/1.2800253
As explained in my Reference Frame column of April 2007 (
In a quantum computer, a nonnegative integer x less than 2 n is represented by the product state
Suppose the initial state of the input register is the superposition of all possible n-Qbit inputs,
(This can be constructed by starting with each Qbit in the state
So it appears that just one application of the subroutine evaluates the function f for all the 2 n possible values of x. This trick is called “quantum parallelism.”
But appearances can be deceptive. Given a system in a state you know nothing about, there is no way to learn that state. You can only extract information through measurement. If you immediately measure all the Qbits, you acquire a random value x 0 of x and the value f 0 of f(x 0), after which the state becomes
Ah, but suppose you measure only the m Qbits in the output register. When f(x) is ax (mod N), you will find with equal probability any one of the r distinct values f 0 and the input register will be left in a state
where x 0 is that random integer less than r at which
This looks promising. By learning only two of the many states
Fourier to the rescue
The clever move is Fourier analysis, in the form of a spectacularly efficient linear subroutine U FT that takes the n-Qbit state
Here the eyes of the quantum physicist tend to glaze over. Ah yes, if you go from position to momentum states, then measurement probabilities become sharply peaked at integral multiples j/r of the inverse period, from which the period r itself can be learned. Ho-hum.
But things are not ho-hummish. To lose interest at this stage is to overlook two crucial differences from boring everyday quantum mechanics. First, x has nothing to do with the position of anything, concrete or abstract. It is an arithmetically useful numerical construction out of the states
Reexamination shows that when n Qbits in the state
Of course, j/r determines not r, but r after any factors it has in common with the random integer j have been divided out. So what our quantum computer gives us is a 40% shot at learning a divisor r 0 of r. The odds that j and r have any really big factors in common are small, so chances are that r will be a fairly small multiple of r 0. You can easily check with a classical computer to see if ax = 1 (mod N) when x = r 0. If so, r = r 0. If not, try
Troublesome phases
But wait a minute! Looking more closely at the crucial subroutine U FT, one finds it to be cunningly constructed out of operations that apply conditional phase shifts
When this dawned on me, I concluded that all the hoopla rested on a silly failure to notice that you can’t turn fields on and off for durations you control to parts in 10300. But I was the silly one. I failed to appreciate the exquisite interplay between digital and analog in a quantum computation. Subroutines like U FT depend on parameters that vary continuously, as in analog computation. But readout through measurement produces an unambiguous sequence of 0s and 1s, as in digital computation. Reading out a thousand Qbits gives you a thousand bits of a definite integer—about 300 digits of the decimal representation of that integer. You learn every one of those 300 digits. The question is whether they are the right 300 digits.
Those “huge” (perhaps parts in 104) uncontrollable phase errors lead to comparable errors in the probability that that 300-digit integer will be one of the ones you’re looking for. So realistic phase errors might change the probability of getting what you’d like from a little over 40% to a little under 40%. They hardly matter!
A nice illustration of how quantum and classical programming styles differ is provided by the actual calculation of ax (mod N). Start with a, square it to get a 2 (here I stop writing “(mod N)”—all multiplications are modulo N), square that to get a 4, continuing in this way to get all the powers of the form
In a classical computer, the two-state systems used to represent 0 and 1, called Cbits, are cheap and time is precious. If you want to calculate ax for 2 n different values of x, you use n groups of Cbits to make a table of all the n different and you look up the various entries going into ax for each value of x, thereby removing the need to recompute those squares each time you turn to a new value of x.
But in a quantum computer, Qbits are precious and time is cheap. The multiplication of the appropriate into ax is not applied 2 n different times to an input register in each of the states
Why factoring 15 is too easy
There is another saving in Qbits to watch out for, because it is misleading. The period r of ax (mod pq) can easily be shown to be a divisor of
Another subtlety, only recently pointed out, 1 reduces that irritating 60% chance of not getting a divisor of r. When N is the product of two distinct primes, one can (again easily) show that r is not only less than N but less than ½N. As a result, besides getting a divisor of r when the measurement yields a y as close as possible to an integral multiple of 2n/r, second, third, and even fourth closest also work. This increase in the number of useful outcomes lowers the probability of failure from 60% to 10%, greatly simplifying the subsequent classical detective work.
Features of Shor’s “factoring” algorithm like those mentioned here are usually buried in the technical details. By exposing them to the light, I hope to have revealed some of the subtlety and charm of that remarkable procedure.
References
1. E. Gerjuoy, Am. J. Phys. 73, 521 (2005). https://doi.org/10.1119/1.1891170
More about the Authors
N. David Mermin. Cornell University, US .