Algorithmic Primitives
Quantum algorithms reuse a small collection of ideas: prepare a state, access a function coherently, encode information in relative phases, interfere amplitudes, amplify a desired outcome, and extract a useful result. These are algorithmic primitives. Learning how they fit together makes apparently different algorithms easier to recognize and understand.
A primitive does not by itself establish a speedup. Its input must be available, its output must suit the next step, and its cost must be included. The final result may be a classical answer or a prepared quantum state for further processing.
Helpful background. The circuit model explains registers and measurements; probability amplitudes explains interference; universal gate sets explains how abstract operations are synthesized.
State preparation and coherent access
Section titled “State preparation and coherent access”Hadamards cheaply prepare a uniform state on basis labels:
One measurement still returns only one label. More general preparation, , can be expensive: amplitudes stored in a classical list are not automatically available as a quantum state.
A reversible Boolean query acts as
With target , it correlates the registers:
With target , it instead gives a clean phase pattern,
The target returns to its original state. This is phase kickback, not a measurement of all function values. An actual reversible implementation may use temporary workspace, which must be restored if it would otherwise distinguish interfering paths. Quantum oracles explains when inverse, controlled or powered queries are available; those capabilities do not follow from the name of an operation alone.
Turning relative phase into probability
Section titled “Turning relative phase into probability”The simplest interference example is . The first Hadamard creates two alternatives, the middle gate changes their relative phase, and the final Hadamard recombines them:
Therefore and . Before the last Hadamard, measuring in the computational basis would give equal probabilities for every . The useful information lies in the relative phase until the readout basis is changed.
The final Hadamard converts relative phase to a measurable probability. At , destructive interference eliminates the zero outcome and the one outcome is certain.
For many qubits, the Walsh–Hadamard transform gives
Here the dot product is modulo two. Useful phases reinforce some outputs and cancel others while conserving total probability. Deutsch–Jozsa detects the constant-versus-balanced promise, Bernstein–Vazirani recovers a linear character, and Simon combines related interference with sampling and classical linear algebra.
Fourier transformation and phase estimation
Section titled “Fourier transformation and phase estimation”The quantum Fourier transform maps
For , its usual exact circuit has gates in a gate set with the required controlled rotations; synthesis into a fixed alphabet adds precision-dependent cost. It transforms amplitudes but does not output a classical list of all Fourier coefficients. The classical FFT has a different input and output task.
Phase estimation combines this transform with controlled evolution. Let and use controls, . After controlled powers and inverse Fourier decoding, the control state for eigenphase is
If , only survives. Otherwise several outcomes have nonzero amplitudes. For an input in an orthonormal eigenbasis, the joint state and measured law are
Finite precision does not literally return an eigenstate index: nearby phases can give overlapping outcome distributions. Even ideal phase measurement preserves coherence within a degenerate eigenspace. Overlap with the desired eigenspace controls its chance of appearing.
Controlled powers require base- uses if built by repetition. Treating each power as one query changes the access model. Phase estimation develops its precision and confidence bounds; Shor’s algorithm combines efficient modular powers with classical number-theoretic recovery.
Amplifying a selected subspace
Section titled “Amplifying a selected subspace”Let project onto useful outcomes and assume . Write
The normalized vectors and lie in the good and bad subspaces. Define the two reflections
Then rotates their plane and gives
This explicitly fixes the reflection sign and execution order. The endpoints are separate: is already successful, while has no good component to amplify. For a small nonzero , ordinary independent preparation needs mean trials; suitable coherent amplification uses preparation, inverse and reflection calls. It requires coherent access to all those operations. Unknown success probability needs an appropriate schedule, since too many iterations can lower success again.
Amplitude amplification explains schedules and exact variants. Grover search is its uniform-state example; amplitude estimation estimates by analyzing the rotation phases.
Hamiltonian and matrix access
Section titled “Hamiltonian and matrix access”In units , Hamiltonian simulation approximates for a specified Hermitian matrix or a carefully defined operator problem. Access might mean local terms, sparse-matrix queries, a sum of implementable unitaries, or a block encoding. Its cost depends on that access, time and error tolerance. Producing uncontrolled evolution does not automatically provide its controlled version; a later phase-estimation algorithm needs that additional capability.
The Hamiltonian simulation algorithms page compares methods, while Hamiltonian simulation connects norm errors to physical outputs. Simulating a state is different from reconstructing its entire wavefunction; observable estimation still needs measurements.
For a general matrix , an block encoding is a unitary whose all-zero ancilla block obeys
In the exact case and . Applying and measuring zero ancillas yields with probability . The normalized output exists only if that probability is positive.
For example, take , and . Success is and the conditional state is . Increasing to two leaves that state unchanged but reduces success to . Preparing the input and building may cost more than the subsequent manipulation.
Polynomial transformations of a signal
Section titled “Polynomial transformations of a signal”Quantum signal processing interleaves a signal unitary with chosen phase rotations. A common one-qubit signal is
Products of and produce polynomial responses with degree, parity and unitarity constraints. For instance, with two signal calls and no phases, . This is a bounded even response, not an arbitrary degree-two function. The number of signal calls is tied to polynomial degree.
For a block encoding of , singular-value transformation acts on normalized singular values . Odd polynomial transformations map right singular vectors to left ones; even transformations act within a right or left singular space, according to the chosen projected block. Zero singular spaces and also matter. One should not replace this by a generic eigenvalue formula for a non-Hermitian matrix.
Hamiltonian evolution requires the signed eigenvalues of a Hermitian operator. Its response has both even and odd parts; it is not one fixed-parity real singular-value polynomial. Appropriate signal-processing constructions combine the needed responses. See block encodings and QSVT for the exact admissibility rules, and qubitization and quantum signal processing for Hamiltonian-specific constructions.
Reciprocal approximations need a spectral interval excluding zero, and sharp filters need a resolved transition region. These restrictions determine degree and retain conditioning, gap and normalization costs. Quantum linear algebra and quantum walks show how the primitives fit complete tasks.
Measurement, postselection and total cost
Section titled “Measurement, postselection and total cost”A measurement outcome may have several unobserved Kraus labels:
Keeping only chosen outcomes is postselection. For repeatable preparations, independent trials need mean attempts per success. Repeating an unknown consumed input requires a separate way to restore it. If the whole preparation, its inverse and a success reflection are coherently available, amplitude amplification can improve the dependence toward . A classical success flag alone does not supply those operations.
Aaronson’s theorem concerns a complexity model that conditions on a nonzero-probability event without charging physical repetitions. It does not turn exponentially rare experimental outcomes into an efficient procedure. Quantum instruments explains outcome probabilities and conditional states.
When composing primitives, keep query calls, gate synthesis, preparations, measured samples and classical work distinct. Approximations must be controlled in a metric that bounds the final result. Coherent errors need not cancel, and postselection can magnify errors when acceptance is small. A benchmark should compare the same input access, output, accuracy and success probability for both methods.
Exercises
Section titled “Exercises”Superposition is not bulk readout
Section titled “Superposition is not bulk readout”Prepare and measure in the computational basis. What is the probability of observing a specified string ? How many independent shots are expected before that string appears?
Solution
Every basis state has amplitude , where , so
Independent repetition gives a geometric waiting time with mean
Preparing a superposition does not make a specified label likely. A useful algorithm must use phase and interference to concentrate probability or extract a global property.
Compose with a supplied phase oracle
Section titled “Compose with a supplied phase oracle”Assume the clean phase-oracle interface
is supplied. Derive its action on an arbitrary input superposition and state what further steps are needed to obtain a useful answer.
Solution
By linearity, an input superposition becomes
The interface supplies a relative phase pattern, not a readable answer. A complete algorithm must still specify the interference step, measurement and postprocessing, success criterion, query model, and implementation costs. If the phase oracle is constructed from other operations, its preparation and workspace cleanup must also be included.
Read a linear phase pattern
Section titled “Read a linear phase pattern”Let and prepare
Show that .
Solution
The amplitude of output is
If , every term equals , so . If , choose a bit where is ; pairing strings that differ in that bit cancels the sum, so . Hence the transformed state is exactly .
This is a clean example of a relative-phase pattern becoming one deterministic classical label through interference.
Phase estimation on a superposition
Section titled “Phase estimation on a superposition”Suppose two orthonormal eigenstates obey , with distinct, exactly representable phases, and the normalized system input is
Assuming ideal phase resolution, give the state before measurement and the probabilities of the two phase outcomes.
Solution
Linearity gives
If the phase-register states are distinguishable, measurement returns with probability and with probability . The corresponding system register is projected onto the associated eigenstate.
Finite resolution broadens the phase distributions, and degenerate or nearby phases require a more careful measurement analysis.
Grover-scale amplification
Section titled “Grover-scale amplification”There is one marked item among equally weighted inputs, so and . Estimate the number of amplitude-amplification iterations that first brings the success probability near one.
Solution
After iterations, the good amplitude is
Choose
For large , , so
Thus the number of coherent oracle and reflection uses is , compared with classical trials in the same unstructured-query model.
Block-encoding success probability
Section titled “Block-encoding success probability”An exact block encoding has normalization . For a normalized input , derive the probability of measuring all ancillas in . What happens if is doubled while is fixed?
Solution
The all-zero ancilla component is
Therefore
Doubling divides the success probability by four. A block encoding with an unnecessarily large normalization can impose a major postselection or amplification cost even if each signal query is cheap.
Count rare accepted outcomes
Section titled “Count rare accepted outcomes”A repeatable known-state preparation succeeds only when an ancilla outcome occurs with probability . The accepted branch has a polynomial-size circuit. What is the expected repetition cost, and why is the accepted circuit size alone not an efficiency proof?
Solution
Independent repetition requires
runs on average for one accepted event. The complete expected cost is therefore exponential even though each accepted branch has polynomial circuit size.
If a coherent preparation, inverse, and success reflection are available, amplitude amplification can reduce the scaling toward
which is still exponential. An efficiency claim must include raw trials, coherent amplification resources if used, and the probability of every heralding condition.
References
Section titled “References”- S. Aaronson, “Quantum computing, postselection, and probabilistic polynomial-time,” Proceedings of the Royal Society A 461, 3473–3482, 2005, doi:10.1098/rspa.2005.1546.
- G. Brassard, P. Høyer, M. Mosca, and A. Tapp, “Quantum amplitude amplification and estimation,” Contemporary Mathematics 305, 53–74, 2002, arXiv:quant-ph/0005055.
- A. Gilyén, Y. Su, G. H. Low, and N. Wiebe, “Quantum singular value transformation and beyond,” in Proceedings of the 51st Annual ACM SIGACT Symposium on Theory of Computing, 193–204, 2019, doi:10.1145/3313276.3316366.
- G. H. Low and I. L. Chuang, “Optimal Hamiltonian simulation by quantum signal processing,” Physical Review Letters 118, 010501, 2017, doi:10.1103/PhysRevLett.118.010501.
- M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Information, 10th anniversary ed., Cambridge University Press, 2010, doi:10.1017/CBO9780511976667.