Skip to content

The Quantum Fourier Transform, intuition first

The QFT is a frequency finder. Built by hand on three qubits, then shown pulling a frequency out of winding phases.

A row of small dials with hands winding around, an arrow labelled QFT, and the readout 001 labelled frequency.
The Fourier transform finds the frequency hidden in how the phases wind.

The Quantum Fourier Transform is the engine inside the most powerful quantum algorithms, the thing that makes Shor's factoring work and phase estimation tick. It is also, in most explanations, a wall of nested sums and product notation that tells you exactly how to compute it and nothing about why you would. I bounced off those formulas more than once. So this post does it the other way around, intuition first, formulas last or never. The one idea you need is this: the QFT finds frequencies hidden in phases. Here it is, built by hand.

The classical idea it comes from

Start with the thing it is named after. The ordinary Fourier transform takes a signal, a sound wave, say, and tells you which frequencies it is made of. You put in a complicated waveform and you get out a spectrum, a list of how much of each pure frequency is present. It is how an equaliser knows the bass from the treble, how your phone turns a recording into the notes that made it. A waveform goes in, the frequencies that compose it come out. That is the whole job of a Fourier transform: it changes your point of view from the signal itself to the frequencies inside it.

The Quantum Fourier Transform is the quantum version of exactly this. It takes a quantum state and reveals the frequencies hidden in the phases of its amplitudes. Same idea, new setting.

The reframe that makes it click

Two earlier posts set this up. From the complex numbers post, a phase is an angle, a direction on a circle. From the phase post, the information in a quantum state lives largely in its relative phases, the pattern of angles across the basis states. Put those together and here is the key picture. Imagine the amplitudes of a state laid out in order, each carrying a phase, and imagine those phases winding around as you go from one basis state to the next, like the hand of a clock advancing a fixed step each time. How fast they wind is a frequency. A state can have a phase pattern that turns slowly across its amplitudes, or quickly, and that winding rate is a real, hidden property of the state.

The QFT is the tool that reads that winding rate. It takes a state whose phases wind at some frequency and converts that frequency into a plain number you can measure. It turns how fast the phases turn into which basis state lights up. That is the entire intuition, and everything else is mechanics.

Building it by hand

The QFT circuit is built from pieces you mostly already know: Hadamards, controlled phase rotations, which are the controlled Z from the kickback post opened up to any angle, and a few swaps at the end. I am building it by hand rather than reaching for a library shortcut, both because it is more instructive and because the convenient built in QFT class has been deprecated since Qiskit 2.1 in favour of QFTGate, exactly the kind of deprecated path the version trap post warned about.

import numpy as np
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector

def qft(n):
    qc = QuantumCircuit(n)
    for j in reversed(range(n)):
        qc.h(j)                                   # spread this qubit into superposition
        for k in reversed(range(j)):
            qc.cp(np.pi / 2**(j - k), k, j)        # controlled phase rotations, finer and finer
    for i in range(n // 2):
        qc.swap(i, n - 1 - i)                      # reverse the qubit order at the end
    return qc

# QFT of |000> is an equal superposition of everything
qc = QuantumCircuit(3).compose(qft(3))
print(np.allclose(np.abs(Statevector(qc).data), 1 / np.sqrt(8)))   # True

Run it. The QFT of the all zeros state is an equal superposition over all eight outcomes, every amplitude the same size. That makes sense in the frequency picture: all zeros is the label zero, the forward QFT turns a label into a ramp winding at that frequency, and the ramp for frequency zero does not wind at all, so it is a flat, even spread, the same way a single spike at position zero spreads evenly over every frequency in the classical transform. Each piece of the circuit has a role. The Hadamards create the superposition, the controlled phase rotations stamp the frequency dependent phases, finer rotations for qubits further apart, and the swaps fix the ordering at the end.

The demo that shows what it really does

The flat result is a fine sanity check, but the frequency idea only truly lands when you feed in a state that does wind, and watch the QFT pull the frequency out as a number. The direction matters: the forward QFT turns a basis state into a winding ramp, so it is the inverse that turns a ramp back into the basis state whose label is the frequency. So prepare a state whose phases wind at frequency one, run the inverse QFT, and see where the weight concentrates.

from qiskit.primitives import StatevectorSampler

qc = QuantumCircuit(3)
for q in range(3):
    qc.h(q)                                 # start from an even superposition
for q in range(3):
    qc.p(2 * np.pi * (2**q) / 8, q)         # p is the phase gate: stamp a ramp winding at frequency 1
qc.compose(qft(3).inverse(), [0, 1, 2], inplace=True)  # read the frequency out

qc.measure_all()
counts = StatevectorSampler().run([qc], shots=1000).result()[0].data.meas.get_counts()
print(counts)   # {'001': 1000}

Run it. The result is 001, every single time, which is the binary for the number one. You stamped a phase pattern winding at frequency one across the state, applied the inverse transform, and out came the number one, cleanly, with certainty. That is the QFT doing its job: it took a frequency encoded invisibly in the phases and turned it into a definite basis state you can read. Change the winding rate and you get the corresponding number. The transform converts how fast the phases turn directly into which outcome you measure. Hidden frequency in, plain number out.

How the pieces conspire to read a frequency

It is worth slowing down on why that circuit does what it does, in words rather than formulas, because the mechanism is the same recurring idea dressed up. Think about what each qubit contributes. A frequency, a winding rate, is fundamentally about how a phase changes as you step through the basis states in order. The controlled phase rotations in the circuit are doing exactly this bookkeeping: each one stamps a phase that depends on the relationship between two qubits, and the rotations get progressively finer, by halves, as the qubits get further apart, because each qubit's phase moves in its own step size, the top qubit in the coarsest steps and the bottom qubit in the finest, and the rotation between two qubits has to match the ratio of their steps. It is the same way the digits of a binary number carry different weights, with each qubit responsible for a different scale of the winding.

The Hadamards put each qubit into the superposition that lets it participate, and the swaps at the end simply reverse the qubit order, fixing a convention so the answer comes out reading the right way round. Put together, the circuit takes a phase that winds across the input at some rate and redistributes the amplitudes so that all the weight piles up on the single basis state whose binary label is that rate. Constructive interference at the frequency, destructive everywhere else, the same interference machinery from the algorithm posts, arranged to detect a winding rate. You do not need to track the exact phases by hand to trust this. You verified it works above, the frequency one ramp came out as the number one. The circuit is just the interference pattern that turns winding into a number, built from gates you already know.

Why this is the engine of the powerful algorithms

Now the payoff, because this is why the QFT matters so much more than its modest circuit suggests.

It is the readout for phase estimation. The phase kickback post gestured at phase estimation without unpacking it, the technique of kicking a gate's eigenvalue back onto a register as a precise phase. The QFT is the second half of that technique: once the phase is sitting on the register, winding at a rate set by the eigenvalue, the QFT reads that winding rate out as a number. Kickback writes the phase, the QFT measures it. Together they are a machine for extracting the hidden phase of a quantum operation, digit by digit.

It is the heart of Shor's algorithm. Factoring a large number, the thing that genuinely threatens current encryption, reduces to finding the period of a function, which is to say its frequency. And finding a frequency is precisely what the QFT does. The quantum part of Shor's algorithm is, at its core, a QFT pulling a period out of a state. When people say quantum computers could one day break encryption, this transform is the specific reason, the engine that turns a periodic structure into a readable answer.

The reduction is worth a sentence more, because it shows how a number theory problem becomes a frequency problem. Shor's insight is that factoring a number can be turned into the task of finding how often a certain related function repeats, its period. You build a quantum state that secretly encodes that repeating structure as a phase that winds at a rate set by the period, exactly the kind of state the QFT was built to read. Then you apply the QFT, and out comes the period, the frequency of the repetition, as a number you can measure. From that period, ordinary classical arithmetic finishes the factoring. So the whole frightening capability, the one that could break the encryption protecting much of the internet, comes down to encoding a hidden period as a winding phase and using the QFT to read the winding rate. The transform you built by hand above, scaled up and embedded in a larger circuit, is the active ingredient. That is a striking thing to sit with: the same humble frequency finder, run on enough qubits, is what makes quantum a long term threat to cryptography.

It is where the most famous exponential speedups come from. The Grover post drew a sharp line: unstructured search gets only a quadratic speedup, because there is no structure to exploit, while the exponential speedups need a problem with hidden structure. The QFT is the tool that exploits one of the most important kinds of structure there is, periodicity. That is the difference between Grover's quadratic gain and Shor's exponential one. Grover searches blind. Shor, through the QFT, exploits a hidden frequency, and exploiting structure is what unlocks the exponential. The QFT is, in a real sense, the source of quantum computing's most dramatic advantages.

The honest catch

One important limit, so you do not oversell it to yourself. The QFT is efficient, it takes only about n squared gates to transform n qubits, where the classical fast Fourier transform would need far more operations to handle the exponentially many amplitudes those qubits represent. That efficiency sounds like it should make the QFT a drop in replacement for classical Fourier analysis, and it is not, because of measurement. After the QFT, you cannot read out all the amplitudes, the whole spectrum. A measurement gives you a single outcome. So the QFT is only useful when the answer you want is a single frequency or period, one number, not the entire spectrum laid bare. That is exactly why it powers period finding, where there is one period to extract, and why it is not a general purpose fast Fourier transform for data. It is a frequency finder for problems with one frequency to find, and within that niche it is extraordinarily powerful.

A quick test before you move on

Close this and answer in your own words.

In one sentence, what does the QFT do? If finds the frequency hidden in a state's phases is not close to your answer, reread the reframe section.

In the demo, you stamped a phase ramp at frequency one and got the outcome 001. What does that tell you the transform is converting into what? If a winding rate into a number is not your answer, revisit the demo.

And why is the QFT the engine of exponential speedups while Grover is only quadratic? If your answer does not connect the QFT to exploiting structure, periodicity, reread the why it is the engine section, because that contrast is the heart of it.

Where I am learning it

Free. The QFT is in every quantum algorithms course and the IBM Quantum materials, but most presentations lead with the formula, and I would suggest finding one that leads with the Fourier intuition instead, since the connection to the classical transform is what makes it sensible. 3Blue1Brown has a wonderful video on the classical Fourier transform that is worth watching first, because the quantum version is genuinely the same idea. As always, the transform did not click until I built it by hand and watched a frequency ramp turn into the number one on my own machine.

The monster was a frequency finder

The QFT looked, for a long time, like the most intimidating object in quantum computing, a thicket of sums and products guarding the algorithms I most wanted to understand. Underneath the notation it is one clean idea: it finds the frequency hidden in a state's phases, turning how fast those phases wind into a number you can read.

That one job, humble when you state it plainly, is the engine inside phase estimation and Shor's algorithm, the source of quantum computing's best known exponential advantages, the specific reason factoring and encryption keep coming up. The formulas describe how it works. The intuition tells you what it is for, and once you have the intuition, the formulas stop being a wall and start being a recipe. A frequency finder. That is all it ever was, and it is enough to power the most remarkable algorithms in the field.