Skip to main content

order_finding

Function order_finding 

Source
pub fn order_finding(
    base: u64,
    modulus: u64,
    counting_qubits: usize,
) -> QuantumResult<OrderFindingResult>
Expand description

Quantum order finding for the unitary U_a|y⟩ = |a·y mod N⟩.

Runs phase estimation with counting_qubits in the counting register and a ⌈log2 N⌉-qubit work register initialised to |1⟩. The eigenphases of U_a are k/r, so the argmax readout φ ≈ k/r is fed through continued_fraction_convergents to extract the period r (verified by a^r ≡ 1). The modular-multiplication ladder is applied exactly on the amplitude array (controlled U_a^{2^j} = multiply by a^{2^j} mod N), so no gate-level modular-arithmetic synthesis is required.

§Errors