- Algorithms
- Also: QFT
Quantum Fourier Transform
The quantum analogue of the discrete Fourier transform, computed exponentially faster on a quantum computer and used as a core subroutine in Shor's algorithm and phase estimation.
The Quantum Fourier Transform (QFT) is the quantum analogue of the classical Discrete Fourier Transform (DFT). It transforms a quantum state’s amplitudes from a computational basis representation into a frequency-domain representation. The QFT is the key subroutine inside Shor’s algorithm, making it directly responsible for the exponential speedup that threatens RSA encryption. It also powers quantum phase estimation, a building block used across many quantum algorithms.
The speedup is striking: the classical Fast Fourier Transform (FFT) runs in operations. The QFT on qubits (representing amplitudes) uses only gates, equivalent to . This is exponentially fewer operations.
The details
The QFT maps a computational basis state to:
This is exactly the DFT formula, with the Fourier coefficients encoded in the amplitudes of the output quantum state.
The circuit implementing the QFT uses two types of gates:
- Hadamard gate : Applied to each qubit in sequence, it generates the required superposition
- Controlled phase rotation : , applied between pairs of qubits to encode the phase relationships
For a 3-qubit QFT, the circuit looks like:
q0 ──[H]──[R2]──[R3]──────────────────── SWAP ──
│ │
q1 ────────●──────────[H]──[R2]────────── SWAP ──
│ │
q2 ───────────────────●──────────[H]──── SWAP ──
(with SWAP gates at the end to reverse the qubit order)
The total gate count for qubits is two-qubit gates plus Hadamard gates, giving depth.
A key limitation: the QFT cannot be used to directly read out all Fourier coefficients, because measuring the output collapses the superposition to one result. The QFT is useful only as a subroutine within a larger algorithm that exploits its structure without measuring every output.
from qiskit.circuit.library import QFT
from qiskit import QuantumCircuit
# 4-qubit QFT
n = 4
qc = QuantumCircuit(n)
qc.compose(QFT(n), inplace=True)
print(qc.draw())
Why it matters for learners
The QFT is the reason Shor’s algorithm works. Period finding in the modular exponentiation function is the computational heart of integer factoring. The QFT extracts the period from the quantum state after computing in superposition. Without QFT, no efficient period-finding procedure exists.
Quantum phase estimation (QPE) is another critical application. QPE estimates the eigenvalues (phases) of a unitary operator , given access to a state that is an eigenstate of . QPE is used in quantum chemistry simulations to estimate molecular ground state energies, and it underlies many quantum machine learning proposals.
Understanding QFT requires being comfortable with complex exponentials, the Fourier basis, and controlled phase gates. These are the mathematical foundations of quantum signal processing. The QFT is also a canonical example of how quantum computation achieves its speed: not by evaluating outputs simultaneously, but by performing a structured transformation on the amplitudes of a superposition that encodes all inputs.
Common misconceptions
Misconception 1: QFT directly gives you the Fourier transform of any input data. Classical FFT takes a vector of numbers as input. QFT operates on a quantum state whose amplitudes are the input data. Loading classical data into quantum amplitudes (quantum state preparation) is itself a hard problem that often requires operations, eliminating the speedup for many data-loading tasks.
Misconception 2: QFT is operations, giving exponential speedup over FFT. The gate count is , which is exponentially better than FFT’s , but this comparison is subtler than it appears. QFT computes on quantum amplitudes; FFT computes on classical data. The exponential speedup applies only in contexts where the input is already in a quantum state (as in Shor’s algorithm), not for general Fourier transforms of classical data.
Misconception 3: QFT gives you all Fourier coefficients at once. After the QFT, the quantum state encodes all Fourier coefficients in superposition. Measuring collapses this to one coefficient. To read out all values, you would need measurements, recreating the state each time. The value of QFT lies in using the structured state as input to further quantum computation.