The first clean quantum win. There’s a hidden function and you must decide a single global fact about it. Classically you poke it twice; quantum mechanics answers in exactly one query — by making the wrong answer cancel itself out.
↩ before you start · keep these handy
·From Ch. 5: H sends |0⟩↔|+⟩, and a second H undoes the first.
·From 0.2: a relative minus sign is a phase — invisible to a 0/1 read until an H converts it to amplitude.
·From 8a: a circuit holds one evolving superposition; interference is what extracts an answer.
🔑 symbol decoder · every new mark, in plain words
fthe hidden yes/no function sealed inside the box.constant / balancedsame answer for every input vs yes for exactly half the inputs.oraclethe black box that applies f — you may use it, not look inside.phase kickbackthe oracle stamping (−1)f(x) onto a branch instead of flipping a bit.(−1)f(x)+1 when f(x) = 0, −1 when f(x) = 1.queryone use of the oracle — the resource we are counting.
feel
One weighing, not two
A black box computes a yes/no function f. You’re promised it’s one of two kinds: constant (same answer for every input) or balanced (yes for exactly half the inputs). You don’t care what the answers are — only which kind of box it is. Classically you must feed it at least two different inputs and compare. The quantum trick feeds it a superposition of inputs at once, then lets interference reveal the global pattern in a single shot.
🪙 everyday picture
You're handed a row of coins, either all the same face (constant) or exactly half-and-half (balanced). You don't care which coins are which — only which of the two situations you're in. Flipping each over to check takes many looks. The quantum trick is like laying a clever stencil over the whole row at once: all-alike reads blank, mixed reads marked. One glance settles it.
recapYou must decide one global fact — constant or balanced — not read the function's individual values.
play
Set the box, run it once
Here’s the one-bit version (Deutsch). Choose what the box does on each input. The oracle stamps a phase(−1)f(x) onto each branch; a final H makes the branches interfere. Read the query qubit: 0 means constant, 1 means balanced — guaranteed, every time.
▸ Deutsch oracle1 query
define the box:{{ kindLabel }}
branch |{{ b.x }}〉
{{ b.sign }}
phase (−1)f({{ b.x }}) = {{ b.sign }}1
query qubit after final H
|0〉
{{ p0 }}%
|1〉
{{ p1 }}%
reads {{ readout }} → {{ kindLabel }}
classical queries2
quantum queries1
for an n-bit box: classical worst case 2n−1+1, quantum still 1.
recapThe oracle stamps a phase on each branch; one final H collapses “same or different?” into a single bit.
math
Phase kickback, then interference
Start the query qubit in |+〉 = (|0〉+|1〉)/√2. The oracle leaves each branch alone but multiplies it by (−1)f(x) — the phase kickback. The state becomes:
( (−1)f(0)|0〉 + (−1)f(1)|1〉 ) / √2
f constant ⇒ both signs equal ⇒ state = ±|+〉 ⟶H|0〉
f balanced ⇒ signs differ ⇒ state = ±|−〉 ⟶H|1〉
The final H turns “are the two phases the same or different?” into a single definite bit. When they’re equal the |1〉 route cancels; when they differ the |0〉 route cancels. One query, zero ambiguity.
✎ worked example · a box with f(0)=1, f(1)=1
1.signs: (−1)f(0) = −1, (−1)f(1) = −1
2.state = (−|0⟩ − |1⟩)/√2 = −|+⟩ (signs equal)
3.final H: H|+⟩ = |0⟩ (the overall − is a global phase, ignorable)
recapPhase kickback + interference: equal phases cancel the |1⟩ route, opposite phases cancel the |0⟩ route.
⚠ common misconception
“It evaluated f on every input at once — that’s the speedup.” It did put every input into the superposition, but you can never read them out — one measurement gives one bit. If you wanted the actual table of f values, the quantum box gives you no advantage at all.
The win is narrower and sharper: it answers one global question — “constant or balanced?” — that secretly depends on all the values together, and arranges for everything irrelevant to interfere away. Every quantum algorithm ahead is a more elaborate version of this same move.
✓ you can now
✓state the constant-vs-balanced promise and why classical needs at least 2 queries
✓explain phase kickback and how the final H reads it out
✓run Deutsch on a chosen box and predict its single-query result