← Atlas

Algorithms · Computational number theory

Primality proving by quantum order finding

Prove that a given integer N is prime, or in most cases prove it composite and produce a witness, rather than merely declaring it probably prime as a randomized primality test does.

Attested & literatureUpdated

Open on the mapView frozen graph

A small worked example, computed in your browser. It is not a result from this record's papers.

Order-finding for 7 mod 15

3 counting qubits, 4 work qubits, finding the order of 7 modulo 15 (the order is 4: 7⁴ mod 15 = 1).

q0q1q2q3q4q5q6Step 1 of 5 · XXStep 2 of 5 · Hadamard layer(3)Hadamard layer(3)Step 3 of 5 · Controlled x7 mod 15Controlled x7 mod 15Step 4 of 5 · Controlled x4 mod 15Controlled x4 mod 15Step 5 of 5 · QFT inverse(3)QFT inverse(3)

Step 1 of 5 · X

Probability of each outcome after this step

  • 0001000100%
  1. Prepares the work register as |0001⟩ = 1.

    The whole state moves from 0000000 to 0001000 — one certain outcome before, one certain outcome after, no superposition either side.

  2. Spreads the 3 counting qubits into an equal superposition of all 8 values.

    Probability spreads from 1 outcome to 8. All 8 are equally likely.

  3. Multiplies the work register by 7 mod 15, controlled by the first counting qubit: the k=0 controlled power of the order-finding unitary.

    Probability moves: 4 outcomes appear that had none, 4 drop to zero, 8 carry probability now. Down: 0001001 12.5% → 0.0%, 0001011 12.5% → 0.0%. This is the step that entangles the qubits: from here on no single qubit has a state of its own, only the register as a whole does.

  4. Multiplies the work register by 4 mod 15 (7 squared, mod 15), controlled by the second counting qubit: the k=1 controlled power. The k=2 power would multiply by 7⁴ mod 15 = 1, so it is the identity and is left out entirely.

    Probability moves: 4 outcomes appear that had none, 4 drop to zero, 8 carry probability now. Up: 0100010 0.0% → 12.5%. Down: 0001010 12.5% → 0.0%, 0001110 12.5% → 0.0%.

  5. An inverse QFT on the counting register reads the phase found by the controlled multiplications into a 3-bit estimate.

    Probability moves: 12 outcomes appear that had none, 4 drop to zero, 16 carry probability now. Down: 0111001 12.5% → 0.0%, 0111101 12.5% → 0.0%.

Readout The counting register reads 000, 010, 100 or 110, each equally likely, corresponding to the four powers k = 0, 1, 2, 3 of the order r = 4; the work register ends entangled with the counting outcome, holding one of 1, 7, 4 or 13. Repeating this and applying the continued-fractions step of the full algorithm to a nonzero outcome recovers the order r = 4 exactly.

Open in Studio
  • Record typeLiterature reference
  • Speedup class (secondary source)Polynomial
  • Primary source on the speedupStated by the primary source: "Its complexity is essentially quadratic in the asymptotic limit, which is more efficient than classical tests that prove primality with certainty, which are usually restricted to integers of a particular form, or require a number of operations of the order of the sixth power of the number of bits (AKS test)."
  • Reported costO((log n)² n³) operations for an n-bit number N, reducible to O(log log n (log n)³ n²) in the asymptotic limit if fast multiplication is used. The paper states that this reduces the asymptotic complexity of the earlier Chau-Lo quantum primality test from O((log n)(log log n) n³) to O((log log n)(log n)³ n²).
  • Papers1
TakesNothingWhat joins here

No input port at this edge: the record publishes no gate sequence and no register, so there is nothing here to read one off — and unlike a declared hole, nothing has been recorded about what belongs here.

Nothing in the Atlas meets this end.

ReturnsNothingWhat joins here

No output port at this edge: the record publishes no gate sequence and no register, so there is nothing here to read one off — and unlike a declared hole, nothing has been recorded about what belongs here.

Nothing in the Atlas meets this end.

This record publishes no gate sequence and no register, so there is nothing here to read an interface off. Absent rather than empty. See all 152 →

References

  • A quantum primality test with order finding

    Alvaro Donis-Vela, Juan Carlos Garcia-Escartin · 2017

    Primary source, and the source of this record's cost claim. Consult it for the classical Fermat screen that decides when the quantum subroutine is worth invoking, for the black-box treatment of order finding that every stated figure depends on, and for the passage where the authors accept losing the classical certificate of primality in exchange for a quantum one.

Attested & literature
  • Peer-reviewed paper
Method
Curation only. The problem statement was recorded from the literature; the speedup class is checked against the record's own primary paper, which states it; the primary reference's title, authors and submission year were read from its arXiv abs page; the complexity claim was taken from a clause of that paper's abstract (abstract of arXiv:1711.02616: "The algorithm requires O((log n)^2 n^3) operations for a number N with n bits, which can be reduced to O(log log n(log n)^3 n^2) operations in the asymptotic limit if we use fast multiplication."; body: "The total expected complexity of our algorithm is O((log n)^2 n^3) for the log n repetitions needed to find an element of order N − 1 with high probability."; and, for the comparison with the earlier test: "Our algorithm reduces the asymptotic complexity of the Chau-Lo quantum primality test from O((log n)(log log n)n^3) to O((log log n)(log n)^3n^2)."). No circuit was constructed, simulated or run.
Result
Pass · the record's problem, speedup class and primary reference agree with the two sources named above.
Caveat
This is a literature record: no circuit was built, compiled, simulated or run, and no integer was tested here. The stated complexity treats quantum order finding as a black box costing O((log n) n³) operations rather than as an implemented primitive, so the figures inherit whatever that subroutine actually costs, including its error-correction overhead, which is not addressed. The faster asymptotic bound requires fast multiplication, and the paper says the constant factors make it worthwhile only in the asymptotic limit for very large N, so it is not the figure that applies at practical sizes. The test trades away something real: the authors state that they lose the classical certificate of primality of the Chau-Lo test and offer a quantum certificate instead, so the output cannot be checked on a classical machine. Compositeness is proved with certainty and a witness only most of the time; otherwise, after a bounded number of unsuccessful attempts, the algorithm declares N composite with high probability rather than certainty. The comparison with the AKS test is against a deterministic classical algorithm that proves primality with certainty, which is a narrower class than primality testing in general, and the paper notes that no classical algorithm is known that determines the order of an integer efficiently — so this is not a speedup over an available classical primitive but a method that is quantum by construction.
A quantum primality test with order finding ↗
Kind
curated reference
Reviewed by
Leona Quantum curation pass
License
Citation metadata only; source publication terms apply
primality provingorder findinglucas theoremaks testnumber theory

Atlas stars stay in the public catalog. Saving this entry to your workspace starts an unstarred private copy.