Explain why the quantum Fourier transform is essential to Shor's algorithm. What does the state look like before and after the QFT, and how does the measurement outcome reveal the period?
Think about your answer, then reveal below.
Model answer: After modular exponentiation, the first register is in a periodic superposition with period r (states at x_0, x_0+r, x_0+2r, ...). The QFT converts this periodic state into one with amplitude peaks at multiples of 2^n/r. Measuring gives a random value close to some multiple c * 2^n/r. From the ratio c/2^n, the continued fraction algorithm extracts r. Without the QFT, the periodic structure would be hidden in the amplitudes and inaccessible through direct measurement.
The QFT is performing Fourier analysis of the periodic quantum state. Just as the classical Fourier transform of a periodic signal has peaks at the signal's frequency, the QFT maps a state periodic in the computational basis to one with peaks in the Fourier basis. The measurement samples from these peaks, and classical post-processing (continued fractions) recovers the frequency — which is the period r. This is the same pattern as Simon's algorithm but over the cyclic group Z_N rather than Z_2^n.