The QFT Defined
The quantum Fourier transform (QFT) is the quantum analogue of the discrete Fourier transform (DFT). It is one of the most important subroutines in quantum computing, underpinning Shor's factoring algorithm and quantum phase estimation.
The Definition
For an -qubit system with states, the QFT maps each computational basis state to
This looks exactly like the DFT — the -th input becomes a uniform superposition whose -th amplitude is the complex exponential . The difference is that the QFT acts on a quantum state and produces a quantum state; it uses quantum parallelism to handle all inputs simultaneously.
Because every amplitude has the same magnitude , the QFT does not change measurement probabilities for basis states — the encoding is entirely in the phases.
Product Representation
The summation formula can be rewritten as a tensor product over individual qubits. Writing in binary as , the QFT output is
where is the binary fraction .
This product form reveals the circuit structure: each qubit in the output needs a Hadamard (to create the superposition) followed by controlled-phase rotations that encode the appropriate binary fraction.
The Two-Qubit Circuit
For (so ), the product form gives
The circuit that implements this (with qubit 0 as the most significant bit) has four steps:
- H on qubit 0 — creates the superposition on the top qubit, which already carries the coarser phase.
- Controlled-phase CP() with control = qubit 1, target = qubit 0 — adds the additional phase to the component of qubit 0, building the full binary fraction .
- H on qubit 1 — transforms the second qubit into its own Fourier superposition.
- SWAP(0, 1) — reverses the output bit order so the result matches the standard QFT ordering (most significant output qubit first).
The controlled-phase gate applies the phase to the component. For step 2, so the accumulated phase on the branch of qubit 0 is , which is combined with the Hadamard contribution — precisely the required value.
The full circuit requires only gates for qubits, compared with operations for the classical FFT (where ), yielding an exponential speed-up for the Fourier subroutine itself.
Try it
Build the 2-qubit QFT. The grader checks the full unitary matrix of your circuit against the exact QFT matrix, so the circuit must be completely correct — a partial or empty circuit will fail.
Sign in on the full site to ask questions and join the discussion.