The Quantum Fourier Transform
Suppose you are handed a periodic signal hidden inside the amplitudes of a quantum state. You are asked to find its period. Classically, extracting periodicity means sampling the signal many times. You then run a discrete Fourier transform, costing at least linear time in signal length. The Quantum Fourier Transform (QFT) performs the analogous frequency extraction on a superposition of amplitudes. It uses only quantum gates. This is exponentially fewer than the operations of the classical Fast Fourier Transform, measured against the vector size . This efficiency is not a curiosity. It is the mechanical heart of nearly every quantum algorithm with a proven exponential or superpolynomial speedup. Shor's factoring algorithm, the discrete-log algorithm, and the general Abelian Hidden Subgroup Problem framework all share a pattern. They reduce their hard classical problem to finding a period. Then they delegate that period-finding to the QFT. Once you understand the QFT circuit, you understand the reusable engine underneath these landmark results. The big picture is this: classical Fourier analysis converts a function of time into a function of frequency. This reveals structure invisible in the original domain. The QFT does exactly this, but acts on the amplitudes of a quantum register. It does so using entangling controlled-phase gates arranged in a tight, recursive circuit. Quantum amplitudes are not directly readable. So the QFT is almost always used as a middle step. It sits sandwiched between state preparation and a measurement that samples from the transformed distribution. This article gives the precise definition of the QFT over . It derives its circuit from the classical FFT's divide-and-conquer structure. It proves the gate count and approximate variants. It also works a full numerical example by hand. It closes by connecting the QFT forward to Quantum Phase Estimation and the Order-Finding Subroutine. These are the two direct consumers of this transform in Shor's algorithm.
- The QFT maps computational basis states to superpositions encoding the -th roots of unity, exactly mirroring the classical DFT on amplitudes.
- A recursive circuit built from Hadamard gates and controlled phase rotations implements the QFT on qubits using gates.
- The circuit's correctness follows by unrolling the same divide-and-conquer recursion that gives the classical Fast Fourier Transform its speed.
- gates for a transform of size is exponentially better than the classical FFT cost, though the QFT cannot be used to read out an unknown state's spectrum by naive measurement.
- The QFT is not itself an "answer machine" — it is the subroutine that turns periodicity in amplitudes into periodicity in measurement outcomes, used inside phase estimation and order finding.
- Approximate QFT variants drop negligible-angle rotations, achieving gates for polynomial-precision needs.
The Quantum Fourier Transform is a unitary circuit of size that performs a discrete Fourier transform on amplitudes, converting periodic structure in a quantum state into a form measurement can reveal.
The idea
The Quantum Fourier Transform on qubits is the unitary operator that acts on computational basis states , where , exactly as the classical discrete Fourier transform (DFT) acts on a vector of complex amplitudes. Precisely, the QFT is defined by its action on basis states:
Applied to a general state , the QFT produces where — precisely the classical DFT of the amplitude vector . Because the DFT matrix is unitary (its rows are orthonormal, scaled by ), the QFT is a legitimate quantum gate: a unitary operator on the -qubit Hilbert space. The crucial structural fact, inherited directly from the classical Fast Fourier Transform (FFT), is that the DFT matrix factors into sparse stages. The FFT exploits this factorization to compute a length- transform in arithmetic operations instead of the naive matrix-vector product. The QFT exploits the same factorization, but because quantum superposition lets amplitudes be manipulated by touching only qubits, the resulting circuit needs only gates — exponentially fewer than even the FFT's already-efficient , when cost is measured against the vector length . The output amplitudes are never directly the answer: quantum amplitudes cannot be read out individually. Instead, the QFT is used to reshape a state's structure so that a subsequent measurement samples an integer that reveals information — most often, the period of a hidden function or the phase of an eigenvalue. This is the pattern used in Quantum Phase Estimation and, through it, in Shor's algorithm's Order-Finding Subroutine.
How it works
From binary fractions to a product formula
Write in binary as (most significant bit first), so . A standard algebraic manipulation — expanding the exponent in binary and discarding integer multiples of (since ) — shows that the QFT output state factors into a tensor product of single-qubit states:
where denotes the binary fraction . This product formula is the entire reason an efficient circuit exists: instead of building an entangled -dimensional output vector directly, we build it as separate single-qubit factors, each computable by applying a Hadamard gate followed by a chain of controlled phase rotations conditioned on the other qubits' bit values.
The circuit, qubit by qubit
Concretely, for qubit (holding bit ), the required single-qubit factor is produced by: 1. A Hadamard gate on qubit , which contributes the leading term . 2. A sequence of controlled phase gates , each controlled by a later qubit and applying the phase to qubit 's amplitude, refining the binary fraction one bit at a time. The standard controlled-phase gate used is
applying phase to the target qubit only when the control qubit is . After processing all qubits this way, a final bit-reversal permutation (via SWAP gates, or simply by relabeling wires) restores the natural ordering, because the recursive construction naturally outputs qubits in reversed order. ``` Algorithm: Quantum Fourier Transform on n qubits Input: quantum register |j_1 j_2 ... j_n> (n qubits, computational basis state) Output: state QFT_N|j_1...j_n> (N = 2^n), same register, bit-reversed order QFT(qubits[1..n]): for l = 1 to n: apply H to qubits[l] for k = 1 to n - l:
# controlled phase: control = qubits[l+k], target = qubits[l] angle = 2*pi / 2^(k+1) apply Controlled-Phase(angle) with control qubits[l+k], target qubits[l]
# qubits are now in reverse order relative to standard QFT convention for i = 1 to floor(n/2): SWAP qubits[i], qubits[n - i + 1] return qubits ``` Each qubit receives exactly one Hadamard and controlled-phase gates, for a total of
two-qubit and single-qubit gates, plus SWAP gates for the final reversal (each a constant number of two-qubit gates), which does not change the asymptotic count.
Reading the diagram
Each row is a qubit-wire, time flows left to right. Qubit receives a Hadamard, then three controlled-phase gates controlled successively by , each contributing a finer binary digit to its phase. Qubit receives one fewer controlled rotation, and so on down to , which receives only a Hadamard. The dashed line marks the final swap stage that undoes the bit-reversal inherent in the recursive construction.
Complexity & correctness
Gate complexity. As counted above, the circuit uses exactly Hadamard gates and controlled-phase gates, plus SWAPs, for a total of
elementary gates, where . This is exponentially smaller than the classical FFT's arithmetic operations when both are measured in terms of the vector dimension : the QFT is polynomial in , while the FFT is polynomial in itself.
Why the circuit is correct. The correctness argument is an algebraic unrolling of the product formula, not an appeal to a black box. Starting from , apply to qubit 1:
since , matching and exactly. The controlled- gate, controlled by , then multiplies the -amplitude of qubit 1 by exactly when , upgrading the phase to . Each successive controlled- gate appends one more binary digit of the fraction. After all controlled rotations on qubit 1, its state is exactly
which is precisely the factor of the product formula. The same argument applies verbatim to qubit , using only bits (since qubit never depends on bits before it — those have already been "used up"). Multiplying the single-qubit factors together, by linearity of tensor product over the sum defining each factor, reconstructs exactly
which is the definition of . Since the circuit's action agrees with the definition on every basis state , and both the circuit and the QFT are linear operators, they agree on all superpositions — establishing full correctness. Because the circuit is manifestly a product of unitary one- and two-qubit gates, it is automatically unitary, confirming the QFT is a valid quantum operation without needing a separate unitarity check.
Why is unavoidable (in the exact circuit) — and how to beat it approximately. The construction directly mirrors the recursive butterfly structure of the Cooley–Tukey FFT: splitting a length- DFT into two length- DFTs on even- and odd-indexed inputs, recombined with "twiddle factor" phase corrections. Classically, this recursion has levels and each level touches all points, giving . Quantum-mechanically, each level touches only qubits with a chain of controlled rotations, and there are levels, giving . The controlled-phase angles shrink exponentially as grows. In the Approximate QFT (AQFT), rotations by angle smaller than some threshold are simply omitted. A careful error analysis (each dropped rotation perturbs the final state's fidelity by at most , and errors add subadditively across retained gates) shows the total output state's fidelity loss is while gate count drops to — essentially for constant precision. This tradeoff is used in practice: fewer gates means less decoherence exposure on real noisy hardware, at the cost of a controllably small approximation error.
Honest limitation. The QFT's speed advantage is entirely in transforming amplitudes you already have in superposition. It does not let you read out the Fourier coefficients of an arbitrary unknown state efficiently — a single measurement after the QFT yields only one sampled output, governed by the Born rule, not the full spectrum. Its power is unlocked only when combined with problem structure (periodicity, eigenphase encoding) that concentrates the post-QFT measurement distribution on informative outcomes — exactly the setup engineered by Quantum Phase Estimation.
Worked example
Take qubits, so , and trace where , i.e. . By the product formula, we need , and its shifted versions:
| Qubit | Binary fraction | Value | Phase |
|---|---|---|---|
So the product formula predicts
Trace through the circuit to confirm this matches, tracking qubit 1 (the most work, since it accumulates the most rotations): 1. Start: . 2. Apply to qubit 1 (): produces , i.e. phase on . Current fraction: . ✓ matches . 3. Apply controlled- on qubit 1, controlled by qubit 2 (): control is , gate does nothing. Fraction stays . 4. Apply controlled- on qubit 1, controlled by qubit 3 (): control is , multiplies -amplitude by . New phase: . Fraction: . ✓ matches the table exactly. Repeating for qubit 2 (: Hadamard gives phase ; controlled- from multiplies by , giving total phase ✓) and qubit 3 (: Hadamard alone gives phase ✓) confirms every factor. The numerical output (unnormalized ordering before bit-reversal correction) is exactly
and this is a genuinely entangled-looking but actually product state — a hallmark of QFT outputs on basis-state inputs. Expanding fully gives all 8 amplitudes with magnitudes, matching the classical DFT of the indicator vector , i.e. — exactly the definitional formula, confirming the circuit computed the right transform.
Common pitfalls & traps
| Pitfall | Why it happens | Fix |
|---|---|---|
| Forgetting the final bit-reversal / SWAP stage | The recursive construction naturally outputs qubits in reverse index order | Always append the SWAP network, or track the reversal in software and reinterpret wire labels |
| Confusing QFT with reading out a Fourier spectrum | Amplitudes are not directly observable; only one sample is obtained per run | Use QFT only as a subroutine feeding a measurement whose distribution encodes the answer (e.g. phase estimation) |
| Using the wrong sign convention for | Some texts define QFT with (inverse convention) | Fix and state a convention explicitly; it only flips the role of QFT vs. inverse-QFT, but must be consistent throughout a derivation |
| Applying controlled-phase gates with the wrong control/target pairing | The formula requires qubit 's phase to depend on later bits , not earlier ones | Carefully match control = later qubit, target = earlier qubit in the standard construction |
| Assuming AQFT truncation is "free" | Dropping small-angle rotations still introduces a real, if small, fidelity error | Bound the total error via the sum of dropped phase magnitudes and choose the threshold to match required precision |
:::warning[The single most dangerous mistake is treating QFT output amplitudes as directly readable data. A measurement collapses the state to one sampled integer governed by the squared amplitudes — the QFT's value comes entirely from how algorithms like phase estimation engineer that sampling distribution to concentrate on the answer, not from any ability to "read off" a spectrum in one shot.]:::
Pioneers & history
The QFT was not invented as a standalone object; it emerged as the mathematical engine inside quantum algorithms designed to exploit periodicity, drawing directly on a century of classical Fourier and Fast Fourier Transform theory.
Origins · 1 minPeter Williston Shor and how this was discovered
Shor showed in 1994 that an efficient QFT circuit, combined with modular exponentiation and continued-fraction post-processing, factors integers in polynomial time — the result that made the QFT central to quantum algorithms.
Where this matters
The QFT is the shared engine inside every quantum algorithm that exploits the <span class="wiki-link-missing">Hidden Subgroup Problem</span> structure. Shor's factoring algorithm uses the QFT to extract the period of modular exponentiation, which — via elementary number theory — reveals a nontrivial factor of the integer being factored; this is the same machinery underlying attacks on RSA-style public-key cryptography, motivating the entire field of post-quantum cryptography. The discrete logarithm algorithm, which breaks Diffie–Hellman and elliptic-curve cryptosystems, uses the identical QFT-based period-finding idea generalized to two registers. Beyond cryptanalysis, the QFT is the computational core of Quantum Phase Estimation, which itself underlies quantum simulation algorithms for estimating molecular ground-state energies in quantum chemistry, and appears inside the HHL algorithm for linear systems and various quantum machine learning proposals that rely on eigenvalue extraction. The Order-Finding Subroutine used inside Shor's algorithm is, concretely, phase estimation applied to a modular-multiplication unitary, with the QFT performing the final frequency extraction step. Any serious quantum computing hardware or compiler stack — from superconducting-qubit platforms to trapped-ion systems — includes an optimized QFT or approximate-QFT circuit generator as a standard library primitive, precisely because so many higher-level algorithms compile down to it.
Ask the tutor: How does the inverse QFT inside Quantum Phase Estimation turn an unknown eigenphase into a sharply peaked measurement distribution?
Is the Quantum Fourier Transform the same as the classical Fast Fourier Transform?
They compute the same mathematical object — the discrete Fourier transform — but operate in fundamentally different settings. The classical FFT transforms a list of numbers stored in classical memory using arithmetic operations. The QFT transforms the amplitudes of an -qubit quantum state using only quantum gates, exploiting superposition so the circuit never touches each amplitude individually. However, you cannot use the QFT to speed up an ordinary classical FFT task, because reading out all transformed amplitudes from a quantum state requires exponentially many measurements — the exponential speedup only pays off when the downstream measurement needs just a few bits of aggregate information, such as a period.
Why does the QFT circuit need controlled-phase gates rather than simpler single-qubit gates?
The product formula for shows that qubit 's output phase depends on bits — that is, on bits held by other qubits, not just its own. A single-qubit gate can only depend on its own qubit's state, so encoding a phase that depends on another qubit's bit value necessarily requires an entangling two-qubit gate, specifically a controlled operation. The controlled-phase gate is the minimal such gate: it applies a phase shift to the target only when the control qubit is , which is exactly what's needed to append one more bit to the target's accumulating binary-fraction phase.
What is the difference between the QFT and the inverse QFT, and why does it matter?
The inverse QFT reverses the transform, mapping — note the negative exponent. Algorithmically, phase estimation and order-finding apply the QFT to a register, but virtually all practical algorithms (Shor's algorithm included) actually require the inverse QFT at the final readout stage, because the state being decoded has phases of the form and inverting the phase relationship is needed to align periodicity with basis-state probability peaks. Circuit-wise, the inverse QFT is built from the same gates with all rotation angles negated, and is equally efficient at gates.
Does the QFT create entanglement?
It depends entirely on the input state. Applied to a computational basis state like , the output — as the product formula shows — is actually a tensor product of single-qubit states, so no entanglement is created despite looking complicated. Applied to a generic superposition input, however, the QFT typically does produce genuine multi-qubit entanglement in the output, because the controlled-phase gates correlate qubits whenever the input already has correlated amplitudes across basis states. This distinction matters for simulating the QFT classically: basis-state inputs are easy to simulate exactly (since the output stays a product state), while generic superposition inputs are not.
Why is the QFT considered the "workhorse" of quantum algorithms rather than a general problem-solver?
The QFT solves exactly one narrow mathematical task extremely fast: converting amplitude-domain structure into frequency-domain structure. It provides no advantage by itself, because reading out a full spectrum from measurement is exponentially expensive regardless of how the state was prepared. Its "workhorse" status comes from being the common final step in a two-part recipe: first encode a hard problem (factoring, discrete log, hidden subgroups, eigenvalue estimation) into periodic or phase-structured amplitudes using problem-specific unitaries, then apply the QFT to concentrate measurement probability on the periodic parameter you want. The hard, problem-specific engineering happens before the QFT; the QFT is the universal, reusable decoder.
What is the Approximate QFT and when should it be used?
The Approximate QFT (AQFT) is a circuit that discards controlled-phase gates whose rotation angle falls below a chosen threshold, since angles shrink exponentially fast as grows and contribute negligibly to the final state. This reduces gate count from to roughly for a target output fidelity within of the exact QFT. AQFT is preferred on noisy intermediate-scale quantum (NISQ) hardware, where every additional two-qubit gate adds decoherence risk, making the tradeoff between a small, controlled mathematical approximation error and a real reduction in physical error highly favorable.
How does the QFT connect to Quantum Phase Estimation and order finding?
Quantum Phase Estimation applies a unitary controlled by an ancilla register repeatedly, encoding an unknown eigenphase into the ancilla's amplitudes as across basis states . Applying the inverse QFT to this ancilla register then concentrates the measurement distribution sharply around the binary expansion of , exactly reversing the product-formula construction described in this article. The Order-Finding Subroutine used in Shor's algorithm is a specific instance: it estimates the phase of an eigenvalue of a modular-multiplication unitary, and that phase directly encodes the multiplicative order being sought, which continued-fraction expansion then extracts as an exact integer.