QCQI – Chapter 7 Detailed Summary: Shor’s Algorithm & Phase Estimation
Learning Objectives¶
Understand Quantum Phase Estimation (QPE): circuit, accuracy, and semiclassical variants.
Reduce integer factoring to order finding and perform recovery via continued fractions.
Implement modular exponentiation with repeated squaring; reason about resources.
Analyze success probabilities and error sources (aQFT, imperfect order conditions).
Quantum Phase Estimation (QPE)¶
Given unitary with eigenpair and , QPE estimates the binary expansion . The -qubit phase register is prepared in and controls powers :
Applying on the phase register yields (with high prob.) .
Accuracy: if has an exact -bit expansion, success is 1. In general, .
Eureka! Control on turns global eigenphases into computational bits via .
Iterative (Semiclassical) Phase Estimation (IPEA)¶
Measure least significant bits first, feeding forward classically controlled -rotations to cancel known phases. Requires one control qubit reused times plus the eigenstate register.
Eureka! Measurements + classical feed-forward can replace 's entangling gates.
Order Finding & Shor’s Reduction¶
For odd composite and coprime to , the order of modulo is the least such that . Define ; then has eigenphases . QPE on returns .
Recover from via continued fractions; if the convergent is unique. With (), this holds with good probability.
From order to factors. If is even and , then are nontrivial factors.
Eureka! Number theory + QPE: the quantum part finds ; classical post-processing extracts factors.
Modular Exponentiation Circuit (Sketch)¶
Implement by repeated squaring:
For each bit , conditionally multiply the work register by the precomputed constant using reversible modular multiplication (adders + controlled adds, with uncomputation). Controlled- are realized by shifting which constants are applied.
Eureka! Exponentiation reduces to a sequence of controlled modular multiplies by fixed constants .
Resource Sketch (Factoring with bits)¶
Qubits: phase register ; work register ; ancillas depending on adder design.
Gates: modular exponentiation dominates: Toffoli/CNOT-level with textbook adders (improvable with advanced arithmetic).
Success Considerations¶
Random coprime to yields even and with probability . Repeat with fresh if needed. aQFT and finite only slightly reduce success; classical continued fractions are robust.
Worked Nuggets¶
Small- example: For , has order ; ; .
Continued fractions criterion: If then is a convergent of ’s CF expansion.
IPEA angle update: when estimating bit (LSB first), subtract the phase implied by bits already measured.
Pseudo-code Aids¶
Pseudocode — Quantum Phase Estimation (standard)
Input: unitary , eigenstate , phase qubits Prepare for to : apply controlled- with control qubit apply to the controls; measure to get return
Pseudocode — Iterative Phase Estimation (IPEA)
Input: , bits for down to 1: prepare control in apply controlled- apply to cancel phases from previously obtained bits apply ; measure to obtain bit
Pseudocode — Shor (Factoring )
Repeat: pick random ; if , return factor run order-finding via QPE on to get if odd or : continue else return
Schematics¶
QPE Circuit (concept)¶
Order-Finding Post-Processing¶
Hands-on Notebook (Multi-Backend)¶
Run: L09
In the first cell set backend to one of: cirq, pennylane, braket, pyquil, or qiskit.
Mini-Lab Ideas¶
QPE on and compare to true .
IPEA vs standard QPE: shots vs. accuracy trade-off.
Order-finding for with small ; recover from CF and verify .