Skip to content
Current section
The Quantum Computing Enthusiast’s Hub
Saved
All sections

All sections

Saved
Skip Learn navigation
Encyclopedia
Topic

Modular exponentiation in order finding

The coherent computation of a power modulo an integer, used to expose a periodic structure in Shor-type algorithms.

Edition released Coverage: Overview · Technical
On this page

Definition and significance

Modular exponentiation computes a^x mod N while preserving the exponent register. It is a major arithmetic component of order finding. Its gate cost can dominate a complete factoring circuit, so the Fourier transform alone does not describe the algorithm's resources.

Mechanism and mathematical treatment

For x=sum_k x_k 2^k, a^x mod N is the product of precomputed constants a^(2^k) mod N for which x_k=1. Controlled modular multipliers implement these factors coherently. Multiplication by a modulo N is a permutation on valid residues when gcd(a,N)=1; behavior on unused basis states must also be defined to obtain a full unitary.

Fully worked reference example

For a=2 and N=15, the constants are 2,4,1,1,... because 2^4=1 modulo 15. Exponent x=3 has bits 11, so multiplying 2 and 4 gives 8 modulo 15. Exponent x=5 selects constants 2 and 1, giving 2, consistent with period four.

Limitations and common misconceptions

Toy circuits may simplify constants using a known small period, making them unsuitable evidence for scalable unrestricted modular arithmetic. Workspace cleanup and controlled arithmetic must be included in resource counts.

Scientific relationships

The periodic arithmetic supplies the order-finding instance.

Controlled addition and multiplication construct modular powers.

Modular exponentiation with a period-six example

Choose N=21 and base a=2. Five exponent bits x0 through x4, listed in increasing arithmetic significance, control multiplications by the classically precomputed residues 2, 4, 16, 4, and 16. These values follow by repeated squaring modulo twenty-one: square 2 to get 4, square 4 to get 16, and square 16 to get 4. Computing this short constant list does not require a supplied order, even though its repetition is visible in the small example.

For exponent x=19, the active bits are x0=x1=x4=1. Starting the residue register at one, the successive active multiplications give 1 to 2, 2 to 8, and 8 to 128 mod 21=2. The inactive controls leave the intermediate residue unchanged. Direct classical modular exponentiation agrees: 2 to the nineteenth is congruent to two modulo twenty-one. Starting the residue register at five instead would produce ten, because this circuit multiplies an arbitrary valid residue by the selected power; preparing the initial residue one is part of its function-evaluation use.

Completing the arithmetic as a unitary

Multiplication by two permutes the twenty-one valid residue labels. Its cycles are (0), (1,2,4,8,16,11), (3,6,12), (5,10,20,19,17,13), (7,14), and (9,18,15). These disjoint cycles account for every valid label exactly once. Five qubits also represent labels twenty-one through thirty-one. Defining multiplication to act as identity on those extra labels completes a valid permutation unitary on the full thirty-two-dimensional register.

The inverse valid-domain multiplier is multiplication by eleven, since 2 times 11 is one modulo twenty-one. The unused-label extension must be inverted consistently as well. An arithmetic circuit that agrees only on the orbit of the initial residue one has a weaker correctness guarantee than this full valid-residue permutation. Exploiting a known tiny orbit can be legitimate for a declared demonstration, but it cannot support a general modular-arithmetic resource claim.

The controlled operation is identity on the inactive exponent branch and the full multiplier on the active branch. Its scalar phase must therefore be fixed consistently. Workspace used by multiplication is returned to a state independent of both exponent and residue. Otherwise the exponent register can remain correlated with arithmetic garbage, altering the interference used by order finding even when the final residue labels appear correct.

The joint state before Fourier sampling

For a uniform superposition over exponents zero through thirty-one, the computed state is sum_x |x>|2^x mod 21>/sqrt(32). The six residues on the orbit of one are 1, 2, 4, 8, 16, and 11. The first two occur six times each in that finite exponent interval; each of the other four occurs five times. A measurement of the residue register therefore gives probabilities 6/32, 6/32, and four copies of 5/32.

If the measured residue is eight, the exponent register becomes the normalized superposition of labels 3, 9, 15, 21, and 27. It is a period-six comb truncated by a register of size thirty-two. Because six does not divide thirty-two, its Fourier distribution has broadened peaks rather than support on exact reciprocal labels. This broadening is already present in the perfect arithmetic and ideal transform. It should not be interpreted as a noise signature.

Measuring the residue is optional when only the exponent's subsequent distribution is required: tracing out that register produces the same mixture of comb states. Keeping it coherent can matter in a larger construction, however. A statement about optional measurement relies on the specified downstream use, not on an assertion that the two joint states are identical.

Arithmetic costs and a matched classical baseline

A simple constant modular multiplier can be built from a linear number of controlled modular additions in the residue bit width n. With linear-cost ripple arithmetic, this gives a quadratic-order gate cost per multiplier in that width. An m-bit exponent then requires m controlled multipliers, giving a conventional O(m n squared) arithmetic scale before more detailed compilation. This is a construction-level estimate with specified schoolbook assumptions, not an optimal lower bound or a physical runtime.

Classical repeated squaring efficiently computes a single modular power and verifies recovered candidates. The quantum circuit's distinctive role is maintaining the exponent-residue relation coherently for interference, not making ordinary one-input exponentiation intrinsically faster. The complete order-finding ledger also includes exponent preparation, arithmetic ancillas, controlled synthesis, Fourier processing, repeated trials, and classical gcd computations. Small constants that become identity should be reported openly because they can drastically simplify a particular example.

The five controlled constants generate the cycles on the valid domain. Conditioning on residue eight selects a five-label comb. Unused labels are left fixed by the identity extension. The cycle and probability calculations are ideal predictions for the stated construction.

Sources

  • Peter W. Shor · · Research paper · Publication status unspecified · arXiv · DOI 10.1137/S0097539795293172
    Verification scope

    Selected source text checked ·

    Polynomial-time ideal-circuit result; new small numerical instances are original illustrations.

  • Steven A. Cuccaro; Thomas G. Draper; Samuel A. Kutin; David Petrie Moulton · · Research paper · Publication status unspecified · arXiv
    Verification scope

    Recorded source check ·

    The version date comes from the arXiv submission record.

    Theoretical or mathematical source anchor; original definitions and worked instances are independent. No experimental or end-to-end performance claim inferred.