Chapter 5: Advanced Topics
Chapter 5: Advanced Topics in Quantum Computing
The first four chapters have built a complete foundation for understanding quantum computing: from linear algebra and complex numbers (Chapter 1), quantum mechanics principles (Chapter 2), qubits and quantum gates (Chapter 3), to the mathematical form of the quantum Fourier transform and the core ideas of Shor’s algorithm (Chapter 4). However, some key technical details and frontier topics remain unexplored. This chapter fills those gaps, deepening the reader’s understanding of quantum computing across five dimensions: we will show how to convert the abstract quantum Fourier transform into a concrete quantum circuit; we will learn quantum phase estimation—an exponentially accelerated technique for reading the eigenvalues of a quantum system; we will confront the greatest enemy of real quantum computers—noise and decoherence; we will explore the most important algorithmic paradigm of the NISQ (Noisy Intermediate-Scale Quantum) era—variational quantum algorithms; and finally, we will introduce §5.5 Hamiltonian simulation—one of the most promising applications of quantum computing in quantum chemistry and materials science. These five topics respectively correspond to circuit implementation of quantum algorithms, core applications, physical limitations, near-term practice, and core application prospects, together forming a complete bridge from theory to experiment.
5.1 Quantum Fourier Transform Circuit Construction
From DFT to QFT: Review and Motivation
Recall the discrete Fourier transform (DFT) studied in §1.8. For complex numbers , the DFT transforms them into a new set of complex numbers :
In quantum computing, the Quantum Fourier Transform (QFT) is the quantum implementation of the DFT. It does not transform an array of classical data; rather, it transforms the amplitudes of a quantum state. Given an -qubit state:
The QFT transforms it into:
where are precisely the DFT coefficients above. Expressed in terms of basis states, the action of the QFT is:
This is one of the most important transforms in quantum computing. From a matrix perspective, is a unitary matrix whose entry is —the quantum version of the DFT matrix from §1.8. But the key point is: classical computers require operations to compute the DFT, while a quantum computer needs only quantum gates to implement the QFT—an exponential speedup.
Binary Fraction Representation: Factoring the QFT
To convert the QFT into a circuit, we need to factor the above sum into a tensor product of single-qubit states. This is the central technique of QFT circuit construction.
First, we introduce the binary fraction representation: for a binary decimal , its value is:
For example, , , .
Now, represent the integer as an -bit binary number , i.e., . The QFT acting on the basis state yields, after a series of algebraic manipulations (expanding the exponential and separating variables), the remarkable factorized form:
Let us verify this formula for correctness. Taking as an example: , , then:
When , , yielding ; when , , yielding . This is precisely the action of the Hadamard gate ! So the single-qubit QFT is simply the gate.
The importance of this factorization is that the output state has been written as the tensor product of single-qubit states. This means we can use parallel single-qubit operations to prepare each factor of the output state—this is the key to constructing an efficient quantum circuit.
Controlled Phase Rotation Gates
Consider the -th factor in the factorization:
The phase can be expanded as:
Each exponential term corresponds to a controlled phase rotation. For this, we define the Controlled-Phase Rotation gate :
It acts on two qubits: when the control qubit is , it adds a phase to the component of the target qubit; when the control qubit is , the target qubit is unchanged. Note that is just the controlled- gate (CZ), since .
The matrix of is diagonal in the computational basis , which makes it relatively easy to implement experimentally (many physical platforms natively support diagonal two-qubit gates).
Cascade Circuit Construction of the QFT
Now we can construct the complete QFT circuit. The QFT circuit operates sequentially from the first qubit to the -th qubit:
Qubit 1: Apply , then sequentially apply , with control qubits being qubits 2, 3, , , respectively.
- produces
- (control = qubit 2) adds phase , transforming the phase to
- (control = qubit 3) adds phase , transforming the phase to
- and so on…
Qubit 2: Apply , then sequentially apply , with control qubits being qubits 3, 4, , , respectively.
…
Qubit : Apply only.
The 3-qubit QFT circuit is as follows:
j₁: |j₁⟩ —H—•—————•——— → output bit 3
| |
j₂: |j₂⟩ ————R₂—H—•——— → output bit 2
|
j₃: |j₃⟩ ————R₃—R₂—H— → output bit 1
where denotes the gate, with the control qubit above and the target qubit below. In the diagram, controls from qubit 2 to qubit 1, controls from qubit 3 to qubit 1, and so on.
More generally, an -qubit QFT circuit requires:
- gates
- controlled-phase gates
The total gate count is . Since gates on different qubits can be executed in parallel (they do not interfere with each other), while controlled-phase gates involve different qubit pairs, the circuit depth is also (if all two-qubit gates can be executed in parallel), or under the most conservative estimate.
Bit-Reversal Problem and SWAP Gate Correction
Carefully examine the factorized output:
where the -th factor corresponds to , meaning it depends only on the input bits . This implies:
- The 1st output factor (most significant) depends only on the least significant input bit
- The -th output factor (least significant) depends on all input bits
Thus, the bit order of the QFT circuit output is reversed. If we want the output arranged in the normal order , we need to append SWAP gates at the end of the circuit to reverse the bit order.
The SWAP gate exchanges the states of two qubits; its matrix is:
A SWAP can be implemented using 3 CNOT gates: CNOT(1→2), CNOT(2→1), CNOT(1→2). Therefore, the complete QFT circuit (including bit-order correction) requires elementary gates.
Complete Numerical Example for 3-Qubit QFT
Let us verify the correctness of the QFT circuit with a concrete 3-qubit example. Take the input state (i.e., ).
Step 1: Initial state
Step 2: Apply to qubit 1
Step 3: (control = qubit 2, target = qubit 1)
Control qubit 2 is , so the component of target qubit 1 acquires phase :
Step 4: (control = qubit 3, target = qubit 1)
Control qubit 3 is , so the component of target qubit 1 acquires an additional phase :
So:
This corresponds to .
Step 5: Apply to qubit 2
Qubit 2 is currently , and :
Step 6: (control = qubit 3, target = qubit 2)
Control qubit 3 is , and the component of qubit 2 acquires phase :
This corresponds to .
Step 7: Apply to qubit 3
This corresponds to .
Step 8: SWAP correction for bit order (qubit 1 ↔ qubit 3)
The final output (ignoring the normalization factor ) is a superposition of 8 basis states, with amplitudes given by , where . This is precisely the result of applying the DFT to the basis state .
Approximate QFT and Depth Optimization
On real quantum computers, very small phase rotations (such as for large , where ) are difficult to implement accurately. A practical optimization is the Approximate QFT: discard all gates with , where . The error of this approximation can be controlled to be arbitrarily small, while the circuit depth reduces to , and in some architectures can even be optimized to .
Summary: The quantum Fourier transform achieves efficient circuit construction by factorizing the output state into a tensor product of single-qubit states. The QFT circuit consists of gates and controlled-phase rotation gates, with total complexity of gates. The binary fraction representation reveals that each output bit depends only on a subset of input bits, which is the key to the cascaded circuit structure. The reversed output bit order must be corrected with SWAP gates. The 3-qubit numerical example verifies the correctness of the circuit.
Connection to Quantum Computing: The QFT is the core subroutine of Shor’s algorithm and quantum phase estimation. The transition from the abstract DFT matrix to the concrete cascaded circuit of gates and controlled-phase gates is a critical step from the mathematical description of quantum algorithms to their physical implementation. Understanding the circuit construction of the QFT is the foundation for understanding how these exponentially accelerated algorithms run on real quantum hardware. The circuit complexity means the QFT can be implemented on moderate-scale quantum computers, making it one of the most practical transforms in near-term quantum computing.
5.2 Quantum Phase Estimation
Problem Statement: Reading the Eigenvalues of a Quantum System
Quantum Phase Estimation (QPE) is one of the most powerful subroutines in quantum computing. It solves the following problem:
Given: a unitary operator and one of its eigenvectors , satisfying . Goal: estimate the numerical value of the phase .
This problem may seem abstract, but it captures the essence of many core quantum algorithms. For example, in Shor’s algorithm, is the unitary operator implementing modular exponentiation, is the corresponding period state, and the precise value of directly provides the key information needed for factorization.
On a classical computer, there is no direct method to estimate the eigenphase of a unitary operator—we typically need to compute all matrix elements of and diagonalize, with complexity (where ). Quantum phase estimation, by leveraging quantum parallelism and the QFT, can directly “read” the phase with a complexity of only gates—an exponential speedup.
Algorithm Circuit Structure: Ancilla Register + Controlled Unitary Operations + Inverse QFT
The QPE circuit consists of three parts, using two quantum registers:
- First register (ancilla/counting register): qubits, initialized to
- Second register (target register): holds the eigenvector (assumed to have been prepared)
The circuit structure is as follows:
|0⟩ —H—•——————•——————•———H†—S†—...— → measure → binary estimate of θ
|0⟩ —H—| U¹ | U² | —H†—...—
|0⟩ —H—| | | ...
⋮ | | |
|0⟩ —H—•———————•———————•———————...—
| | |
|u⟩ ——U¹——U²——U⁴——...——U^(2^{t-1})— → |u⟩ (unchanged)
Step 1: Create a superposition
Apply gates to all ancilla qubits:
Step 2: Controlled unitary operations encode the phase
Sequentially apply controlled operations, with the control qubit being the -th qubit of the ancilla register and the target being . The controlled acts as: when the control qubit is , apply to the target; when the control qubit is , the target is unchanged.
Mathematically, for the ancilla qubits in state (where ), the controlled operations transform the target state as:
Thus, the state of the entire ancilla-target system becomes:
This is the critical step: the phase has been encoded into the amplitudes of the ancilla register! Note the form of this state—it closely resembles the output state of the QFT.
Step 3: Inverse QFT reads the phase
Apply the Inverse Quantum Fourier Transform (Inverse QFT, QFT) to the ancilla register part of the above state. QFT is the Hermitian conjugate of the QFT; it transforms a frequency-domain representation back to the time domain.
If can be exactly represented as a -bit binary number, i.e., , then the inverse QFT transforms the ancilla register precisely into . Measuring the ancilla register, we directly read out the binary representation of !
More precisely, if (i.e., a -bit binary fraction), then:
This is a direct consequence of the defining property (orthogonality) of the QFT.
Precision Analysis and Success Probability
When is not a -bit binary fraction (i.e., cannot be represented exactly), QPE yields the best -bit approximation of . Let be the distance between the true value of and the nearest -bit binary fraction ().
The probability that the measurement outcome falls near satisfies:
In particular, to obtain an estimate with bits of precision (i.e., error less than ), one needs ancilla qubits. More precisely, to obtain bits of precision with probability at least , one needs:
For example, to obtain bits of precision with 99% success probability, roughly ancilla qubits are needed.
Relationship to Shor’s Algorithm
The core of Shor’s algorithm is order finding: given an integer coprime to , find the smallest positive integer such that . This problem can be formulated as phase estimation:
Define a unitary operator : (acting on qubits). The eigenstates of this are:
with corresponding eigenvalues , where .
By using QPE to estimate , and then using the continued fraction expansion to extract from the approximation of , we obtain the mechanism by which QFT/QPE plays its central role in Shor’s algorithm. QPE transforms an abstract number-theoretic problem into a physical measurement of a quantum system’s eigenphase—a profound intersection of mathematics and physics.
Implementation Challenges: Controlled Operations
The theoretical framework of QPE is elegant and concise, but its experimental implementation faces major challenges:
-
Preparing the eigenstate : we usually do not know the explicit form of . In practice, we prepare (or another simple state), which can be expressed as a superposition of all eigenstates: . QPE simultaneously estimates multiple eigenphases, and the measurement outcome gives some value of with a certain probability—this is sufficient for order finding.
-
Implementing controlled : this is the greatest experimental challenge. For the modular exponentiation in Shor’s algorithm, , one needs to implement elementary gates. While theoretically feasible, the gate fidelity and coherence time of current quantum hardware limit the scale of executable .
-
Qubit count: Shor’s algorithm for factoring an -bit integer requires roughly qubits for the ancilla register, plus qubits for the target register. For 2048-bit RSA (), roughly 4000–5000 qubits are needed—far beyond the current state-of-the-art quantum computers (~1000 qubits).
Summary: Quantum phase estimation achieves exponentially accelerated estimation of the eigenphase of a unitary operator by creating a superposition in the ancilla register, applying controlled operations to encode the phase into the amplitudes, and then using the inverse QFT to convert the phase information into a measurable binary representation. ancilla qubits provide roughly bits of precision. The order finding in Shor’s algorithm is a direct application of QPE. The implementation of controlled is the main bottleneck in current experiments.
Connection to Quantum Computing: QPE is a general-purpose tool for “reading” the intrinsic information of a quantum system. It is used not only in Shor’s algorithm, but widely in quantum chemistry (computing molecular energy levels), quantum simulation (reading system evolution frequencies), and quantum machine learning. Understanding the circuit structure and precision analysis of QPE is key to understanding how quantum computers extract useful classical information from abstract quantum states. QPE exemplifies the typical paradigm of quantum algorithm design: encoding problems using superposition and extracting answers using quantum interference.
5.3 Noise Models and Decoherence
Open Quantum Systems: Why Noise Is Unavoidable
In the preceding chapters, we discussed only closed quantum systems—ideal systems that are completely isolated from the external environment and governed solely by precisely controlled unitary evolution. In reality, no quantum system is completely isolated. Open quantum systems are continuously coupled to their environment, leading to the degradation and loss of quantum information.
Why is this coupling unavoidable? Because qubits are real physical systems (electron spins, superconducting circuits, ion energy levels, etc.), they necessarily interact with surrounding environmental degrees of freedom such as electromagnetic fields, lattice vibrations (phonons), and thermal radiation. These environmental degrees of freedom constitute an enormous “heat bath,” whose Hilbert space dimension is typically exponentially larger than that of the qubit. Entanglement between the qubit and the environment causes the pure state of the qubit to evolve into the mixed states we studied in §2.6—this is the physical origin of decoherence.
Understanding noise is not optional supplementary knowledge; it is the basis for evaluating the practical feasibility of any quantum computing scheme. All current quantum computers operate in the “NISQ” (Noisy Intermediate-Scale Quantum) era, where noise is the primary factor limiting computational scale and depth.
Operator-Sum Representation (Kraus Representation)
For open quantum systems, evolution is no longer a unitary map from pure state to pure state, but a completely positive trace-preserving map (CPTP map) from density matrix to density matrix. Such maps can be characterized by the operator-sum representation, also known as the Kraus representation:
where are called Kraus operators, satisfying the completeness relation:
This condition ensures that the map is trace-preserving: .
The physical meaning of the Kraus representation is: the action of the environment on the quantum system can be viewed as a statistical mixture of a series of “quantum operations.” Each corresponds to one possible “response” of the environment, and the overall evolution is the probability-weighted average of these responses. This is entirely analogous to channel models for classical noise—except that here the “channel” acts on density matrices rather than classical probability distributions.
If there is only one Kraus operator (a unitary matrix), it reduces to the unitary evolution of a closed system: . Thus, the Kraus representation is a natural generalization of unitary evolution, uniformly describing everything from pure unitary evolution to complete depolarization.
Depolarizing Channel
The depolarizing channel is one of the simplest noise models, describing a process in which the quantum state is completely randomized with probability :
The corresponding Kraus operators are:
Completeness check: ✓
Physical meaning: with probability , the quantum state is unaffected; with probability each, an , , or error is applied (bit flip, phase flip, or both). When , any input state becomes the completely mixed state —information is completely lost.
On the Bloch sphere, the depolarizing channel uniformly shrinks all points toward the center:
i.e., the length of the Bloch vector is reduced by a factor of , but the direction is unchanged. When , the entire sphere collapses to the center .
Bit-Flip Channel
The bit-flip channel flips the qubit () with probability , corresponding to a classical “bit error”:
Kraus operators: , .
On the Bloch sphere, the effect of the bit-flip channel is:
Let me recompute. Setting , we have:
So the Bloch coordinates transform as:
i.e., the coordinate is unchanged, while the and coordinates are scaled by a factor of . When , the and components vanish completely, and the state becomes —if initially , it becomes the completely mixed state. The bit-flip channel preserves information on the axis but compresses the state in the - plane.
Phase-Flip Channel (Dephasing Channel)
The phase-flip channel, also called the dephasing channel, applies a gate (flipping the phase of ) with probability :
Kraus operators: , .
Effect on the Bloch sphere:
i.e.:
This is the core mechanism of decoherence! The phase-flip channel compresses the state in the - plane (attenuating the coherence terms) but preserves the coordinate (the occupation probabilities of the energy eigenstates). When , the and components vanish, and the state becomes a classical probability mixture —quantum coherence is completely lost, leaving only classical probabilistic information.
The importance of the dephasing channel is that it is the dominant noise mechanism in most physical systems. Due to energy conservation constraints, processes in which the system exchanges energy with the environment (causing changes in ) are typically much slower than pure phase information loss (, decay). Hence, (phase coherence time) is typically shorter than (energy relaxation time)—this is the most common limiting factor in experimental quantum computing.
Amplitude Damping Channel
The amplitude damping channel describes the process of energy dissipating from the quantum system into the environment, such as spontaneous emission decay of an excited state to the ground state:
where:
The parameter is the probability of energy dissipation. transforms (the excited state) into (the ground state), corresponding to energy released into the environment. reduces the amplitude of while leaving unchanged.
Completeness check:
On the Bloch sphere, amplitude damping attracts the state toward the north pole (, the ground state):
The coordinate transformation is:
As , any state approaches . When , the system undergoes exponential decay , where is the energy relaxation time.
Quantum Error Mitigation
Quantum error correction (§4.4) actively corrects errors through redundant encoding, but requires a large number of physical qubits and physical error rates far below the threshold. In the NISQ era (Noisy Intermediate-Scale Quantum), hardware has not yet reached the error-correction threshold, giving rise to an alternative technical route—Quantum Error Mitigation (QEM). Unlike QEC, QEM does not correct errors, but removes the influence of noise in classical post-processing, estimating noise-free expectation values in an unbiased manner. The core observation of QEM is: while we cannot eliminate noise on quantum hardware, we can cleverly vary the noise and measure its influence, then “subtract” the noise contribution on a classical computer.
Zero-Noise Extrapolation (ZNE):
- Core idea: measure the expectation value of the same observable at different noise levels, then extrapolate to the zero-noise limit
- How to control the noise level: systematically amplify noise through pulse stretching (lengthening gate operation times on superconducting platforms) or gate folding (inserting decompositions of identity gates to increase circuit depth)
- Fitting model: , where is the noise amplification factor
- Richardson extrapolation or exponential fitting
- Experimental validation: ZNE techniques can reduce energy estimation errors in VQE by a factor of 5–10 (IBM, Rigetti 2020–2022)
Probabilistic Error Cancellation (PEC):
- Core idea: represent noisy quantum gates as combinations of ideal gates and noise channels, then invert the noise through Monte Carlo sampling
- Implementation: decompose each noisy gate into a linear combination of ideal gates, sample in a “quasi-probability” manner, and multiply by a sign factor to correct expectation values
- Cost: sampling variance grows with , and grows exponentially with circuit depth—hence PEC is only applicable to shallow circuits
- Applicability: compared to ZNE, PEC provides more accurate correction at low depth but at higher cost
Virtual Distillation:
- A more recent method (2021–2022), which “distills” a noise-free state by preparing copies and measuring the expectation value of the swap operator
- Does not require additional ancilla qubits, but requires a gate network
- Applicable to medium-depth circuits; a method that sits between QEC and QEM
Measurement Error Mitigation:
- The simplest form of QEM: by preparing known basis states (such as and ) and measuring them, construct a measurement error response matrix , then correct all subsequent measurements via
- Complexity: for full matrix correction, or use tensor product decomposition approximations
QEC vs QEM comparison:
| Dimension | Quantum Error Correction (QEC) | Quantum Error Mitigation (QEM) |
|---|---|---|
| Goal | Actively correct errors | Post-process to remove noise bias |
| Quantum overhead | Large number of ancilla qubits () | Additional circuit executions (2–10x depth) |
| Classical overhead | Real-time decoder | Monte Carlo / extrapolation fitting |
| Error scaling | Exponential (below threshold) | Polynomial (extrapolation order) |
| Applicable era | Fault-tolerant era (2030+) | NISQ era (present) |
| Demonstrated | Below threshold (Willow ) | 2–10x precision improvement (IBM/Google) |
and Times
In experimental quantum computing, noise is characterized by two characteristic times:
(Energy Relaxation Time, Longitudinal Relaxation Time): describes the rate at which energy leaks from the excited state to the ground state. If the system is in at , the evolution of the coordinate satisfies:
i.e., the excited-state occupation probability decays as . A larger means the qubit can retain energy longer.
(Decoherence Time, Transverse Relaxation Time): describes the rate at which a quantum superposition state (a state in the - plane) loses coherence. The decay of the and coordinates satisfies:
The relationship between and is:
where is the pure dephasing time, describing the rate of pure phase noise (phase randomization that conserves energy). Typically , hence —phase coherence is lost much more rapidly than energy relaxation.
Current state-of-the-art superconducting qubits: , . This means quantum computations must be completed within a time far shorter than , or noise will overwhelm the quantum signal. Since a typical single-qubit gate time is about , current systems can execute roughly gate operations—this defines the computational boundary of the NISQ era.
Implications of Noise for Quantum Error Correction
The analysis of the above noise models reveals a key fact: single-qubit errors can be viewed as a statistical mixture of , , , and . This suggests a strategy for combating noise: if we can detect and correct , , and errors, we can protect quantum information.
However, the challenge of quantum error correction is far greater than that of classical error correction, for three reasons:
-
Continuous errors: quantum errors are continuous (arbitrary rotations on the Bloch sphere), whereas classical errors are discrete (bit flips). Although the Kraus representation decomposes continuous evolution into a mixture of discrete operations, the error-correction circuits themselves are also affected by noise.
-
No-cloning theorem: we cannot copy quantum information to protect it, so we must employ more sophisticated encoding strategies (such as encoding one logical qubit into multiple physical qubits).
-
Measurement destroys coherence: to detect errors, we need to measure certain observables, but measurement causes collapse. Quantum error-correcting codes (such as Steane code, Shor code, surface code) circumvent this limitation by measuring stabilizers rather than the qubits themselves—stabilizer measurements reveal error information without destroying the encoded quantum state.
The surface code is currently the most promising quantum error correction scheme. It uses physical qubits on a two-dimensional lattice to encode one logical qubit, detecting and errors through local stabilizer measurements. The threshold theorem of the surface code states: if the single-qubit error rate is below about , the logical error rate can be arbitrarily reduced—this is the theoretical foundation of fault-tolerant quantum computing.
Summary: Open quantum systems coupling to the environment leads to information loss, uniformly described by the Kraus operator-sum representation. The depolarizing channel completely randomizes the quantum state with probability ; the bit-flip channel preserves the coordinate but compresses and ; the phase-flip (dephasing) channel is the core mechanism of decoherence, attenuating and but preserving ; amplitude damping describes energy dissipation, attracting the state toward the ground state. The and times characterize the noise strength, and current hardware limits NISQ-era circuit depths to roughly gates. Quantum error correction combats noise through multi-qubit encoding and stabilizer measurements, with the surface code being the most promising fault-tolerant scheme; in the NISQ era, quantum error mitigation (ZNE, PEC, virtual distillation) estimates noise-free expectation values in an unbiased manner through classical post-processing, providing an alternative noise-management strategy for current hardware that complements QEC for the fault-tolerant era.
Connection to Quantum Computing: Noise is the greatest obstacle to the transition of quantum computing from theory to practice. Understanding noise models not only helps us evaluate the practical feasibility of quantum algorithms, but also guides the design of quantum error-correcting codes. The variational quantum algorithms of the NISQ era (§5.4) are held in high hope precisely because of their noise robustness compared to algorithms requiring deep circuits (such as Shor’s algorithm). From the dephasing channel to the time, from the Kraus representation to the surface code, noise theory bridges abstract quantum algorithms and real physical hardware.
5.4 Variational Quantum Algorithms
Quantum-Classical Hybrid Architecture
The quantum algorithms we have studied so far (Shor, Grover, QPE) all assume an ideal fault-tolerant quantum computer—millions of qubits, extremely low error rates, and sufficiently long coherence times. But current and near-term foreseeable quantum hardware is far from meeting this standard. Devices in the NISQ (Noisy Intermediate-Scale Quantum) era have qubits, limited coherence times, and significant gate error rates. Under these constraints, new algorithmic paradigms are needed.
Variational Quantum Algorithms (VQA) arose in response. Their core idea: use the quantum computer as a “parameterized state preparer,” and hand the difficult optimization problem to a classical computer.
The hybrid architecture workflow is:
- A classical optimizer chooses a set of parameters
- The quantum computer uses a parameterized circuit to prepare a trial state
- The quantum computer measures some observable of that state, obtaining an estimate of the energy (or other cost function)
- The classical computer updates the parameters based on
- Repeat steps 2–4 until convergence
This loop exploits the quantum computer’s advantage in state preparation and measurement (operations in an exponentially large Hilbert space), while avoiding the noise accumulation of deep quantum circuits—the parameterized circuits are typically very shallow ( or depth). The classical optimizer handles parameter updates, using mature classical optimization algorithms (gradient descent, Adam, L-BFGS, etc.).
Variational Principle: The Energy Upper Bound
The theoretical foundation of variational quantum algorithms is the variational principle: for any quantum state , the expectation value of the Hamiltonian satisfies:
where is the ground-state energy (lowest eigenvalue) of . Equality holds if and only if is the ground state.
This means: if we can prepare a trial state close to the ground state, its energy expectation value provides an upper bound on the ground-state energy. By minimizing , we simultaneously obtain an estimate of the ground-state energy and an approximation to the ground state itself.
This principle is especially important in quantum chemistry: the electronic structure of molecules is described by the Schrödinger equation , but exact solution is impossible on classical computers for multi-electron systems (beyond roughly 20 electrons). Variational quantum algorithms offer a possible path for computing molecular ground-state energies on NISQ devices.
VQE: Variational Quantum Eigensolver
The Variational Quantum Eigensolver (VQE) is the most famous algorithm in the VQA family, specifically designed for finding the ground-state energy and ground-state wavefunction of a quantum system.
Algorithm flow:
1. Parameterized Quantum Circuit (Ansatz):
Choose a parameterized circuit that transforms the initial state into a trial state:
Common ansätze include:
- Hardware-Efficient Ansatz (HEA): uses simple gate layers matching the native gate set of the target quantum hardware (e.g., single-qubit rotations + entangling gates). Shallow depth, but may struggle to represent complex ground states.
- UCCSD (Unitary Coupled Cluster with Single and Double excitations): built from quantum-chemistry-inspired excitation operators; physically well-motivated, but circuit depth is larger.
2. Energy Measurement:
Decompose the Hamiltonian into a linear combination of Pauli operators (via the Jordan-Wigner transformation or Bravyi-Kitaev transformation):
The energy expectation value is:
Each can be measured in the computational basis after an appropriate basis rotation. For example, to measure , first apply gates to all relevant qubits, then measure .
3. Classical Optimization:
Use a classical optimizer to minimize . Commonly used optimizers include:
- Gradient descent: requires estimating the gradient
- SPSA (Simultaneous Perturbation Stochastic Approximation): estimates all gradient components using only 2 function evaluations, suitable for noisy environments
- L-BFGS: a quasi-Newton method, converges quickly but is sensitive to noise
Quantum method for gradient estimation:
The parameter shift rule allows exact gradient computation:
This requires only evaluating the energy at , with no need for numerical differentiation.
Application: Quantum Chemistry
The most important application of VQE is computing the ground-state energy of molecules. For example, computing the ground-state energy of the hydrogen molecule requires 4 qubits (4 spin orbitals), and VQE can be implemented on current NISQ devices. For larger molecules (such as , ), more qubits and deeper circuits are needed, but this remains one of the most promising near-term quantum advantage application scenarios.
QAOA: Quantum Approximate Optimization Algorithm
The Quantum Approximate Optimization Algorithm (QAOA), proposed by Farhi, Goldstone, and Gutmann in 2014, is specifically designed for solving combinatorial optimization problems.
Problem setting:
A combinatorial optimization problem can be formulated as: minimize a cost function defined on -bit binary strings, where . For example, the MaxCut problem: given a graph , partition the vertices into two sets to maximize the number of edges between the two sets.
Map the cost function to a problem Hamiltonian :
The ground state corresponds to the optimal solution. But directly finding the ground state is hard (NP-hard).
QAOA circuit structure:
QAOA uses layers of alternating unitary evolution:
where:
- Mixer Hamiltonian: , i.e., the sum of gates on all qubits. Its role is to drive the system in a “random walk” through solution space.
- Problem Hamiltonian: (for the MaxCut example)
- Initial state: , the equal superposition of all qubits
The parameters and are adjusted by a classical optimizer to minimize the expectation value .
QAOA circuit example for (3-qubit MaxCut):
|0⟩ —H—Rz(γ₁)—•——————Rx(β₁)—
| (ZZ)
|0⟩ —H—Rz(γ₁)—⊕—•—————Rx(β₁)—
| (ZZ)
|0⟩ —H—Rz(γ₁)———⊕——Rx(β₁)—
where comes from the diagonal evolution of , and the gate (a variant of the controlled- gate) implements .
Applications:
QAOA has been applied to MaxCut, graph coloring, the traveling salesman problem (TSP), portfolio optimization, and other problems. Although whether QAOA’s approximation ratio can surpass classical algorithms for general problems remains an open question, for certain specific problem instances, QAOA has demonstrated performance superior to classical greedy algorithms.
Challenges of Variational Algorithms
Although variational quantum algorithms provide a practical path for the NISQ era, they face several fundamental challenges:
1. Barren Plateaus
This is the most severe theoretical challenge for variational quantum algorithms. Research shows that for random parameterized circuits of depth , the variance of the cost function gradient decreases exponentially with the number of qubits :
This means that as the circuit scale increases, the gradient becomes extremely small and is drowned out by noise—the optimizer cannot find a descent direction. This phenomenon is called barren plateaus, because the cost function landscape is as flat as a barren plateau, with no discernible gradient information.
Mitigation strategies include:
- Using local cost functions (rather than global cost functions)
- Designing problem-specific shallow ansätze
- Adopting layerwise optimization strategies
2. Measurement Sampling Overhead
Estimating the energy expectation value requires measuring each term . Estimating each to precision requires measurements (by the central limit theorem). If the Hamiltonian has terms, the total sampling complexity is . For quantum chemistry problems, can be very large (), leading to enormous measurement overhead.
Mitigation strategies include:
- Grouping Commuting Pauli Strings: simultaneously measure commuting Pauli operator strings
- Classical Shadows: use randomized measurements to obtain information about multiple observables at once
3. Circuit Depth vs. Expressibility Trade-off
Deeper circuits can represent more complex quantum states (higher expressibility), but are also more susceptible to noise (lower fidelity). Ansatz design needs to strike a balance between expressibility and noise robustness. Hardware-efficient ansätze are shallow and noise-robust, but may not be able to approximate the target ground state; chemistry-inspired ansätze like UCCSD have high expressibility, but their circuit depth may exceed the limits of NISQ devices.
Relationship Between Variational Algorithms and Fault-Tolerant Quantum Computing
Variational quantum algorithms are not a replacement for fault-tolerant quantum computing, but the core algorithmic paradigm of the transition period (the NISQ era). Their relationship can be summarized as follows:
| Feature | NISQ Variational Algorithms | Fault-Tolerant Quantum Algorithms |
|---|---|---|
| Circuit depth | or | |
| Qubit count | ||
| Error rate tolerance | or lower | |
| Classical optimization | Required | Not required |
| Application scenarios | Quantum chemistry, optimization | Factorization, large-molecule simulation |
VQE’s application in quantum chemistry is considered the most promising area for achieving practical quantum utility on NISQ devices. While classical methods (such as density matrix renormalization group DMRG, coupled cluster CCSD(T)) are very accurate for small molecules, they fail for strongly correlated systems (such as transition metal catalysts, the Hubbard model of high-temperature superconductors), where VQE may offer a new computational pathway.
From a broader perspective, variational quantum algorithms represent a “pragmatic turn” in quantum computing: rather than waiting for a perfect fault-tolerant quantum computer, leverage existing (imperfect) quantum hardware, combined with classical computing, to solve scientifically and practically valuable problems. This hybrid paradigm may be the primary way quantum computing generates real-world impact in the coming decade.
Summary: Variational quantum algorithms adopt a quantum-classical hybrid architecture, using parameterized quantum circuits for state preparation and a classical optimizer for parameter updates. VQE exploits the variational principle to estimate ground-state energies, with important applications in quantum chemistry. QAOA solves combinatorial optimization problems by alternately applying a problem Hamiltonian and a mixer Hamiltonian. Variational algorithms face three major challenges: barren plateaus (exponentially vanishing gradients), measurement sampling overhead , and the circuit-depth vs. expressibility trade-off. They are the most promising practical quantum computing paradigm of the NISQ era.
Connection to Quantum Computing: Variational quantum algorithms bridge current NISQ hardware and future fault-tolerant quantum computers. They show how quantum computing can generate practical value under noise and scale constraints. From VQE’s quantum chemistry applications to QAOA’s combinatorial optimization, variational algorithms transform abstract quantum mechanical principles into computational tools for solving real problems. Understanding the principles, advantages, and limitations of variational algorithms is key to evaluating whether quantum computing can achieve “quantum advantage” in the near term. Whatever the future development of quantum hardware, the variational optimization philosophy—solving complex problems through the synergy of quantum state preparation and classical optimization—will continue to play an important role in quantum computing.
5.5 Introduction to Hamiltonian Simulation
Problem statement: Given a Hamiltonian (describing the total energy of a quantum system), compute the time evolution operator and simulate its effect on an initial state. This is one of the most promising applications of quantum computing—for quantum chemistry (molecular ground-state computation), materials science (electronic structure), and high-energy physics (lattice gauge theory).
Why classical simulation is hard: acts on a system of qubits, so its matrix size is —exponential. But is typically sparse (e.g., in quantum chemistry, ), involving only a few terms.
Trotter decomposition (Trotter-Suzuki decomposition—the most basic method):
- If , and each is easy to simulate (e.g., Pauli strings acting on only a few qubits), then where is the number of Trotter steps, with error .
- Physical intuition: slice time into small segments , and within each segment approximately assume that the commute
- Complexity: to achieve precision
Higher-order Trotter methods:
- Second-order decomposition:
- Fourth-order decomposition: by nesting second-order decompositions, the error drops from to
Post-Trotter methods (recent breakthroughs):
- Quantum Signal Processing: achieves optimal complexity via the Quantum Singular Value Transformation (QSVT)
- Taylor series method: expand as a Taylor series, implemented via Linear Combination of Unitaries (LCU)
- Quantum walk method: reformulate Hamiltonian simulation as a quantum walk problem
Applications:
- Quantum chemistry: simulating the electronic structure of molecules , LiH, FeS (already experimentally demonstrated at small scale)
- Condensed matter physics: ground states and dynamics of the Hubbard model and t-J model
- High-energy physics: simulation of the Schwinger model and lattice QED
Current limitations:
- Practically useful quantum chemistry simulations require quantum gates, far beyond current hardware capabilities
- The resource overhead after error correction remains enormous (potentially thousands of logical qubits running for thousands of hours)
- The coupling between Trotter error and gate fidelity requires further study
Summary: Hamiltonian simulation aims to compute the time evolution operator , and is the most promising application of quantum computing in quantum chemistry, materials science, and high-energy physics. Classical simulation is difficult due to the exponential matrix size, but Hamiltonians are typically sparse. Trotter decomposition splits the total Hamiltonian into a product of easily simulable terms—the most basic method; higher-order Trotter methods reduce error through symmetrized decompositions. Recent breakthroughs include Quantum Signal Processing (QSVT), the Taylor series method, and quantum walk methods, achieving better complexity. Current limitations are that practically useful simulation scales require far more gates than existing hardware can deliver, and the resource overhead after error correction remains enormous.
Connection to Quantum Computing: Hamiltonian simulation is one of the strongest candidates for a “killer application” of quantum computing. It directly leverages the natural evolution of quantum systems to simulate other quantum systems, avoiding the exponential storage and computation bottlenecks of classical computers. From Trotter decomposition to Quantum Signal Processing, the development of Hamiltonian simulation demonstrates how quantum algorithms, starting from basic physical intuition, achieve complexity breakthroughs through mathematical deepening. It is closely linked to variational quantum algorithms (such as VQE): VQE is used for finding ground-state energies, while Hamiltonian simulation is used for studying system dynamics. Understanding the principles and limitations of Hamiltonian simulation is key to evaluating whether quantum computing can deliver practical advantages in quantum chemistry and materials science.
Chapter 5 Summary
This chapter completes the knowledge puzzle of advanced quantum computing topics across five key dimensions:
- §5.3.4 Quantum error mitigation (ZNE, PEC, virtual distillation) fills the core gap of “how to run algorithms when error correction is unavailable” in the NISQ era
- §5.1–5.2 QFT circuit implementation and QPE constitute the algorithmic engine of Shor’s algorithm and quantum simulation, the technical core of quantum exponential speedup
- §5.3 Noise models (Kraus operators, depolarizing/bit-flip/phase-flip/amplitude damping channels) provide the language for understanding the physical limitations of real quantum hardware
- §5.4 Variational quantum algorithms (VQE, QAOA) demonstrate the practical value of the quantum-classical hybrid paradigm in the NISQ era
- §5.5 Hamiltonian simulation, as a candidate for quantum computing’s “killer application,” connects algorithmic theory to real-world application scenarios
The common theme of these five topics is: the core challenges quantum computing faces in transitioning from theory to practice—noise, decoherence, error-correction overhead, and algorithmic design constraints. Having mastered these topics, the reader can now not only understand “how quantum computing works,” but also evaluate “when and in what way quantum computing will generate practical value.”
Appendix
Quantum Algorithms in Detail: From Principles to Circuit Implementation
Supplementary Material — Deepening and extension of §3.6 of the quantum computing primer (Part 3)
This document provides complete mathematical derivations, circuit constructions, complexity proofs, and worked examples for the five core quantum algorithms outlined in §3.6 (Introduction to Quantum Algorithms) of the tutorial. Readers should have completed Parts 1–3 of the tutorial and be familiar with complex numbers, linear algebra, qubits, quantum gates, quantum circuits, and the basic concepts of the Quantum Fourier Transform (QFT).
Part 5.1 (QFT Circuit Implementation) and Part 5.2 (Quantum Phase Estimation, QPE) will be directly referenced by Shor’s algorithm.
Table of Contents
- Deutsch-Jozsa Algorithm
- Bernstein-Vazirani Algorithm (supplementary)
- Simon’s Algorithm (supplementary)
- Grover’s Search Algorithm
- Shor’s Factoring Algorithm
- Algorithm Complexity Comparison Table
- References and Further Reading
1. Deutsch-Jozsa Algorithm
1.1 Problem Definition and Classical Complexity
Problem: Given a Boolean function , with the promise that is either a constant function (for all , takes the same value) or a balanced function (outputs 0 for exactly half of the inputs and 1 for the other half). Determine whether is constant or balanced.
Classical complexity analysis (worst case):
- Deterministic algorithm: in the worst case, requires queries. Because even if the first queries all yield the same result, one still cannot conclude that is constant—it is possible that the remaining queries all yield the opposite result, making exactly balanced. Only after querying the -th input and getting the same result can one be certain that is constant. Hence the deterministic query complexity is .
- Randomized algorithm: if one accepts a probability of error, it can be more efficient. But the worst case still requires an exponential number of queries.
Quantum complexity: only 1 query. This was the first quantum algorithm to demonstrate an exponential speedup (albeit for an artificially constructed problem).
1.2 Oracle Construction
In quantum algorithms, the function is not passively queried as a “black box,” but is realized as a unitary operator via a quantum oracle. The oracle is a basic component of quantum circuits: it encodes the function as a reversible unitary transformation.
The standard Deutsch-Jozsa oracle implementation takes the phase oracle form:
where is the -bit input register, is a single-bit output register, and denotes addition modulo 2 (XOR).
Matrix representation: in the computational basis is a diagonal matrix plus swap operations. Specifically, for each :
- If : (unchanged)
- If : , (applies an gate on the output qubit)
Unitarity verification of : , because two XOR operations restore the original state. is also a permutation matrix (exactly one 1 per row and column), so it is clearly unitary.
1.3 Phase Kickback Mechanism
Phase kickback is the core technique of the Deutsch-Jozsa algorithm and many other quantum algorithms. Its key insight is: preparing the oracle’s target qubit in the state causes the function value to be “kicked back” into the phase of the input register.
Derivation:
Initialize the output register to and apply an gate, yielding:
Now examine the action of on :
Consider two cases:
Case A — :
Case B — :
Combining both cases:
This is phase kickback: the function value appears as in the global phase of the input register , while the output register is completely unchanged (and can be discarded). In other words, the oracle acts equivalently as:
At this point the oracle has degenerated into a diagonal unitary matrix .
Physical intuition: the output register plays the role of a “phase reference.” When the oracle attempts to flip (the case), because the two components and of are flipped with opposite sign, the overall state acquires a global phase. This phase, due to the reversibility of the gate, is “kicked back” onto the input register.
1.4 Complete Description of the Deutsch-Jozsa Algorithm
Circuit Diagram ( bits, standard notation)
|0⟩^⊗n —H^⊗n—•—H^⊗n—[M]
|
|1⟩ —————H—— ⊕ ——————
where:
- The upper lines are the input register, initialized to
- The lower line is the auxiliary qubit (output register), initialized to
- The line between and represents the oracle (a collection of controlled operations)
- denotes measurement in the computational basis
- denotes parallel gates
Step-by-step derivation
Step 0 — Initialization:
Step 1 — Apply to the auxiliary qubit:
Step 2 — Apply to all qubits (i.e., parallel gates on the input register):
Recall the action of :
This is because , and the tensor product expansion yields an equal superposition of all computational basis states. Hence:
Step 3 — Apply the oracle :
Using phase kickback:
This is the critical step: a single oracle call simultaneously marks the function values of all inputs.
Step 4 — Apply a second to the input register:
We need the explicit form of . Recall , . For bits, for a single basis state :
where is the bitwise inner product (mod 2 addition).
Proof of this formula: , therefore:
Now apply the second to the input register of :
Step 5 — Measure the input register:
Measuring yields an outcome . The key question: can we determine from the measurement outcome whether is constant or balanced?
1.5 Correctness Proof
Theorem: In the above algorithm, if is a constant function, then with probability the measurement yields ; if is a balanced function, the probability of measuring is .
Proof:
Consider the amplitude of (corresponding to ):
since for all .
Case 1 — is a constant function:
- If for all , then ,
- If for all , then ,
In both cases , so the measurement yields with probability .
Case 2 — is a balanced function: Exactly half of the inputs have and half have . Therefore:
So , and the probability of measuring is zero.
Corollary: if the measurement yields , then must be balanced; if the measurement yields , then must be constant. A single query, deterministic decision!
1.6 Worked Example: (Deutsch’s Algorithm)
For , the input is , with .
Example A: Constant function
| 00 | 0 | +1 |
| 01 | 0 | +1 |
| 10 | 0 | +1 |
| 11 | 0 | +1 |
State after step 3:
Step 4 (second ):
Combining like terms, the coefficient of is:
The coefficients of the other are 0. Therefore , and the measurement inevitably yields .
Example B: Balanced function (value of the first bit)
| 00 | 0 | +1 |
| 01 | 0 | +1 |
| 10 | 1 | -1 |
| 11 | 1 | -1 |
State after step 3:
Step 4:
Coefficient of :
Coefficient of :
Therefore , and the measurement yields (nonzero), confirming is a balanced function. Correct!
Example C: Balanced function (XOR)
| 00 | 0 | +1 |
| 01 | 1 | -1 |
| 10 | 1 | -1 |
| 11 | 0 | +1 |
Step 3:
Step 4, coefficient of :
The measurement inevitably yields a nonzero result. Note that different balanced functions produce different patterns, but the algorithm only needs to check whether the outcome is all zeros.
1.7 Worked Example: Circuit
|0⟩ —H—•—H—[M]—
|0⟩ —H—•—H—[M]—
|0⟩ —H—•—H—[M]—
|
|1⟩ —H—⊕——————
The input space has 8 elements.
Constant function example :
Measured probability distribution: , .
Balanced function example (AND of three bits, only when , otherwise ):
Is this function balanced? No—the AND function outputs 1 for only 1 out of 8 inputs and 0 for 7 inputs—it is neither constant nor balanced, and therefore falls outside the promise of the Deutsch-Jozsa problem. The Deutsch-Jozsa algorithm is only valid for functions satisfying the “constant or balanced” promise.
A valid balanced function example: (depends only on the first bit). Then out of 8 inputs, half (the 4 with ) output 0, and half (the 4 with ) output 1.
1.8 Complexity Analysis
Quantum complexity:
- Quantum gate count: single-qubit gates ( gates) + 1 oracle call
- Circuit depth: ( gates can be executed in parallel)
- Total complexity:
Classical complexity (deterministic):
- Worst case: queries
- Exponential gap! For , classical requires queries (infeasible), while quantum requires only about 200 gates.
Important note: The problem solved by the Deutsch-Jozsa algorithm has the promise structure of “constant or balanced,” and the function is a promise problem rather than a general decision problem. It is not a “practical” algorithm, but it is the perfect pedagogical example of quantum algorithm design philosophy: superposition → parallel evaluation → interference → extraction of global information.
2. Bernstein-Vazirani Algorithm
2.1 Problem Definition
Problem: Given a function of the form , where is a hidden bit string and is the bitwise inner product. Find .
Classical complexity: query each bit individually. Set to obtain ; set to obtain ; and so on. A total of queries are needed.
Quantum complexity: only 1 query.
2.2 Algorithm Circuit
The Bernstein-Vazirani algorithm is almost identical to the Deutsch-Jozsa algorithm; the only difference lies in how the measurement outcome is interpreted.
|0⟩^⊗n —H^⊗n—•—H^⊗n—[M] → s (read out directly!)
|
|1⟩ —————H—— ⊕ ——————
where the oracle implements .
2.3 Complete Mathematical Derivation
Steps 0–3 are exactly the same as in Deutsch-Jozsa. The state after the oracle call is:
Step 4 — Apply the second :
Recall . Therefore:
where is the bitwise XOR. Note that the sum equals if and only if (since ), and is otherwise.
Therefore:
Step 5 — Measure the input register, directly obtaining every bit of !
Intuitive explanation: quantum parallelism evaluates all inputs at once; interference constructs the Fourier-transformed form of the hidden bit string ; the second performs the inverse Fourier transform, focusing the information about onto a single quantum state.
2.4 Worked Example
Let , (i.e., ).
State after the oracle call:
Explicit expansion (only listing terms with , i.e., inputs where is odd):
| 001 | -1 |
| 010 | +1 |
| 011 | -1 |
| 100 | -1 |
| 101 | +1 |
| 110 | -1 |
| 111 | +1 |
After the second , all amplitudes except interfere destructively, and the measurement yields .
2.5 Relationship Between Bernstein-Vazirani and Deutsch-Jozsa
- BV is the “parameterized” version of DJ: DJ decides whether is constant or balanced; BV finds the hidden parameter of
- BV’s oracle structure is more specific (a linear function rather than an arbitrary constant/balanced function)
- BV demonstrates the idea of quantum Fourier sampling: using the Fourier transform to convert hidden structure into measurable peaks
- Both algorithms share the same circuit, but BV provides a stronger result (finding , not just classifying)
Complexity comparison:
| Algorithm | Classical queries | Quantum queries | Speedup |
|---|---|---|---|
| Deutsch-Jozsa | 1 | Exponential | |
| Bernstein-Vazirani | 1 | -fold |
BV’s speedup is “linear” (-fold), not exponential. But as a quantum algorithm design template, it has pedagogical importance comparable to DJ.
3. Simon’s Algorithm
3.1 Problem Definition
Problem: Given a function (the output is also bits), with the promise that there exists a hidden nonzero bit string such that for all :
i.e., is two-to-one, and the colliding pairs differ exactly by . Find .
Geometric understanding: the input space is partitioned into “pairs” , with each pair sharing the same function value. The goal is to find the hidden period that determines this pairing structure.
Classical complexity: in the worst case, queries are needed (by the birthday paradox).
Quantum complexity: queries—an exponential speedup!
3.2 Simon’s Algorithm Circuit
The core idea of Simon’s algorithm shares a deep similarity with DJ/BV: superposition → oracle → Hadamard → measurement. But Simon requires multiple runs to collect linear equations.
Single-run circuit:
|0⟩^⊗n —H^⊗n—•—H^⊗n—[M] → random z
|
|0⟩^⊗n ——————⊕————— → discarded (measurement used for verification)
where the oracle .
3.3 Step-by-Step Derivation
Step 0:
Step 1 — Apply to the first register:
Step 2 — Apply the oracle:
Step 3 — Apply a second to the first register:
Step 4 — Measure the first register. The probability of measuring a particular is:
Since is two-to-one, each corresponds to two values: and . Therefore:
For any “pair” , its contribution is:
Key:
- If , then , and the contribution of that pair is zero
- If , then , and the contribution of that pair is nonzero
Thus, only when ; otherwise .
Conclusion: each run of Simon’s algorithm yields a random satisfying . In particular, , .
3.4 Recovering from Measurement Outcomes
A single run yields one satisfying . This is one linear equation in . Run times, collecting linearly independent values:
This constitutes a system of linear equations over . Solve for the nonzero solution (and the trivial solution ). Since is the promise condition, we take the nonzero solution.
Required number of runs: in , the probability that randomly and uniformly chosen -dimensional vectors span an -dimensional subspace (the orthogonal complement of ) is:
Taking makes the success probability approach 1. Classical post-processing is completed in (Gaussian elimination).
3.5 Worked Example: ,
Function definition (example with the promise):
| 00 | 01 |
| 01 | 10 |
| 10 | 10 |
| 11 | 01 |
Verification: , , and , . So .
Run 1: suppose is measured. Equation: .
Run 2: suppose is measured. Equation: .
From and we obtain . But this gives , contradicting the promise (). What went wrong? The collected equations are not independent! In fact, the second equation already implies , and combined with the first equation yields , but we know .
This reveals a key point: the distribution of measurement outcomes in Simon’s algorithm is uniform (among those satisfying ). It is possible that all sampled belong to the 1-dimensional subspace —in that case we only obtain the single equation , and need more runs.
Run 3: is measured. Equation: .
Now still gives . Still a contradiction! This shows that all measured come from the orthogonal complement of , which is —if every measurement yields (probability is small but nonzero), we need even more runs.
In practice, we need at least independent nonzero equation to constrain . The orthogonal complement of is -dimensional, and measurements sample uniformly from it. The expected number of runs to find linearly independent vectors is . Once we find a nonzero , we are done.
3.6 Complexity Analysis
Quantum complexity:
- Per run: gates + 1 oracle call
- Number of runs: (in expectation)
- Total oracle calls:
Classical complexity:
- Deterministic: function evaluations (finding a collision via the birthday paradox)
- Randomized: also requires
Exponential speedup: Simon’s algorithm was the first to demonstrate an exponential quantum speedup (more convincing than Deutsch-Jozsa’s “promise-based exponential” speedup, because the problem is more natural). It directly inspired Shor’s algorithm—Simon’s “hidden subgroup” framework directly generalizes to finite abelian groups, and Shor’s period finding is the generalization of Simon’s problem to the group .
3.7 Simon’s Problem and the Hidden Subgroup Problem
Simon’s problem is an instance of the Hidden Subgroup Problem (HSP) on the group :
- Group
- Hidden subgroup (a subgroup of order 2)
- The function is constant on the cosets of
- Goal: find a generator of
The period-finding problem in Shor’s factoring algorithm corresponds to an instance of HSP on the group . This unified framework reveals the deep connection between Simon’s and Shor’s algorithms.
4. Grover’s Search Algorithm
4.1 Problem Definition
Problem: Among unstructured data items, find the item satisfying a certain condition—the “marked” item. Assume there is a unique marked item , which can be tested via oracle queries.
Formalization: there exists an oracle function , where if and only if (the marked item), and otherwise. Find by querying .
Classical complexity: sequential search requires on average queries, and worst-case queries.
Quantum complexity: queries (roughly iterations), a quadratic speedup.
4.2 Oracle Construction
Similar to Deutsch-Jozsa, the Grover oracle is implemented via phase kickback:
For the marked item , , so a phase is applied; for other , the phase is unchanged.
At the circuit level, the Grover oracle can be written as:
i.e., it applies a phase flip to the marked state , while leaving all other states unchanged.
Verification: ; while for , .
4.3 Mathematical Derivation of the Diffusion Operator
The second key component of Grover’s algorithm is the diffusion operator (also called “inversion about the mean”):
where is the equal superposition of all basis states.
Why is it called “inversion about the mean”?
Let be the amplitude of . The action of on the state is:
where , so , with being the average amplitude.
Therefore:
This is precisely “inversion about the mean”: each amplitude is replaced by . If is below the mean, it is “boosted”; if above the mean, it is “suppressed.” The effect of this operation is: amplify amplitudes above the mean, shrink amplitudes below the mean.
Circuit implementation: , where is the “zero-state phase flip”: it applies a phase to and leaves other states unchanged.
Circuit for the complete diffusion operator:
|x⟩ —H^⊗n—(·)—H^⊗n—
|
X—•—X
|
X—•—X
|
...
X—•—X (n pairs of X gates)
|
H—⊗n—H
The middle part can be further decomposed as: flip all qubits (apply ), apply a multi-qubit controlled- gate (phase flip on ), and flip back.
4.4 Geometric Interpretation: Two-Dimensional Rotation
The most elegant mathematical explanation of Grover’s algorithm reduces the entire -dimensional space to a two-dimensional subspace. This is the key to understanding why Grover’s algorithm is so efficient.
Define two orthogonal states:
Note that , and the initial state can be written as:
where . For large , .
A Grover iteration consists of two steps:
- Oracle: — a reflection about
- Diffusion: — a reflection about
The Grover iteration is a rotation: In the plane, rotates the state by radians:
Proof (by induction or direct geometric argument):
is a reflection about the axis (preserving and flipping its perpendicular component). is a reflection about the axis. The composition of two reflections is a rotation, with the rotation angle equal to twice the angle between the two reflection axes.
The initial state makes an angle with (since ). reflects to the point symmetric about , at angle from . then reflects the result about the axis. The net effect of two reflections: a rotation by radians.
Thus after iterations, the state’s angle is .
4.5 Derivation of the Optimal Number of Iterations
We want the amplitude of (the marked item) to be as large as possible after iterations.
The condition for maximizing this amplitude:
Hence the optimal number of iterations:
Since (for ):
Final amplitude:
When , this value is close to 1. More precisely, the minimum failure probability is:
Example: , . . After 1 iteration, , and the marked item is found with probability 1.
Example: , rad. . After 1 iteration, , success probability . After 2 iterations, , probability .
4.6 Full Worked Example:
( qubits), with the marked item set to (binary, i.e., decimal 2).
Initialization:
First :
Grover iteration 1 (the only iteration needed):
Step A — Oracle (marking ):
Step B — Diffusion:
First compute the mean
Inversion about the mean:
| (after Oracle) | (after Diffusion) | |
|---|---|---|
| 00 | ||
| 01 | ||
| 10 | ||
| 11 |
After normalization (note ):
Measurement:
A probability of finding the marked item. Note that for , a single iteration already has high success probability. A second iteration (unnecessary) would raise it further.
In fact, is the most special case, because , , a perfect rotation to , and the success probability should be 100%. The above comes from the expression; let us compute more precisely:
Let us compute step by step:
: first compute the action of on .
Apply :
So:
Finally apply :
Perfect! , probability 1 of finding the marked item. For , only 1 Grover iteration is needed to find the marked item with probability 1.
4.7 Worked Example: ()
Marked item set to (decimal 6).
Initialization:
1st iteration: Oracle flips the amplitude of from to . Mean . After inversion, the amplitude of becomes . Other amplitudes become . Success probability .
2nd iteration: Starting from (amplitude vector before normalization). Oracle: flips the amplitude of to (others unchanged). New mean . After inversion, amplitude becomes . Other amplitudes become . Success probability .
Thus for , 2 iterations achieve roughly 94.5% success probability. Consistent with the theoretical value .
4.8 Optimality Proof: The BBBV Theorem
Question: does there exist a quantum search algorithm faster than ?
BBBV Theorem (Bennett, Bernstein, Brassard & Vazirani, 1997): any quantum algorithm solving the unstructured search problem must call the oracle at least times.
Proof sketch (high-dimensional geometric argument):
Consider the state evolution of a quantum algorithm. The initial state is . After oracle calls and non-oracle unitary transformations :
Define a sequence of “query states”: is the state after the -th oracle call. The key idea is to track how the amplitude of the marked item grows with the number of queries.
Introduce a “no-mark” oracle (never flips any phase), and define as the state sequence when is used in place of . Lemma: in some form—i.e., it is hard to distinguish whether the search space contains a marked item.
A more rigorous argument follows:
Define as the state after oracle queries. Define the oracle operation and the reference oracle (no mark).
Consider the difference vector , where uses .
One can show that each oracle call can increase by at most (because each oracle call can affect at most of the amplitude). After queries:
On the other hand, to successfully distinguish the marked and unmarked cases (i.e., to find the marked item), we need . Hence .
Intuitive understanding: each oracle query can only “slightly” change the quantum state; queries are needed to accumulate enough change to reliably locate the marked item. This is the optimality proof for Grover’s quadratic speedup.
4.9 Generalization to Multiple Marked Items
If there are marked items (rather than 1), Grover’s algorithm still works.
Define , and the rotation angle . The optimal number of iterations is:
The success probability is close to 1. When , , and a single iteration can find a marked item.
Special cases:
- If , classical random guessing is already fast, and the quantum speedup diminishes
- If is unknown, quantum counting can first estimate , then run Grover
- Quantum counting itself is a combination of Grover iteration and QPE
5. Shor’s Factoring Algorithm
5.1 Problem Definition and Classical Complexity
Problem: Given an -bit composite number (where are primes), find and .
Classical complexity (best known algorithm):
- General Number Field Sieve (GNFS): , sub-exponential but super-polynomial
- For large (e.g., RSA-2048, ), classical algorithms are completely infeasible
Quantum complexity: , polynomial time! This is the fundamental threat to RSA encryption security.
5.2 From Factoring to Period Finding: Detailed Reduction
The core insight of Shor’s algorithm is to convert factoring into a period-finding problem. The reduction proceeds in the following steps:
Step 1: Rule out trivial cases
If is even, directly output the factor 2. If for some , factor directly. These cases can be decided in polynomial time.
Step 2: Randomly choose
Randomly choose . Compute . If , a factor has already been found. Otherwise is coprime to .
Step 3: The period-finding problem
Consider the modular exponentiation function:
This function is periodic, because the finiteness of modular arithmetic guarantees the existence of a smallest such that (a generalization of Fermat’s little theorem; is the order of in the multiplicative group ). The period is precisely the period of the function .
Step 4: Converting period to factors
Theorem: If is even and , then and are both nontrivial factors of .
Proof:
From we have .
If is even, the product of and is divisible by :
If , then shares common factors with —these factors are precisely and .
Step 5: Handling failure
If is odd, or , choose another and repeat.
Success probability: for a randomly chosen , the probability of successfully finding a factor is at least (where is the number of distinct prime factors of ). For RSA keys (two distinct odd primes), , and the success probability is at least . Thus success is expected within attempts.
Complete reduction example
: randomly choose . . Compute :
| 0 | 1 | 1 |
| 1 | 7 | 7 |
| 2 | 49 | 4 |
| 3 | 343 | 13 |
| 4 | 2401 | 1 |
Period (even). , . Therefore:
Obtaining factors 3 and 5. ✓
5.3 Quantum Period Finding: Circuit Design
Period finding is the “quantum engine” of Shor’s algorithm; it uses Quantum Phase Estimation (QPE) to find the period of .
Overall circuit diagram (two registers):
|0⟩^⊗m —H^⊗m—•—•—•—•—•—•—•—•—H^⊗m—QFT†—[M]
| | | | | | | |
|0⟩^⊗L ——————U U U U U U U U—————————[M] (verification)
a² a a¹ a⁸
⁸ ⁴ ²
- Upper: qubit “counting” register ()
- Lower: qubit “working” register
- is the modular multiplication operator:
- Controlled are the building blocks of modular exponentiation
Modular Exponentiation
Modular exponentiation is the most expensive part of Shor’s algorithm. It is decomposed via the square-and-multiply method into a series of controlled modular multiplications:
The circuit implementation requires:
- Precomputing for (can be done on a classical computer as preprocessing)
- Using controlled modular multipliers : when the control qubit is , apply
- Cascading these controlled operations
Quantum resources: modular exponentiation requires elementary gates (using classically-assisted modular multiplication algorithms) and ancilla qubits.
Quantum Phase Estimation (QPE) for Period Finding
The detailed circuit implementation of QPE is in Part 5.2 of the tutorial. Here we outline its application in Shor’s algorithm:
Input register: initialized to (a superposition state).
Working register: initialized to .
For each bit (), apply the controlled operation:
The core result of QPE is: after running the inverse QFT () on the counting register, the measurement yields an approximation of the period :
where is a random integer between and .
Key mathematical derivation: the eigenstates of include: where .
The initial state can be expanded as a superposition of these eigenstates:
Thus QPE measures the phase with probability . Extracting from requires the continued fraction expansion.
5.4 Continued Fractions Algorithm
QPE outputs an -bit approximation of (an -bit binary fraction). We need to recover the denominator from .
Continued fraction expansion: any rational number can be uniquely represented as:
denoted compactly as .
Algorithm:
Starting from , iterate:
- (take the integer part)
- (take the reciprocal of the fractional part)
At the -th step, the convergent (the -th convergent of the QFT measurement value ) gives an approximation of :
with the recurrence relations:
Convergence theorem: if , then is a convergent of .
Application to Shor’s algorithm: choose (i.e., ); the precision guarantee of QPE is:
Thus one of the convergents of is . Check the denominator : if (or if the correct factorization is found), then .
Complete example: extracting the period from
Let , the true period , , so .
Suppose QPE outputs (a small error). Continued fraction expansion:
- ,
- ,
- ,
- ,
Convergents:
- → (check: , not the period)
- → (check: , correct!)
Thus .
5.5 Complete Worked Example: Factoring 15
This is the most classic pedagogical example of Shor’s algorithm.
Parameters:
- , (since )
- counting qubits
- Randomly choose ()
Step 1: Rule out trivial cases. 15 is odd and not a perfect power.
Step 2: Precompute :
| 0 | 1 | |
| 1 | 2 | |
| 2 | 4 | |
| 3 | 8 | |
| 4 | 16 | |
Note that for , .
Step 3: Prepare the counting register superposition.
The working register is .
Step 4: Apply controlled modular multiplications.
Since for , only the controlled modular multiplications for have a nontrivial effect. Thus:
Step 5: Apply the inverse QFT and measure.
Suppose the measurement yields (i.e., binary ).
Step 6: Continued fraction expansion.
→ .
Step 7: Verification and factoring.
. ✓ ✓
Possible historical difference: note that is used here. In actual quantum experiments (such as the photonic quantum implementation by Martin-López et al. 2012), the simpler is often used (because , period ), or (period ). The case is simpler because only one layer of controlled modular multiplication () is needed.
5.6 Complexity Analysis and Resource Estimates
Quantum gate complexity
| Subroutine | Gate complexity | Notes |
|---|---|---|
| Modular exponentiation | L is the number of bits, using classical modular multiplication + quantum controlled operations | |
| QFT / QFT† | QFT on m = 2L bits | |
| Total complexity | = |
Total quantum gate count estimate (using RSA-2048 as an example, ):
- Modular exponentiation: roughly elementary gates
- Ancilla qubits: roughly
- Required physical qubits (accounting for error correction): millions
Classical vs. quantum complexity summary table
| Operation | Classical complexity | Quantum complexity | Speedup |
|---|---|---|---|
| Integer factoring | Exponential | ||
| Discrete logarithm | Exponential | ||
| Elliptic curve discrete log | Exponential (breaks ECC) |
Resource estimate references:
| Number to factor | Bits | Classical GNFS time | Quantum gate count | Quantum time estimate* |
|---|---|---|---|---|
| 15 | 4 | Instant | ~10³ | Microseconds |
| 21 | 5 | Instant | ~10⁴ | Microseconds |
| 143 | 8 | Microseconds | ~10⁶ | Milliseconds |
| RSA-512 | 512 | ~10⁴ years | ~10¹⁰ | Hours |
| RSA-1024 | 1024 | ~10⁶ years | ~10¹¹ | Days |
| RSA-2048 | 2048 | ~10¹¹ years | ~10¹² | Years |
*Quantum time estimates are based on a physical gate rate of 1 MHz, highly idealized. In practice, error-correction overhead (roughly 10³–10⁴ times resource increase) must also be considered.
5.7 Threat Analysis of Shor’s Algorithm to RSA
Short term (<10 years): no threat. Requires millions of high-quality physical qubits, far beyond current levels.
Medium term (10–20 years): may threaten RSA-1024. Requires roughly 1 million physical qubits, with error-corrected gate fidelity > 99.9%.
Long term (20–30 years): threatens all RSA key lengths. NIST has already advanced PQC (Post-Quantum Cryptography) standardization; FIPS 203/204/205 were published in 2024.
Qubit resources: the optimized scheme of Gidney & Ekerå (2021) shows that factoring RSA-2048 requires roughly 2,000 logical qubits and roughly 20 million physical qubit gates, with a runtime of roughly 8 hours. This is far more optimistic than previous estimates (which required 10–100 times more resources), but the engineering implementation still faces enormous challenges.
6. Algorithm Complexity Comparison Table
| Algorithm | Problem | Classical complexity | Quantum complexity | Speedup type | Practical application |
|---|---|---|---|---|---|
| Deutsch-Jozsa | Constant/balanced decision | Exponential | Pedagogy | ||
| Bernstein-Vazirani | Hidden bit string | Linear | Pedagogy | ||
| Simon | Hidden period () | Exponential | Pedagogy, inspired Shor | ||
| Grover | Unstructured search | Quadratic | Database search, optimization | ||
| Shor | Integer factoring | Sub-exponential | Exponential | Breaking RSA |
Speedup type descriptions:
- Exponential speedup: quantum is exponentially faster than classical (advantage far exceeds a constant factor as problem size doubles)
- Quadratic speedup: quantum is faster by a square-root factor
- Linear speedup: quantum is faster by a constant factor
7. References and Further Reading
Original Papers
- Deutsch, D. & Jozsa, R. (1992). “Rapid solution of problems by quantum computation”. Proceedings of the Royal Society A, 439(1907), 553–558.
- Bernstein, E. & Vazirani, U. (1997). “Quantum complexity theory”. SIAM Journal on Computing, 26(5), 1411–1473.
- Simon, D. R. (1997). “On the power of quantum computation”. SIAM Journal on Computing, 26(5), 1474–1483.
- Grover, L. K. (1996). “A fast quantum mechanical algorithm for database search”. Proceedings of STOC 1996, 212–219.
- Shor, P. W. (1997). “Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer”. SIAM Journal on Computing, 26(5), 1484–1509.
- Bennett, C. H., Bernstein, E., Brassard, G., & Vazirani, U. (1997). “Strengths and weaknesses of quantum computing”. SIAM Journal on Computing, 26(5), 1510–1523. (BBBV optimality proof)
Textbooks and Reviews
- Nielsen, M. A. & Chuang, I. L. (2010). Quantum Computation and Quantum Information: 10th Anniversary Edition. Cambridge University Press. (Chapter 6: Quantum search algorithms; Chapter 5: QFT and Shor’s algorithm)
- Kaye, P., Laflamme, R., & Mosca, M. (2007). An Introduction to Quantum Computing. Oxford University Press.
- Mermin, N. D. (2007). Quantum Computer Science: An Introduction. Cambridge University Press.
- Jozsa, R. (1997). “Quantum algorithms and the Fourier transform”. Proceedings of the Royal Society A, 454(1969), 323–337.
In-Depth Topics
- Grover, L. K. (1998). “Quantum computers can search arbitrarily large databases by a single query”. Physical Review Letters, 79(23), 4709.
- Boyer, M., Brassard, G., Høyer, P., & Tapp, A. (1998). “Tight bounds on quantum searching”. Fortschritte der Physik, 46(4-5), 493–506.
- Brassard, G., Høyer, P., Mosca, M., & Tapp, A. (2002). “Quantum amplitude amplification and estimation”. Contemporary Mathematics, 305, 53–74. (Generalization of Grover)
- Kitaev, A. Y. (1995). “Quantum measurements and the Abelian stabilizer problem”. arXiv:quant-ph/9511026. (HSP framework)
- Gidney, C. & Ekerå, M. (2021). “How to factor 2048 bit RSA integers in 8 hours using 20 million noisy qubits”. Quantum, 5, 433. (Resource optimization milestone)
- Beauregard, S. (2003). “Circuit for Shor’s algorithm using 2n+3 qubits”. Quantum Information and Computation, 3(2), 175–185.
- Martin-López, E. et al. (2012). “Experimental realization of Shor’s quantum factoring algorithm using qubit recycling”. Nature Photonics, 6, 773–776. (First complete demonstration of Shor’s algorithm factoring 15)
Internal Tutorial References
- Part 1.8: Mathematical form of the Discrete Fourier Transform (DFT)
- Part 5.1: Detailed construction of the QFT circuit (controlled-phase gates, cascade structure)
- Part 5.2: Quantum Phase Estimation (QPE) algorithm—the quantum engine of Shor’s algorithm
Document version: v1.0
Last updated: 2026-06-03
Associated tutorial: Quantum Computing Primer—From First Principles (Part 3.6, Part 5.1, Part 5.2)
Writing principles: Standard quantum computing notation, consistent with the mathematical and physical foundations of Parts 1–3 of the tutorial