|q⟩ Bad Qubits

intermediate · Programming · The Quantum Fourier Transform

QFT on One Qubit

The Quantum Fourier Transform (QFT) is the quantum analogue of the discrete Fourier transform (DFT). For an nn-qubit register it maps computational basis states as

QFTnj=12nk=02n1e2πijk/2nk.\text{QFT}_n |j\rangle = \frac{1}{\sqrt{2^n}} \sum_{k=0}^{2^n - 1} e^{2\pi i j k / 2^n} |k\rangle.

Before building the full nn-qubit circuit it pays to study the smallest case: a single qubit.

The n = 1 case

Setting n=1n = 1 and N=21=2N = 2^1 = 2 the formula becomes

QFT1j=12k=01e2πijk/2k.\text{QFT}_1 |j\rangle = \frac{1}{\sqrt{2}} \sum_{k=0}^{1} e^{2\pi i j k / 2} |k\rangle.

Evaluating on each basis state:

QFT10=12(e00+e01)=12(0+1),\text{QFT}_1 |0\rangle = \frac{1}{\sqrt{2}}\bigl(e^{0}|0\rangle + e^{0}|1\rangle\bigr) = \frac{1}{\sqrt{2}}\bigl(|0\rangle + |1\rangle\bigr), QFT11=12(e00+e2πi/21)=12(0+eiπ1)=12(01).\text{QFT}_1 |1\rangle = \frac{1}{\sqrt{2}}\bigl(e^{0}|0\rangle + e^{2\pi i / 2}|1\rangle\bigr) = \frac{1}{\sqrt{2}}\bigl(|0\rangle + e^{i\pi}|1\rangle\bigr) = \frac{1}{\sqrt{2}}\bigl(|0\rangle - |1\rangle\bigr).

In matrix form, using the columns QFT10\text{QFT}_1|0\rangle and QFT11\text{QFT}_1|1\rangle:

QFT1=12(1111)=H.\text{QFT}_1 = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} = H.

The single-qubit QFT is the Hadamard gate — exactly the gate you already know.

Why the DFT viewpoint matters

The classical DFT maps a length-NN vector xx to its frequency components Xk=jxje2πijk/NX_k = \sum_j x_j e^{2\pi i jk/N}. The QFT does the same thing but encodes the 2n2^n amplitudes of a quantum state, operating in O(n2)O(n^2) gates rather than the classical fast Fourier transform's O(n2n)O(n \cdot 2^n) — an exponential speedup in circuit depth. For n=1n = 1 there is a single amplitude "frequency component" and one Hadamard suffices.

Try it

Implement the 1-qubit QFT. The grader checks the unitary matrix of your circuit, so an empty circuit will not pass.

Run your code to see the quantum state.

After running, the statevector panel shows both amplitudes equal to 1/20.7071/\sqrt{2} \approx 0.707 when started from 0|0\rangle — consistent with H0=+H|0\rangle = |+\rangle.

Sign in on the full site to ask questions and join the discussion.