The Bernstein-Vazirani Algorithm

Suppose a black box computes a secret dot product. Given a bit string xx, it returns f(x)=a⋅x  2f(x) = a \cdot x \bmod 2. A classical computer needs nn queries to learn all nn bits of the hidden string aa. It learns one bit at a time. The Bernstein-Vazirani algorithm recovers all of aa using a single quantum query. It exploits superposition and phase kickback. This turns an oracle into a direct readout of hidden structure. This is not merely a party trick. It is the cleanest illustration of a recurring theme in quantum algorithm design. Hidden classical information can sometimes be extracted with exponentially fewer queries. This works by encoding it into the phase of a superposition. The phases are then interfered back into readable amplitudes. The same mechanism — Hadamard transform, oracle phase kickback, Hadamard transform again — reappears, in generalized form, in The Deutsch-Jozsa Algorithm. It eventually blossoms into the period-finding ideas behind Simon's Algorithm and Shor's algorithm. The big picture is this: classical query complexity for learning a linear function is Θ(n)\Theta(n), provably. Each classical query yields at most one bit of information about aa in the worst case. Quantum query complexity for the exact same problem collapses to Θ(1)\Theta(1). Bernstein and Vazirani used this gap in 1997. They gave the first oracle separation between quantum and classical computation that was provable, rather than merely suspected. This generalizes naturally to a recursive version. That version separates quantum P\mathsf{P} from the polynomial hierarchy under an oracle. This article gives a complete derivation of the algorithm. It covers the exact state evolution through each Hadamard and oracle application. It includes a correctness proof via the Hadamard eigenvalue identity. It also provides a full complexity analysis and a worked numerical trace showing every amplitude. It closes with the historical context. It ends with the natural path forward toward algorithms that detect hidden periodicities rather than hidden linear strings.

Key takeaways
  • The problem: given oracle access to f(x)=a⋅x  2f(x) = a \cdot x \bmod 2 for secret a∈{0,1}na \in \{0,1\}^n, find aa.
  • Classically this needs exactly nn queries; quantumly it needs exactly 11.
  • The algorithm is Hadamard⊗n^{\otimes n} → phase oracle → Hadamard⊗n^{\otimes n} → measure.
  • Correctness follows from the identity H⊗n∣a⟩=2−n/2∑x(−1)a⋅x∣x⟩H^{\otimes n}|a\rangle = 2^{-n/2}\sum_x (-1)^{a\cdot x}|x\rangle, applied twice.
  • Phase kickback converts the oracle's action on an ancilla qubit into a global phase on the query register.
  • It is the direct ancestor of Simon's Algorithm and the template for phase-based hidden-structure algorithms.
The core insight

Encoding a hidden bit string into relative phases via one oracle call, then using a second Hadamard transform to convert those phases into a directly measurable computational-basis state, recovers the string exactly.

The idea

The Bernstein-Vazirani (BV) problem is stated over the field F2\mathbb{F}_2. Fix a hidden string a∈{0,1}na \in \{0,1\}^n. An oracle (black box) computes the Boolean function

f(x)=a⋅x  2=(∑i=1naixi)  2,f(x) = a \cdot x \bmod 2 = \left(\sum_{i=1}^n a_i x_i\right) \bmod 2,

for any x∈{0,1}nx \in \{0,1\}^n that we choose to query. The task is to determine aa exactly, using as few queries to ff as possible. Classically, the optimal strategy is to query the nn standard basis vectors e1,e2,…,ene_1, e_2, \dots, e_n (each having a single 11 in one position). Since f(ei)=aif(e_i) = a_i, each query reveals exactly one bit of aa, and nn queries are both necessary and sufficient — necessary because any function output is a single classical bit, and an information-theoretic counting argument shows nn bits of unknown information require at least nn single-bit-output queries in the worst case. Quantumly, we are given the oracle as a unitary rather than a classical subroutine. Two equivalent oracle conventions are used in the literature; we adopt the standard phase oracle obtained via phase kickback applied to the more primitive bit-flip oracle Uf:∣x⟩∣y⟩↦∣x⟩∣y⊕f(x)⟩U_f: |x\rangle|y\rangle \mapsto |x\rangle|y \oplus f(x)\rangle. Preparing the ancilla in the state ∣−⟩=12(∣0⟩−∣1⟩)|-\rangle = \frac{1}{\sqrt2}(|0\rangle - |1\rangle), an eigenstate of the XOR-flip with eigenvalue −1-1, converts the oracle into

Uf∣x⟩∣−⟩=(−1)f(x)∣x⟩∣−⟩=(−1)a⋅x∣x⟩∣−⟩.U_f |x\rangle |-\rangle = (-1)^{f(x)} |x\rangle |-\rangle = (-1)^{a\cdot x}|x\rangle|-\rangle.

The ancilla is unchanged and can be discarded; the oracle now acts as a phase on the query register alone. This is exactly the phase-kickback trick used in the Deutsch-Jozsa algorithm, applied here to a richer function class (a linear function rather than a constant/balanced promise). The entire task reduces to: prepare a uniform superposition over all xx, let the oracle imprint phases (−1)a⋅x(-1)^{a\cdot x}, and then find a way to read aa off directly. The second Hadamard transform performs exactly this readout.

How it works

The circuit uses nn query qubits initialized to ∣0⟩⊗n|0\rangle^{\otimes n} and one ancilla qubit initialized to ∣1⟩|1\rangle, which is Hadamard-transformed into ∣−⟩|-\rangle.

Step 1 — Initialization. Prepare

∣0⟩⊗n⊗∣1⟩.|0\rangle^{\otimes n} \otimes |1\rangle.

Step 2 — Hadamard on all qubits. Applying H⊗nH^{\otimes n} to the query register and HH to the ancilla gives

(12n∑x∈{0,1}n∣x⟩)⊗∣−⟩.\left(\frac{1}{\sqrt{2^n}}\sum_{x\in\{0,1\}^n} |x\rangle\right) \otimes |-\rangle.

Step 3 — Query the oracle once. The phase oracle acts as

Uf:∣x⟩∣−⟩↦(−1)a⋅x∣x⟩∣−⟩,U_f: |x\rangle|-\rangle \mapsto (-1)^{a\cdot x}|x\rangle|-\rangle,

giving the entangled-looking but actually product state

12n∑x(−1)a⋅x∣x⟩⊗∣−⟩.\frac{1}{\sqrt{2^n}}\sum_{x} (-1)^{a\cdot x}|x\rangle \otimes |-\rangle.

The ancilla decouples completely and is discarded (or measured and ignored).

Step 4 — Hadamard on the query register again. This is the crucial step. Using the identity (proved below)

H⊗n(12n∑x(−1)a⋅x∣x⟩)=∣a⟩,H^{\otimes n} \left(\frac{1}{\sqrt{2^n}}\sum_x (-1)^{a\cdot x}|x\rangle\right) = |a\rangle,

the query register collapses, after this unitary, to the single computational basis state ∣a⟩|a\rangle.

Step 5 — Measure. Measuring the query register in the standard basis yields aa with probability 11. ``` Algorithm BernsteinVazirani(oracle U_f, n) // U_f implements |x⟩|y⟩ -> |x⟩|y ⊕ (a·x mod 2)⟩ for hidden a ∈ {0,1}^n Input: black-box oracle U_f, size parameter n Output: the hidden string a ∈ {0,1}^n 1. Initialize register R of n qubits to |0...0⟩ 2. Initialize ancilla qubit A to |1⟩ 3. Apply H to A // A is now |-⟩ = (|0⟩ - |1⟩)/√2 4. Apply H to every qubit of R // R is now uniform superposition over all x 5. Apply U_f to (R, A) // phase kickback: R picks up phase (-1)^(a·x) 6. Apply H to every qubit of R again // R collapses (via interference) to |a⟩ 7. Measure R in the standard basis 8. Return the measured bit string as a ``` The single call to `U_f` in step 5 is the only query made. Everything else is local unitary manipulation and a final measurement — no repetition, no amplitude amplification, no error probability to amplify away.

Figure
Circuit diagram: one oracle query sandwiched between two Hadamard layers
|0⟩ q₁ |0⟩ q₂ |0⟩ q₃ |1⟩ anc H H H H U_f phase kickback H H H 📏 📏 📏 a₁ a₂ a₃ uniform superposition Σ|x⟩ ancilla discarded after oracle

Complexity & correctness

Query complexity. The algorithm makes exactly one call to `U_f`. This is optimal: any classical algorithm requires nn queries in the worst case, since each classical query to a Boolean function returns one bit, and there are 2n2^n possible values of aa, so at least log⁡2(2n)=n\log_2(2^n) = n bits of information — hence at least nn single-bit queries — are information-theoretically required to distinguish all cases (this can also be shown directly by an adversary argument on the standard basis queries). So the separation is 11 versus nn: exponential in query complexity, though the function class itself is extremely simple.

Gate complexity / time complexity. The circuit uses 2n2n single-qubit Hadamard gates plus one call to UfU_f (whose own gate cost depends on how ff is implemented, but is treated as a black box of unit cost in the query model). Total circuit depth is O(n)O(n) gates plus one oracle call, and O(n)O(n) qubits are used. Classically, computing aa via the standard-basis-vector strategy costs nn queries and O(n)O(n) total classical work, so BV also improves gate-level cost, not just query count, when the oracle's per-call cost is comparable in both models.

Space complexity. n+1n+1 qubits: nn for the query register, 11 ancilla. No auxiliary qubits beyond this are needed.

Correctness proof. The entire argument rests on one identity: for a,x∈{0,1}na, x \in \{0,1\}^n,

H⊗n∣x⟩=12n∑z∈{0,1}n(−1)x⋅z∣z⟩.H^{\otimes n}|x\rangle = \frac{1}{\sqrt{2^n}} \sum_{z \in \{0,1\}^n} (-1)^{x\cdot z} |z\rangle.

Apply this with x=0nx = 0^n during step 2, obtaining the uniform superposition 12n∑x∣x⟩\frac{1}{\sqrt{2^n}}\sum_x |x\rangle (since (−1)0⋅z=1(-1)^{0\cdot z}=1 for all zz). This confirms step 2. The oracle then multiplies the amplitude of each ∣x⟩|x\rangle by (−1)a⋅x(-1)^{a\cdot x}, giving the state

∣ψ⟩=12n∑x(−1)a⋅x∣x⟩.|\psi\rangle = \frac{1}{\sqrt{2^n}}\sum_x (-1)^{a\cdot x}|x\rangle.

Now apply H⊗nH^{\otimes n} again. Using linearity and the same Hadamard identity applied to each basis vector ∣x⟩|x\rangle inside the sum,

H⊗n∣ψ⟩=12n∑x(−1)a⋅x⋅12n∑z(−1)x⋅z∣z⟩=12n∑z(∑x(−1)(a⊕z)⋅x)∣z⟩.H^{\otimes n}|\psi\rangle = \frac{1}{\sqrt{2^n}}\sum_x (-1)^{a\cdot x} \cdot \frac{1}{\sqrt{2^n}}\sum_z (-1)^{x\cdot z}|z\rangle = \frac{1}{2^n}\sum_z \left(\sum_x (-1)^{(a\oplus z)\cdot x}\right)|z\rangle.

The inner sum over xx is a character sum over F2n\mathbb{F}_2^n. It equals 2n2^n if a⊕z=0na \oplus z = 0^n (i.e., z=az=a), and it equals 00 otherwise, because summing (−1)w⋅x(-1)^{w\cdot x} over all xx for any fixed nonzero ww gives exactly as many +1+1's as −1-1's by a pairing argument (flipping any coordinate ii with wi=1w_i = 1 flips the sign, and such an ii exists whenever w≠0w \neq 0). Therefore

H⊗n∣ψ⟩=12n⋅2n∣a⟩=∣a⟩.H^{\otimes n}|\psi\rangle = \frac{1}{2^n}\cdot 2^n |a\rangle = |a\rangle.

The query register is exactly ∣a⟩|a\rangle with probability 11 — not approximately, not with high probability, but exactly, assuming a perfect (noiseless) oracle and gates. Measuring in the standard basis therefore returns aa deterministically. This completes the correctness proof.

Tradeoffs and honesty about scope. The dramatic 11-vs-nn separation is a query complexity statement relative to a black-box oracle; it says nothing about the hardness of computing ff itself, since f(x)=a⋅xf(x) = a\cdot x is already trivially easy to compute classically once aa is known. The power of BV is a clean demonstration mechanism, not a source of practical algorithmic speedup for a "real-world" hidden linear-function-guessing task, because such a task rarely arises in isolation as an oracle. Its lasting importance is pedagogical and structural: it is the minimal example showing that a single quantum query can outperform any number of classical randomized queries on a well-defined problem, and the phase-interference recipe it introduces generalizes directly to problems, like Simon's problem, that do have significant downstream cryptographic implications.

Worked example

Take n=3n = 3 and hidden string a=101a = 101 (i.e., a1=1,a2=0,a3=1a_1=1, a_2=0, a_3=1), so f(x1x2x3)=x1⊕x3f(x_1x_2x_3) = x_1 \oplus x_3.

Step 1–2. Query register starts as ∣000⟩|000\rangle, Hadamard gives uniform superposition over all 88 strings, each amplitude 1/81/\sqrt8. Ancilla becomes ∣−⟩|-\rangle.

Step 3 (oracle). Each basis state ∣x⟩|x\rangle receives phase (−1)a⋅x=(−1)x1⊕x3(-1)^{a\cdot x} = (-1)^{x_1 \oplus x_3} (using the fact that a⋅x  2a\cdot x \bmod 2 equals x1⊕x3x_1 \oplus x_3 here). The table below lists every basis state and its phase after the oracle.

xxx1⊕x3x_1 \oplus x_3phase (−1)a⋅x(-1)^{a\cdot x}
0000+1
0011−1
0100+1
0111−1
1001−1
1010+1
1101−1
1110+1

So after step 3, the state (ignoring the decoupled ancilla and the global 1/81/\sqrt8 factor) is

+∣000⟩−∣001⟩+∣010⟩−∣011⟩−∣100⟩+∣101⟩−∣110⟩+∣111⟩.+|000\rangle -|001\rangle +|010\rangle -|011\rangle -|100\rangle +|101\rangle -|110\rangle +|111\rangle.

Step 4 (second Hadamard layer). Rather than expanding all 6464 cross terms, use the proven shortcut: H⊗3H^{\otimes 3} applied to 18∑x(−1)a⋅x∣x⟩\frac{1}{\sqrt8}\sum_x (-1)^{a\cdot x}|x\rangle must yield ∣a⟩=∣101⟩|a\rangle = |101\rangle exactly, by the identity proved above. We can spot-check this by verifying the amplitude of ∣101⟩|101\rangle directly:

amp(∣101⟩)=18∑x(−1)a⋅x(−1)x⋅101=18∑x(−1)(a⊕101)⋅x=18∑x(−1)0=18⋅8=1.\text{amp}(|101\rangle) = \frac{1}{8}\sum_x (-1)^{a\cdot x}(-1)^{x\cdot 101} = \frac{1}{8}\sum_x (-1)^{(a\oplus 101)\cdot x} = \frac{1}{8}\sum_x (-1)^{0} = \frac{1}{8}\cdot 8 = 1.

Since a⊕101=000a \oplus 101 = 000, every term in the sum is +1+1, giving amplitude exactly 11. Checking any other basis state, say ∣011⟩|011\rangle: a⊕011=110≠0a \oplus 011 = 110 \neq 0, so the character sum splits evenly between +1+1 and −1-1 and cancels to 00.

Step 5 (measure). The query register is ∣101⟩|101\rangle with certainty; measurement returns a=101a = 101, matching the hidden string, using only the single oracle call from step 3.

Figure
Amplitude flow for n=3, a=101, across the two Hadamard layers
Amplitude sign after oracle (before final H⊗3) 000 + 001 − 010 + 011 − 100 − 101 + 110 − 111 + After the second H⊗3, all amplitude constructively concentrates on |101⟩ — the hidden string a

Common pitfalls & traps

PitfallWhy it's wrongFix
Using the bit-flip oracle UfU_f directly without the ∣−⟩\lvert-\rangle ancilla trickWithout phase kickback, the oracle entangles the ancilla with the query register and the second Hadamard layer no longer isolates ∣a⟩\lvert a\rangleAlways initialize the ancilla to ∣1⟩\lvert1\rangle and Hadamard it to ∣−⟩\lvert-\rangle before querying
Forgetting to apply Hadamard to the ancillaThe oracle then just flips a target bit conditioned on f(x)f(x) with no phase effect at allExplicitly apply HH to the ancilla in step 3 of the circuit
Measuring the query register before the second Hadamard layerThe state ∑x(−1)a⋅x∣x⟩\sum_x (-1)^{a\cdot x}\lvert x\rangle looks uniform in measurement probability — every outcome is equally likely, giving no information about aaApply the second H⊗nH^{\otimes n} before measuring; the information is in the phase, not the pre-interference measurement statistics
Confusing BV with Deutsch-Jozsa and expecting only a promise-decision answerBV recovers the entire string aa, not a single bit like "constant vs. balanced"Recognize BV as DJ's linear generalization: same circuit, richer output
Assuming the 11-query bound survives with noisy or imperfect gatesThe exact cancellation relies on perfect phase interference; realistic noise reduces the success probability below 11State the deterministic result as an idealized, noiseless-oracle guarantee, and treat noisy hardware separately
Believing this proves quantum computers are faster for all problemsThe separation is specific to this promise/oracle structure; it says nothing about general-purpose speedupTreat BV as a structural, not universal, separation result

Pioneers & history

Origins · 1 minEthan Bernstein and how this was discovered
EB
Ethan Bernstein
born 1966 · American computer scientist, co-developer of the algorithm with Umesh Vazirani

UV
Umesh Vazirani
born 1957 · Professor of computer science at UC Berkeley, prominent figure in quantum complexity theory

The Bernstein-Vazirani algorithm was introduced as a query-complexity separation result, deliberately designed to be simpler than Simon's algorithm while still demonstrating a strict quantum advantage that could be proven rigorously rather than only conjectured. It built directly on the ideas of phase kickback and superposition query already present in the Deutsch-Jozsa algorithm, but sharpened the separation from a promise-decision problem into a full string-recovery problem with a clean 11-vs-nn query gap.

Origins · 1 minhow this was discovered
History
1985
— Deutsch introduces the first quantum algorithm exploiting superposition to gain query advantage over deterministic classical query.
1992
— Deutsch and Jozsa generalize this into the promise-based constant-vs-balanced separation, establishing phase kickback as a reusable technique.
1993
— Bernstein and Vazirani publish "Quantum Complexity Theory," introducing the recursive version separating quantum P\mathsf{P} from the polynomial hierarchy relative to an oracle.
1997
— The journal version formalizes the single-instance linear-string recovery algorithm now taught as the Bernstein-Vazirani algorithm.
1994
— Simon's algorithm appears shortly after, generalizing the phase-interference recipe to periodicity detection over Z2n\mathbb{Z}_2^n, directly inspiring Shor's factoring algorithm.

Where this matters

The Bernstein-Vazirani algorithm is used almost universally as the entry-level demonstration circuit on real quantum hardware and cloud quantum computing platforms, because it is small, deterministic in the ideal case, and immediately shows a measurable, checkable output that differs from any classical single-query strategy. Students and researchers routinely implement it on superconducting-qubit and trapped-ion cloud backends as a first "hello world" beyond single-qubit demonstrations, using it to calibrate readout fidelity and gate error by comparing the observed output distribution to the ideal deterministic spike at ∣a⟩|a\rangle. Pedagogically, it is the standard bridge between the constant/balanced promise of Deutsch-Jozsa and the group-structure hiding of Simon's algorithm, which in turn is the direct conceptual ancestor of the period-finding subroutine inside Shor's algorithm. The phase-kickback-then-interfere pattern it crystallizes — encode structure into relative phase via one oracle call, then use a change of basis (Hadamard, or more generally a quantum Fourier transform) to read that structure back out — is the single most reused architectural motif in query-based quantum algorithms, appearing again in amplitude estimation and in various quantum machine learning feature-map constructions. It also serves as a canonical example in complexity theory courses discussing oracle separations and the limits of what black-box lower bounds can and cannot say about real-world computational hardness.

Ask the tutor: How would the Bernstein-Vazirani circuit change if the hidden function included a constant offset, i.e., f(x)=a⋅x⊕bf(x) = a\cdot x \oplus b for an unknown bit bb?

Why does the algorithm need exactly one ancilla qubit and not more?

The ancilla's only job is to serve as an eigenstate of the underlying bit-flip oracle so that the oracle's action becomes a global phase rather than a bit flip on a separate register. A single qubit prepared in ∣−⟩=12(∣0⟩−∣1⟩)|-\rangle = \frac{1}{\sqrt2}(|0\rangle-|1\rangle) satisfies ∣y⟩↦∣y⊕1⟩|y\rangle \mapsto |y\oplus 1\rangle having eigenvalue −1-1 on this state, which is exactly what's needed since f(x)f(x) is a single bit. If ff returned multiple output bits, you might need a correspondingly sized ancilla register, but for a Boolean-valued f(x)=a⋅x  2f(x)=a\cdot x \bmod 2, one ancilla qubit suffices and using more would be wasted resources with no effect on correctness.

Is the Bernstein-Vazirani algorithm probabilistic, like Grover's algorithm?

No. Assuming a perfect, noiseless implementation of the oracle and gates, the algorithm is fully deterministic: the final measurement returns the exact hidden string aa with probability exactly 11, not with high probability. This distinguishes it from Grover's algorithm, whose success probability approaches but does not reach 11 and which requires O(2n)O(\sqrt{2^n}) queries rather than a fixed single query. The determinism here is a direct consequence of the exact cancellation shown in the correctness proof: the character sum over F2n\mathbb{F}_2^n evaluates to precisely 00 or 2n2^n, with no intermediate values, so there is no residual measurement uncertainty in the idealized model.

How does this algorithm differ from the Deutsch-Jozsa algorithm if they use the same circuit?

They share an identical circuit template — Hadamard, oracle, Hadamard, measure — but differ in what the oracle promises and what the output means. Deutsch-Jozsa promises ff is either constant or balanced and asks a one-bit decision; Bernstein-Vazirani promises f(x)=a⋅x  2f(x)=a\cdot x \bmod 2 for some fixed hidden aa and asks for the entire string aa. In fact, Bernstein-Vazirani can be seen as a generalization: the Deutsch-Jozsa decision is recoverable as a special case, since ff is constant if and only if a=0na = 0^n, which the BV circuit would report by returning the all-zero string.

Why can't a classical randomized algorithm beat n queries, even with error allowed?

Even allowing bounded error, information-theoretic arguments (formalized via Yao's minimax principle or direct entropy counting) show that distinguishing among 2n2^n equally likely candidate strings aa requires close to nn bits of information on average, and each classical query to a Boolean-valued ff yields at most one bit. Randomization can sometimes reduce worst-case query counts for other problems, but for this particular linear-recovery task the lower bound remains Ω(n)\Omega(n) even in the randomized bounded-error query model, because the outputs for different candidate aa's are not compressible into fewer than nn independent bits of evidence.

Does Bernstein-Vazirani give any real-world cryptographic or computational advantage?

Directly, no — the function a⋅x  2a\cdot x \bmod 2 is already trivial to evaluate and does not model any hard real-world problem, so the 11-vs-nn separation is a demonstration of quantum query power rather than a practical speedup for an existing application. Its real-world importance is indirect: the exact same phase-interference technique, generalized to detect a hidden period rather than a hidden linear string, becomes Simon's Algorithm, which in turn inspired the quantum Fourier transform machinery behind Shor's factoring algorithm — a result with direct implications for RSA and Diffie-Hellman cryptography.

What happens if the oracle is not exactly linear — does the algorithm silently give a wrong answer?

Yes, and this is an important caveat: the algorithm's guarantee is conditional on the promise that f(x)=a⋅x  2f(x) = a\cdot x \bmod 2 for some fixed aa. If ff is not of this form, the circuit still runs and still produces some measured output, but that output need not correspond to any meaningful "hidden string," since the derivation of H⊗n∣ψ⟩=∣a⟩H^{\otimes n}|\psi\rangle = |a\rangle relied entirely on the phase pattern being exactly (−1)a⋅x(-1)^{a\cdot x}. Unlike some algorithms that degrade gracefully, this one has no built-in mechanism to detect or flag a violated promise; verifying the promise, if needed, requires separate classical reasoning about how ff was constructed.

How does phase kickback in this algorithm relate to phase kickback used elsewhere, such as in Shor's algorithm?

The underlying mechanism is identical: a target qubit or register is prepared in an eigenstate of the operation the oracle performs, so that applying a controlled version of that operation leaves the eigenstate unchanged but multiplies the control register's corresponding amplitude by the eigenvalue. In Bernstein-Vazirani, the eigenstate is the single qubit ∣−⟩|-\rangle and the eigenvalues are ±1\pm 1. In Shor's algorithm's phase estimation step, the eigenstate is an eigenvector of modular multiplication and the eigenvalues are complex roots of unity, requiring a full quantum Fourier transform rather than a simple Hadamard layer to read out. Bernstein-Vazirani is the simplest nontrivial instance of this general phase-kickback-and-readout pattern.

Before this

Where this leads