Quantum Algorithms, One Query at a Time
Every algorithm here reuses the same oracle idea from Phase 6. Same engine underneath — what's new is what you do with the query.
Setup — one query decides constant vs. balanced
Input-register measurement probabilities
Run the circuit to see the verdict.
Why one query is enough. A constant function always returns the inputs to |00...0⟩ after the second Hadamard layer — perfect constructive interference. Any balanced function guarantees destructive interference at |00...0⟩, landing you somewhere else with certainty. No classical algorithm can tell these apart in one call; this one always can.
Setup — recover a hidden bit string in one query
(2–4 bits)
Input-register measurement probabilities
Run the circuit to recover the secret.
What's actually happening. This is Deutsch–Jozsa's exact circuit, run against an oracle built from a secret string instead of a generic balanced function. The measurement doesn't just say "balanced" — it reads the secret string straight off, in one shot, with probability 1.
Setup — 2-bit hidden period s (toy case)
Input-register measurement probabilities
Run to get a measurement outcome y.
Classical post-processing
Waiting for a measurement outcome…
Toy-scale honesty. Real Simon's algorithm needs several independent measurements to pin down s in general. At n=2 bits, a single nonzero outcome happens to be enough to solve the one linear equation over GF(2) — that's a simplification of scale, not of the underlying idea.
Setup — amplitude amplification
Measurement probabilities
Run to amplify the marked state.
Optimal stopping point. Iterating too little under-amplifies; iterating past the optimum starts rotating the amplitude back down. Optimal iteration count is roughly (π/4)·√N — for N=8 that's about 2, for N=4 about 1. Try sweeping the slider and watch the marked bar rise, peak, then fall.
Setup — transform a basis state into the frequency domain
Output amplitudes (magnitude · phase)
What to notice. QFT on a single basis state |k⟩ always produces an equal-magnitude superposition over every output state — all the information moves into the relative phases, which wind faster for larger k. This is exactly the phase pattern Shor's algorithm reads out in the next tab.
Order-finding for N = 15, a = 7 (the quantum core of Shor's algorithm)
4 counting qubits + 4 work qubits, simulated in full — 256 amplitudes. This is the real phase-estimation circuit, not a stand-in.
Counting-register measurement distribution
Classical post-processing
Run the circuit to see a sampled outcome and the factors it produces.
Scope of this demo. N=15 is the standard textbook case because it fits in a browser-simulable register. General Shor's needs a modular-exponentiation circuit built from arithmetic gates for arbitrary N — polynomial in the number of bits of N, but a substantially larger build than this toy case. What's simulated here is the genuine phase-estimation circuit against the real order-4 structure of 7 mod 15, not a hardcoded lookup.