Lesson 28 · 90 min · advanced
The Quantum Fourier Transform
The quantum Fourier transform on amplitudes is the discrete Fourier transform written as a unitary operator. This lesson proves its unitarity from the geometric series, derives the product representation by factoring the exponential, turns that formula into a circuit of Hadamard and controlled-phase gates plus SWAPs, bounds the error of the approximate QFT, inverts the circuit, works the case in full, and explains why the output amplitudes cannot be read out directly.
Prerequisites: The Deutsch–Jozsa Algorithm, Rotation Gates & ZYZ Euler Decomposition
Objectives and key results
Define on basis states and prove by summing the geometric series .
Derive the product representation of with binary fractions , explaining why integer parts of the phase drop out.
Build the QFT circuit from , and SWAP, count its gates against the operations of the classical FFT, and bound the error of the approximate QFT.
Construct the inverse QFT by reversing the gate order and negating the angles, with a proof of .
Compute the QFT matrix and both from the definition and from the product formula, and explain why Born-rule sampling limits what the QFT can deliver.
- definition · Quantum Fourier transform
- identity · Orthogonality of the characters
- theorem · Product representation
- algorithm · QFT circuit
- formula · Gate count
Definition and unitarity#
Definition
Quantum Fourier transform
Let . The quantum Fourier transform on qubits is the linear operator defined on the computational basis by and extended by linearity: with . Its matrix in the computational basis is with , a primitive -th root of unity. The matrix is symmetric, . Up to the sign convention of the exponent and the normalisation , the vector map is the classical discrete Fourier transform.
Orthogonality of the characters
For integers : .
Proof (6 steps)
- Step 1:Each term is the -th power of the single complex number , because .
- Step 2:If every term equals and there are terms.
- Step 3:would require , which is impossible for .
- Step 4:Multiplying by shifts every exponent by one; all terms cancel and only and remain.
- Step 5:Divide by , which is non-zero because .
- Step 6:is an integer and for every integer . Together with the case this is .
∎
- Step 1:Matrix product with .
- Step 2:Insert ; the complex conjugate flips the sign of the exponent; combine the exponentials.
- Step 3:Orthogonality of the characters (the lemma above).
- Step 4:For square matrices a left inverse is also a right inverse, so is unitary and preserves norms and inner products.
Result
Quick check
For , what is the probability of measuring after applying to the basis state ?
The product representation#
Definition
Binary expansion and binary fraction
Write in binary as , i.e. with the most significant bit. In this platform qubit holds and qubit holds . The binary fraction is . For example , , .
Product representation of the QFT
For and , where the -th factor acts on qubit . In particular is a product state for every basis input.
Proof (7 steps)
- Step 1:Binary expansion of the summation index , divided by .
- Step 2:The sum over is the same as the sum over all bits .
- Step 3:The exponential of a sum is the product , and ; each scalar factor is attached to the tensor factor it depends on (multilinearity of ).
- Step 4:The -th factor depends only on , so the nested sums distribute over the tensor product (expand the right-hand side to check). Then evaluate the two terms (phase ) and .
- Step 5:Split the binary expansion of at the position of the binary point after dividing by : terms with have a non-negative exponent of (an integer), terms with have exponents , which is the binary fraction by the definition with first index .
- Step 6:The integer part drops out because for every integer : only the fractional part of matters.
- Step 7:Substitute into the product. For (qubit ) the phase is ; for (qubit ) it is .
∎
Quick check
For and , the factor on qubit is . What is as a decimal?
The circuit and its cost#
Definition
Controlled phase gate
multiplies by and leaves the other basis states unchanged. It is symmetric in its two qubits, so "control" and "target" are interchangeable. With control and target , it multiplies the component by when the control is in the basis state . We write , so and .
Qubit after and the controlled phases
- Step 1:, , and .
- Step 2:Qubit is in the basis state , so multiplies the component of qubit by ; and .
- Step 3:By induction on : the control qubit holds , and adding appends the bit at position of the binary fraction.
- Step 4:After qubit holds exactly the last factor of the product formula; qubits are untouched because a controlled phase on a basis-state control returns the control unchanged.
- Step 5:The same argument on qubit (holding ), with controlled by qubit (holding ), . Qubits are still basis states when qubit is processed, which is why the qubits are treated in the order .
- Step 6:State after all qubits: these are the factors of the product formula in reverse order.
- Step 7:SWAPs reverse the qubit order, giving exactly the product representation. Since the circuit and agree on every basis state and both are linear, they are equal as operators.
Circuit · 3 qubits
The three-qubit QFT on : prepare the input, then . Every amplitude has modulus and amplitude has phase , e.g. .
Gate count: against for the FFT
- Step 1:Qubit receives one and the rotations , i.e. controlled phases; substitute .
- Step 2:Add the two counts. For : gates plus one SWAP, the seven gates of lab-qft3.
- Step 3:for , and the count is for . Each SWAP is three CNOTs, which changes only the constant.
- Step 4:Cooley–Tukey splits the sum into even and odd indices, , two half-size transforms plus combinations; unrolling levels of work each gives .
Result
Approximate QFT
Let be the QFT circuit with every rotation , , removed. Then in operator norm. With the error is at most , and the circuit uses gates.
Proof (4 steps)
- Step 1:Telescoping: ; the triangle inequality and with for unitaries bound each term by .
- Step 2:Removing replaces it by . and .
- Step 3:Each qubit loses at most the rotations with ; the geometric series bounds their total error.
- Step 4:Sum over the qubits and choose . Each qubit keeps at most gates, so the gate count is .
∎
Quick check
How many gates (counting , and SWAP) does the exact QFT circuit use on qubits?
The inverse QFT#
Adjoint of a product
For matrices of compatible size, . If every is unitary, the inverse of the circuit is the circuit .
Proof (3 steps)
- Step 1:Definition of the adjoint, the conjugate of a sum of products is the sum of the conjugated products, and reordering the scalar factors.
- Step 2:Induction on : apply the case with , , then the induction hypothesis.
- Step 3:removes the innermost pair repeatedly, so the reversed adjoint circuit is the inverse.
∎
Gate-by-gate adjoints: reverse the order and negate the angles
- Step 1:Both matrices are real and symmetric.
- Step 2:The adjoint of a diagonal matrix conjugates the diagonal.
- Step 3:The circuit read as the operator product ; by the lemma its adjoint is the reversed product of the adjoints, written here as an operator product (first gate applied = rightmost factor ).
- Step 4:Entrywise check: since is symmetric, , the same matrix with replaced by , consistent with negating every phase angle.
Result
Quick check
Which circuit implements on two qubits (gates listed in the order they are applied)?
Worked example: two qubits#
For , and , so . The exponent only matters modulo : , , , . Row lists : Each column has squared norm , and distinct columns are orthogonal, e.g. columns and : .
Unitary verified: (max deviation 0.0e+0)
from the definition
- Step 1:and .
- Step 2:, , , ; then write in binary. This is the second column of the matrix above.
from the product formula
- Step 1:Binary fractions of the bits of .
- Step 2:Product representation with : qubit carries and qubit carries ; and .
- Step 3:Expand the tensor product term by term. Both computations agree.
What the QFT does not give you#
Where the QFT helps: periodic states concentrate on multiples of
- Step 1:A state with period and offset , the kind of state produced by phase kickback in the period-finding and phase-estimation algorithms. It has equal amplitudes.
- Step 2:Apply the definition to each term and pull out the factor independent of .
- Step 3:The orthogonality lemma with in place of : equals exactly when divides , and otherwise its -th power is , so the geometric series vanishes.
- Step 4:The offset only contributes a phase, so the outcome is a uniformly random multiple of , from which is recovered with a few samples. The next lesson, quantum phase estimation, uses in exactly this way to read an eigenphase.
Quick check
For , apply to (period ). What is the probability of the outcome ?
import { cexpi, circuitUnitary, matrix } from '@/lib/quantum-simulator';
// Three-qubit QFT circuit, qubit 0 = most significant bit:
// on qubit q apply H, then CP(2 pi / 2^m) controlled by qubit q + m - 1 (m = 2 .. n - q); finally SWAP(0, n - 1).
const n = 3;
const N = 2 ** n;
const ops = [];
for (let q = 0; q < n; q++) {
ops.push({ kind: 'gate', gate: 'H', targets: [q] });
for (let m = 2; m <= n - q; m++) {
ops.push({ kind: 'gate', gate: 'CP', targets: [q + m - 1, q], params: [(2 * Math.PI) / 2 ** m] });
}
}
ops.push({ kind: 'gate', gate: 'SWAP', targets: [0, n - 1] });
const U = circuitUnitary({ version: 1, numQubits: n, numClbits: 0, ops });
// Definition: F[j][k] = e^{2 pi i j k / N} / sqrt(N).
const rows = [];
for (let j = 0; j < N; j++) {
const row = [];
for (let k = 0; k < N; k++) {
const w = cexpi((2 * Math.PI * j * k) / N);
row.push([w.re / Math.sqrt(N), w.im / Math.sqrt(N)]);
}
rows.push(row);
}
const F = matrix.fromRows(rows);
console.log('gates: ' + ops.length);
console.log('max|U - F| < 1e-12: ' + (matrix.maxAbsDiff(U, F) < 1e-12));
console.log('U is unitary: ' + matrix.isUnitary(U, 1e-12));
const e = matrix.get(U, 1, 1);
console.log('U[1][1] = ' + e.re.toFixed(4) + ' + ' + e.im.toFixed(4) + 'i');Expected output
gates: 7 max|U - F| < 1e-12: true U is unitary: true U[1][1] = 0.2500 + 0.2500i
References
- D. Coppersmith, "An approximate Fourier transform useful in quantum factoring", IBM Research Report RC 19642 (1994); arXiv:quant-ph/0201067.arxiv.org
- M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Information, 10th anniversary ed., Cambridge University Press (2010), §5.1 The quantum Fourier transform.doi:10.1017/CBO9780511976667
- J. W. Cooley and J. W. Tukey, "An algorithm for the machine calculation of complex Fourier series", Mathematics of Computation 19, 297–301 (1965).doi:10.1090/S0025-5718-1965-0178586-1
Hands-on labs
Build the three-qubit QFT
1 step · auto-gradedOpen labBuild the quantum Fourier transform on three qubits, , from Hadamard gates, controlled-phase gates and one SWAP, using at most seven gates.