Quantum Fourier transform
Quantum Fourier Transform (QFT) is the unitary transform on an n-qubit register that maps computational-basis states to equal-weight superpositions with phase factors e^{2πi·(jk)/N}; it is a key subroutine in algorithms like Phase Estimation and Shor's algorithm.
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
QFT is the quantum analogue of the Discrete Fourier Transform (DFT). Engineers use QFT as a subroutine in higher-level quantum algorithms (for example, Phase Estimation and Shor's algorithm for factoring). Knowing QFT and its efficient circuit decomposition helps design quantum algorithms and reason about resource costs (number of qubits and gates).
Key ideas
Definition: F_N(|k>) = (1/√N) Σ_{j=0}^{N-1} e^{2πi j k / N} |j>. This defines a unitary matrix with elements F_{j,k} = (1/√N) e^{2πi j k / N}.
Assumptions: we assume the computational basis is the standard basis |0>, |1>, ..., |N−1> (binary encoding across n qubits). All phases are dimensionless (unitless complex numbers). The transform is linear and unitary (F_N† F_N = I).
Matrix form and unitarity: The matrix of F_N is the N×N complex matrix with entries F_{j,k} given above. To show unitarity, check F_N F_N† = I using orthogonality of complex exponentials (Σ_{k} e^{2πi (j−j')k / N} = N δ_{j,j'}).
Circuit decomposition (standard, exam-asked derivation): QFT on n qubits can be implemented with O(n^2) elementary gates (Hadamard and controlled phase-rotation gates) and final qubit swaps. The usual decomposition steps are:
- Index input bits as x_{n-1} (most significant) down to x_0 (least significant).
- Show that F_N maps computational basis |x_{n-1}...x_0> to a product state of single-qubit rotations (after final bit-reversal, i.e., in most-significant-first output order):
- Output qubit j (starting from most-significant output) is prepared as (|0> + e^{2πi·0.x_{n-1}x_{n-2}...x_{n-j}} |1>)/√2, where 0.x_{n-1}x_{n-2}... is the binary fraction x_{n-1}/2 + x_{n-2}/4 + ... .
- Implement each output qubit by: apply H on the corresponding input qubit, then apply controlled rotations R_k from less-significant qubits (R_k = diag(1, e^{2πi / 2^k})) conditioned appropriately. Repeat for each qubit, then swap qubit positions to reverse bit order.
- Total gates: about n Hadamards and (n(n−1))/2 controlled rotations; swaps add ⌊n/2⌋ two-qubit swaps. Thus naive gate count is O(n^2).
Controlled phase rotation R_k — defined on one qubit as R_k = |0><0| + e^{2πi/2^k} |1><1| (a single-qubit phase gate). When controlled by another qubit, it applies that phase only if control is |1>. Note: some texts write R_k = diag(1, e^{2πi/2^k}).
Inverse QFT — the Hermitian adjoint of QFT: F_N† = F_N^{-1}. It is implemented by running the QFT circuit in reverse, replacing each controlled R_k by its inverse (R_k† = R_k^{-1} = diag(1, e^{−2πi/2^k})) and applying Hadamards and swaps in reverse order.
Complexity and approximation: exact QFT uses Θ(n^2) two-qubit gates, but an approximate QFT can drop small-angle controlled rotations to reduce gate count to O(n log n) for constant precision, or to O(n log(n/ε)) to achieve error ≤ ε. Dropping a controlled rotation with very small angle introduces a bounded approximation error (see, e.g., Coppersmith 1994; Nielsen & Chuang, Sec. 5.1, for explicit bounds).
Diagram to draw for exams: draw n horizontal lines (qubits) labelled q_{n-1} (top) to q_0 (bottom). On q_{n-1} place H then controlled-R_2 from q_{n-2}, controlled-R_3 from q_{n-3}, ...; then on q_{n-2} place H then controlled-R_2 from q_{n-3}, ...; continue and finally draw swap gates between q_{n-1} and q_0, q_{n-2} and q_1, etc. Label each controlled rotation with its R_k.
Formulas
F_N(|k>) = (1/√N) Σ_{j=0}^{N-1} e^{2πi j k / N} |j> — where N = 2^n is the dimension, |k> is computational basis state, phase is unitless, applies to n-qubit registers.
(F_N)_{j,k} = (1/√N) e^{2πi j k / N} — matrix element at row j, column k; unitless complex number.
R_k = diag(1, e^{2πi / 2^k}) — single-qubit phase rotation with dimensionless phase; used inside controlled rotations.
F_N† = F_N^{-1} — the inverse (adjoint) of QFT; unitary inverse, applies when you need inverse transform.
Gate count (standard): ≈ n Hadamards + n(n−1)/2 controlled-R_k + ⌊n/2⌋ swaps — counts gates in the textbook decomposition; units: gate counts (dimensionless), applies for exact QFT.
Note: all phases (exponent arguments) are dimensionless; no SI unit. Use N = 2^n where n is number of qubits.
Worked examples
Example 1 — QFT on 2 qubits (N = 4), compute F_4(|01>) and show circuit steps.
- Write definition: F_4(|k>) = (1/2) Σ_{j=0}^{3} e^{2πi j k / 4} |j>.
- Put k = 1 (|01>), compute phases j = 0..3:
- j=0: e^{2πi·0·1/4} = 1
- j=1: e^{2πi·1·1/4} = e^{πi/2} = i
- j=2: e^{2πi·2·1/4} = e^{πi} = −1
- j=3: e^{2πi·3·1/4} = e^{3πi/2} = −i
- So F_4(|01>) = (1/2)(|00> + i|01> − |10> − i|11>). Final answer (state vector): (1/2)[1, i, −1, −i]^T.
Circuit decomposition (show on paper): draw two wires q1 (top) and q0 (bottom). For input |01> (so q1=0, q0=1):
- Apply H on q1: creates (|0> + |1>)/√2 on q1.
- Apply controlled-R_2 from q0 to q1: since q0 is |1>, q1's |1> component gains phase e^{2πi/4} = i. So q1 becomes (|0> + i|1>)/√2.
- Apply H on q0: transforms |1> to (|0> − |1>)/√2.
- No further controlled gates remain. Finally swap q1 and q0 (gives correct output order). If you multiply out, you get the same amplitudes as the formula above.
Example 2 — Decomposition for 3-qubit input |001> (show phases and how QFT breaks into single-qubit rotations).
- Index bits: x2 x1 x0 = 0 0 1 (x2 MSB).
- Binary fractions:
- For output qubit 0 (top): 0.x2 x1 x0 = 0.001 (binary) = 1/8.
- For output qubit 1: 0.x1 x0 = 0.01 = 1/4.
- For output qubit 2 (bottom): 0.x0 = 0.1 = 1/2.
- So QFT produces (before swap): (|0> + e^{2πi·1/8}|1>)/√2 ⊗ (|0> + e^{2πi·1/4}|1>)/√2 ⊗ (|0> + e^{2πi·1/2}|1>)/√2. This equals (1/√8) Σ_{j=0}^{7} e^{2πi·j·1/8} |rev(j)>, so after swapping the qubits (bit-reversal) it matches the definition. Final answer: product-state form above; swapping the qubits yields the usual ordering.
Example 3 (short conceptual): approximate QFT — explain trade-off. If you drop controlled rotations whose angles are smaller than a threshold, the circuit depth reduces but the output state is only approximately F_N|ψ>. The approximation error (operator norm or trace distance) can be bounded; the bound depends on how many smallest rotations are removed (see, e.g., Coppersmith 1994; Nielsen & Chuang, Sec. 5.1, for explicit inequalities).
Common mistakes
- Writing R_k with wrong exponent: R_k should use 2πi/2^k, not 2πi/k.
- Thinking QFT always requires O(N^2) gates; correct is O(n^2) gates for n qubits, where N = 2^n.
- Forgetting that phases are unitless complex numbers (no SI units).
For your exam
Kinds of questions:
- Definitions: state the QFT and its matrix elements; define R_k.
- Short notes: circuit decomposition and gate counts; compare QFT vs classical DFT complexity.
- Derivations: show F_N is unitary; derive product-state decomposition (0.x... binary fraction form) step by step; derive circuit from that decomposition.
- Numericals: compute F_N(|k>) for small n (examples above). Carry out amplitude calculations and give final state.
- Diagrams: draw QFT circuit for n qubits, label Hadamards, controlled-R_k gates and final swaps.
What a full-marks answer includes:
- Precise definition of F_N and matrix elements.
- Proof or clear argument of unitarity (use orthogonality of exponentials).
- Correct decomposition into H and controlled-R_k gates, correct gate-count estimate, and correct description of swaps.
- For numericals, explicit calculation of complex amplitudes and final normalized state.
Quick check
- What is the matrix element (j,k) of F_N?
- For n=2, what is F_4(|10>) in amplitude form?
- What gate implements a conditional phase of e^{2πi/8} on the target when control is |1>? Answers: (1) (1/√N) e^{2πi j k / N}. (2) F_4(|10>) = (1/2)(|00> − |01> + |10> − |11>) (check signs from e^{2πi j·2/4}). (3) A controlled-R_3 gate where R_3 = diag(1, e^{2πi/2^3}) = diag(1, e^{2πi/8}).
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?