Skip to main content
KetQat

Appearance

Algorithm · intermediate

Quantum order finding

Finds the multiplicative order r of a modulo N by phase estimation of the modular multiplication unitary on the state |1>, which returns a random multiple s/r of 1/r to 2L+1 bits, followed by the continued-fraction algorithm; O(L^3) gates per run with schoolbook arithmetic.

Established resultMachine-checkedUpdated 2026-12-01 · last verified 2026-12-01

AI-assisted text, machine-checked, not yet reviewed by a person. Citations resolve and an automated pass compared the statements with the cited sources. That is not peer review; check the sources for anything you depend on.

The unitary. On an LL-qubit register let Ua∣y⟩=∣ay mod N⟩U_a\ket{y} = \ket{a y \bmod N} for 0≤y<N0 \le y < N and Ua∣y⟩=∣y⟩U_a\ket{y} = \ket{y} for N≤y<2LN \le y < 2^L. It permutes basis states (because aa is invertible modulo NN), so it is unitary, and Ua2j=Ua2j mod NU_a^{2^j} = U_{a^{2^j} \bmod N} costs no more than UaU_a.

Its eigenvectors. For s=0,…,r−1s = 0, \dots, r-1 let

∣us⟩=1r∑k=0r−1e−2πisk/r ∣ak mod N⟩.\ket{u_s} = \frac{1}{\sqrt r}\sum_{k=0}^{r-1} e^{-2\pi i s k/r}\, \ket{a^k \bmod N} .

Since Ua∣ak⟩=∣ak+1⟩U_a\ket{a^k} = \ket{a^{k+1}} and ar≡1a^r \equiv 1, re-indexing the sum gives Ua∣us⟩=e2πis/r∣us⟩U_a\ket{u_s} = e^{2\pi i s/r}\ket{u_s}. Summing over ss, the phases cancel except at k=0k = 0: r−1/2∑s=0r−1∣us⟩=∣1⟩r^{-1/2}\sum_{s=0}^{r-1}\ket{u_s} = \ket{1}. So the easily prepared state ∣1⟩\ket{1} is a uniform superposition of eigenvectors whose phases are s/rs/r.

Procedure.

  1. Run phase estimation on UaU_a with target ∣1⟩\ket{1} and t=2L+1+⌈log⁡2(2+1/(2ε))⌉t = 2L + 1 + \lceil \log_2(2 + 1/(2\varepsilon)) \rceil control qubits; read the result as x=m/2tx = m/2^t.
  2. Compute the continued-fraction convergents of xx; for each denominator q<Nq < N in increasing order, test whether aq≡1(modN)a^{q} \equiv 1 \pmod N, and output the first such qq.

Correctness. By the superposition remark in the phase estimation record, step 1 behaves as phase estimation on ∣us⟩\ket{u_s} for an ss uniform in {0,…,r−1}\{0, \dots, r-1\}. By the accuracy theorem with n=2L+1n = 2L + 1, with probability at least 1−ε1 - \varepsilon, ∣x−s/r∣≤2−(2L+1)≤1/(2N2)<1/(2r2)\lvert x - s/r\rvert \le 2^{-(2L+1)} \le 1/(2N^2) < 1/(2r^2), using r<N≤2Lr < N \le 2^L (for s≥1s \ge 1 the distance modulo 1 coincides with the ordinary distance, as s/rs/r is at least 1/r1/r away from 0 and 1; s=0s = 0 is a failed run). The convergent theorem then puts s/rs/r in lowest terms, s′/r′s'/r', among the convergents of xx. If gcd⁡(s,r)=1\gcd(s, r) = 1 then r′=rr' = r and step 2 returns rr; otherwise r′r' is a proper divisor of rr and the test ar′≡1a^{r'} \equiv 1 fails for it. The probability that a uniform ss is coprime to rr is φ(r)/r=Ω(1/log⁡log⁡r)\varphi(r)/r = \Omega(1/\log\log r), so O(log⁡log⁡N)O(\log\log N) repetitions suffice; combining the denominators of two runs by their least common multiple reduces this to a constant expected number of runs (section 5.3.1 of Nielsen and Chuang).

Cost. The quantum part is dominated by the t=O(L)t = O(L) controlled modular multiplications. With schoolbook arithmetic each costs O(L2)O(L^2) gates, giving O(L3)O(L^3) gates per run; with fast multiplication Shor obtains O(L2log⁡Llog⁡log⁡L)O(L^2 \log L \log\log L). The inverse QFT on tt qubits costs O(L2)O(L^2) gates, or O(Llog⁡L)O(L\log L) approximately. The classical continued-fraction step costs O(L3)O(L^3) bit operations.

The algorithm is Shor's; the eigenvector formulation as phase estimation is due to Kitaev and Cleve, Ekert, Macchiavello and Mosca.

Holds when

  • N≥3N \ge 3 with L=⌈log⁡2N⌉L = \lceil \log_2 N \rceil bits, and a∈ZN∗a \in \Z_N^\ast of unknown order rr.
  • A reversible circuit for controlled modular multiplication by a2j mod Na^{2^j} \bmod N for each jj (the classical computer precomputes these constants).
Part of
Stated in

Open in the knowledge graph

Contributions about this record

Nobody has published a contribution about it yet.

Publish a result, reproduction or commentPropose a correction to this page

References

  1. Peter W. Shor (1997). Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer. SIAM Journal on Computing 26(5), 1484-1509. doi:10.1137/S0097539795293172arXiv:quant-ph/9508027
  2. A. Yu. Kitaev (1995). Quantum measurements and the Abelian stabilizer problem. arXiv:quant-ph/9511026
  3. Richard Cleve, Artur Ekert, Chiara Macchiavello, Michele Mosca (1998). Quantum algorithms revisited. Proceedings of the Royal Society A 454, 339-354. doi:10.1098/rspa.1998.0164arXiv:quant-ph/9708016
  4. Michael A. Nielsen, Isaac L. Chuang (2010). Quantum Computation and Quantum Information (10th Anniversary Edition). Cambridge University Press. doi:10.1017/CBO9780511976667

Contributors

  • KetQat maintainers · @ketqatConceptualization; Supervision (CRediT roles)
  • Claude (AI drafting assistant)Writing, original draft (CRediT roles)

Review history

  1. Automated source check · Pass · 2026-12-01 · Independent automated verification pass (AI, not the drafting session)

    Eigenvector identities and |1> = r^(-1/2) sum_s |u_s> re-derived; the chain |x - s/r| < 2^-(2L+1) <= 1/(2N^2) < 1/(2r^2) and the modulo-1 remark checked; also checked that no later convergent with denominator below N exists in the good event. Numerical check: for every N in 3..39 and every a coprime to N, the exact outcome distribution with t = 2L+1 was computed and the record's step 2 applied; whenever x was within 2^-(2L+1) of some s/r with s >= 1 the output was r or nothing, and the per-run success probability was at least 0.25. Cost O(l^2 log l log log l) with fast multiplication compared with Shor arXiv:quant-ph/9508027 Section 3; eigenvector formulation with Cleve-Ekert-Macchiavello-Mosca arXiv:quant-ph/9708016 Section 6 and Kitaev's abstract; Nielsen-Chuang Section 5.3.1 via the publisher's table of contents.

Revision history

  1. 2026-12-01Content release 2.1.0: 35 more topics, an independent source check of every record, intake hardening (#17)80537b7e
  2. 2026-11-30KetQat Commons: free learning paths, knowledge records, research problems, literature intake (#14)571c9b10

Current revision 44766eb48e7bf867. Source file knowledge/records/algorithm/order-finding.md in the content repository (readable there once it is public).