Home / Quantum from Scratch / Ep 16

Quantum from Scratch · Episode 16 of 19

Quantum Fourier transform

Quantum Fourier Transform: How Shor's Algorithm Finds Factors

Go deeper

What I say in the video

Shor's algorithm doesn't try factors. It listens for a rhythm.

Pick a number, keep multiplying it, and the remainders repeat, like a song on loop.

Know the length of that loop, and the factors fall out.

Finding the loop is the hard part. That's the Quantum Fourier Transform's job.

Like a music app hearing a messy wave and finding the beat.

The quantum version makes the repeats interfere until the beat stands out, and you read that beat.

That's why it shines inside Shor's, not on its own.

In plain words

How does Shor's algorithm factor a number without trying factors? It finds a repeating loop, and the Quantum Fourier Transform is what finds that loop.

What this Short covers:

  1. Shor's algorithm turns factoring into period finding: keep multiplying a number and the remainders repeat.
  2. Example: 7^x mod 15 gives 7, 4, 13, 1, 7… a loop of length 4.
  3. Knowing the loop length gives the factors: gcd(7² − 1, 15) = 3 and gcd(7² + 1, 15) = 5, so 15 = 3 × 5.
  4. For large numbers, finding the loop is hard for classical computers. The Quantum Fourier Transform does it by making the repeats interfere until the period stands out.
  5. The QFT does not speed up ordinary Fourier transforms: measurement cannot read out all its outputs, so its advantage shows up inside algorithms like Shor's.
What I simplified

Fine print for the algorithms crowd: the "loop" is the period r of a^x mod N (here 7^x mod 15 = 7, 4, 13, 1, so r = 4). With an even period, gcd(a^(r/2) ± 1, N) gives the factors: gcd(48, 15) = 3 and gcd(50, 15) = 5. This works for most choices of a, not every one. "Hard part" means hard for a classical computer; in gate count the QFT is cheap and modular exponentiation is the costly quantum step. "Read that beat": one measurement gives a clue to r, a short classical step (continued fractions) finishes it, and sometimes you rerun. The music-app line is an analogy: beat trackers use Fourier-style analysis of the audio, not a QFT.

Sources (7)

One new quantum idea, every week

The next episode in your inbox, with its sources. Free, and one click to unsubscribe.