Skip to content
Quantum ComputingAN INTERACTIVE OPEN TEXTBOOK
charithj.com.au

How quantum algorithms use interference

A marked phase becomes a larger probability only through a carefully designed transformation.

16 min readDr. Charith Jayasekara↓ Chapter PDF
By the end, you’ll be able to
  • Trace one exact two-qubit Grover iteration.
  • Explain why too many amplification iterations reduce success.

Prepare the uniform state with amplitudes (1/2,1/2,1/2,1/2)(1/2,1/2,1/2,1/2). Suppose item 11 is marked. Its phase oracle produces (1/2,1/2,1/2,−1/2)(1/2,1/2,1/2,-1/2).

The mean amplitude is now 1/41/4. Diffusion reflects each amplitude a about the mean: a↦2(1/4)−aa\mapsto2(1/4)-a. The first three become 0 and the marked amplitude becomes 1. One ideal iteration therefore finds 11 with certainty in this special four-item case.

For one marked item among N, let sin⁡θ=1/N\sin\theta=1/\sqrt N. After k Grover iterations, success probability is

sin⁡2((2k+1)θ).\sin^2((2k+1)\theta).

This oscillates. Increasing k forever does not improve the result. A useful iteration count is near πN/4\pi\sqrt N/4, with rounding and marked-set assumptions handled carefully.

The model uses one marked basis state, exact phase marking and exact diffusion. It counts one oracle query per iteration but excludes the cost of constructing that oracle, preparing application data and executing fault-tolerant gates.

A classical simulator calculates all these amplitudes explicitly. Its wall-clock time is not a measurement of a quantum device’s runtime.

Challenge: for eight items, calculate the probabilities at k = 0, 1, 2 and 3. Compare them with the bars, then explain the drop after the best point using the angle formula.

Track the signed amplitudes, not just the marked bar

Section titled “Track the signed amplitudes, not just the marked bar”
WORKED DIAGRAM · F25One complete four-item Grover iteration
One complete four-item Grover iterationReal amplitudes begin at 1/2. The oracle negates the marked component. Reflection about the new mean, 1/4, leaves amplitude 1 on 11 and 0 elsewhere. Negative amplitudes are not negative probabilities.Uniform input000.5010.5100.5110.50 · signed scale −1 to +1Mark 11000.5010.5100.511-0.50 · signed scale −1 to +1Diffuse0000101001110 · signed scale −1 to +1
Real amplitudes begin at 1/2. The oracle negates the marked component. Reflection about the new mean, 1/4, leaves amplitude 1 on 11 and 0 elsewhere. Negative amplitudes are not negative probabilities.

The three panels show the initial uniform state, the phase-marked state and the state after diffusion. The oracle changes a sign without changing probabilities. Diffusion then converts that phase pattern into a different probability distribution. The algorithm needs both transformations. Stopping after the oracle would leave the chance of reading the marked label unchanged.

The reflection formula is linear in the amplitude vector, even though it refers to the vector’s mean. The mean is itself a linear function of the entries. Diffusion can also be written as a reflection about the uniform state. This perspective connects the arithmetic example with the two-dimensional rotation analysis used for larger search spaces.

With one marked item among eight, every initial amplitude is one over the square root of eight, approximately 0.353553. The oracle negates the marked entry. The new mean is three quarters of the original amplitude. Diffusion therefore maps each unmarked amplitude to half its original value and the marked amplitude to two and a half times its original value.

The marked probability after one iteration is consequently 25 thirty-seconds, or 78.125 percent. Each unmarked probability is one thirty-second. The eight probabilities sum to one. This is a useful independent calculation: it checks both the amplification and where the remaining probability goes, instead of checking only that the marked bar got taller.

After two iterations, the success probability is 121 one-hundred-twenty-eighths, approximately 94.53 percent. More iterations do not keep improving it. The state rotates in a plane spanned by the marked direction and the uniform unmarked direction. Continuing the rotation carries it past the marked direction and reduces success again.

The initial marked component has magnitude one over the square root of N. Define an angle whose sine is that magnitude. Each Grover iteration adds twice that angle, giving a marked probability determined by the sine squared of an odd multiple. Choosing the iteration count means stopping near a probability peak, not repeatedly measuring until the amplitude has “filled up.”

For several marked items, replace the initial marked probability with their fraction of the space. The rotation occurs between the uniform good and bad subspaces. If that fraction is unknown, a fixed schedule may overshoot. Counting, estimation and search variants address this uncertainty with different resource and success guarantees. The single-marked-item lab deliberately keeps that assumption explicit.

After measuring a candidate, evaluate the predicate classically to check whether it is marked. A failed candidate can trigger another independent run according to a planned strategy. This verification does not reveal the amplitudes, and it should not be confused with intermediate observation inside the amplification circuit.

The oracle and diffusion are abstractly simple in a tiny register. In a practical problem, reversible predicate evaluation, state preparation, workspace cleanup, precision and error correction may dominate. A quadratic query improvement is valuable only after those costs are compared with the best relevant classical method. Structure that makes a predicate easy to solve classically can also change the appropriate baseline from blind exhaustive search.

For two qubits and marked 11, predict results at zero, one and two iterations before revealing each setting. At zero iterations the marked probability is one quarter. At one it is one. At two it returns to one quarter, with a phase pattern that differs from the initial uniform vector. Equal success probabilities do not guarantee equal full states.

L06 · INTERACTIVE LABRuns on your device

Grover search explorer

A phase oracle marks one item; diffusion reflects amplitudes about their mean. Amplification can overshoot. Oracle construction and hardware costs are excluded.

Experiment controls

Predict the marked item’s success probability at this register size and iteration count. Explain an expected increase or decrease.

Record a prediction to enable the results.

Results are hidden.

Prepare your experiment using the controls. Record a prediction, then reveal the statevector or run the experiment.

Changing the preparation or circuit starts a new prediction.

MODEL · Ideal pure-state vector, complex double precisionORDER · q0 is the leftmost bit
Take it further

For four items, trace all amplitudes through one iteration. For eight, compare iterations 0–6 and explain the oscillation.

Then select three input qubits. Predict one iteration using the eight-item calculation, and compare two and three iterations with the rotation formula. Record both the marked probability and at least one unmarked amplitude. Changing the shot count affects sampling precision, while changing the iteration count changes the ideal state itself.

Practice: identify a premature measurement

Section titled “Practice: identify a premature measurement”

A proposed search procedure measures immediately after every phase oracle, then applies diffusion to the measured basis state. Explain why it is not the same algorithm and why the first oracle measurement cannot preferentially return the marked label.

Check your reasoning

The phase oracle preserves every basis probability, so the immediate measurement is still uniform on the first iteration. It also removes the coherent superposition that diffusion was designed to reflect. The later operation acts on a collapsed basis state rather than the phase-marked uniform state. Grover amplification requires the coherent oracle-and-diffusion sequence before the final measurement.

PAUSE & THINK

Among eight items with one marked, what is success after one ideal Grover iteration?

Choose your answer

Reference: IBM Quantum — Fundamentals of quantum algorithms.

ONE IDEA FURTHER

Ready for the next step?

Your progress stays in this browser.