Cyclic periodicity on implies that the least positive period divides : the shifts preserving the function form a subgroup of the cyclic group. Injectivity within one period says that distinct residue classes modulo have distinct function values. Write .
Prepare the uniform superposition state by applying the quantum Fourier transform to , and evaluate reversibly into a second quantum register. This is efficient because the given classical Boolean circuit can be converted into a reversible circuit, with its workspace cleaned by uncomputation. The resulting quantum state is
Measuring the function quantum register leaves a uniform coset state for some . The amplitude at after a quantum Fourier transform is
The finite geometric series is zero unless is a multiple of , and then equals . Thus a computational-basis measurement produces a uniform Fourier sample
The exact period recovery from a Fourier sample computes
A greatest common divisor is computable in time polynomial in . The candidate is always a divisor of the true period, and equals it precisely when is coprime to .
For the success flag, compute and compare with . If , injectivity within the first period makes these unequal. If , periodicity makes them equal, including . Hence accept and output exactly when this comparison succeeds; otherwise report failure. This is heralded exact quantum period finding when the period divides the register size, with no false acceptance. The case succeeds even on the sample .
The exact success probability is
where is the Euler totient function. For , the prime-product formula gives . A Rosser–Schoenfeld totient bound supplies the needed lower bound for large . Every single attempt, including verification, has the assumed polynomial-in- gate cost. Repeating times gives constant success probability with a certified result whenever one is found.
The printed in the totient hint should be a lower-bound statement, . Literally, is false: at primes , . Likewise the exact single-sample success probability need not be ; for prime period it tends to one. The useful intended guarantee is the displayed inverse-log-log lower bound, not a universal upper bound. If an algorithm satisfying the literal success upper bound is desired, one can additionally accept an otherwise certified run only when independent fair bits are all zero. This retains a detectable failure flag and polynomial runtime, and has success at most , but deliberately weakens the useful guarantee. The standard unsuppressed algorithm above gives the stronger intended performance. Small can be handled directly. Primary evidence for the totient lower bound is Theorem 15, equations (3.41)–(3.42), in denisevellachemla.eu/Rosser-Schoenfeld-1962.pdf .
Use the positive-sign quantum Fourier transform
Orthogonality of the finite-group characters makes a unitary operator. Here is the least positive period. The injectivity within one period implies : write , . Periodicity gives , and injectivity forces . Put .
Start with two available computational basis states . Apply to the first register and query the modular-addition quantum oracle:
Measure the second register. For some , the first register becomes the normalized coset state
The quantum Fourier transform of a periodic coset state is
Indeed, the inner geometric sum vanishes unless the Fourier label is a multiple of . Measuring that label gives for a uniformly random . Compute, by the Euclidean algorithm,
Thus exact period recovery from a Fourier sample succeeds whenever is coprime to , and
Here is the Euler totient function. The classical number-theory input is the totient lower bound from the Mertens product: for sufficiently large , for an absolute , with the finitely many small cases handled separately. For recovery is certain; for its probability is . The useful asymptotic probability statement is a lower bound, hence notation; it can be much larger for particular periods, for example a prime period.
There is one oracle query, two Fourier transforms and two measurements. The final greatest common divisor and division use polynomial time in . This meets the specified primitive-operation model without assuming that an arbitrary- Fourier gate is free in another gate model. If a constant success probability is wanted, repeat independently times and return the least common multiple of the candidates: each candidate divides , and one successful sample makes that least common multiple exactly .
Use the positive-exponent quantum Fourier transform convention . The period of a function here is the least positive translation leaving the function unchanged on the cyclic group . The injective promise means exactly when . In particular : the subgroup of period translations is generated by , and wrapping the argument by preserves its value. This is exact quantum period finding on a finite cyclic group, rather than the truncated, nondividing-period version requiring continued fractions.
Prepare a uniform superposition state in the first quantum register using , and perform a reversible computation of the function into a second quantum register, cleaning its workspace by uncomputation:
A quantum measurement in the computational basis of the second quantum register leaves a periodic coset state in the first:
For the quantum Fourier transform of this periodic coset state, the finite geometric series vanishes unless the measured label is . On those labels its normalized amplitude is . Thus has the uniform distribution on a finite set on , irrespective of .
Compute the greatest common divisor by the Euclidean algorithm, and set , with . Since ,
The exact period recovery from a Fourier sample is therefore certified by testing . Every candidate divides and lies between and , so the injective promise makes that equality equivalent to . This includes , where the test uses input , and , which always succeeds. The test does not assert that an arbitrary equality of function values certifies an arbitrary period; the Fourier-derived divisor restriction is essential.
The concise result is
Here is the Euler totient function, with . The totient lower bound from the Mertens product gives for . Each trial uses polynomial time quantum Fourier transforms, function evaluations and Euclidean algorithm arithmetic in . Repeating independent trials gives constant success probability; the herald accepts only correct answers.
The printed asymptotic bound has the wrong direction for this argument. In Big O notation, the stated upper bound on the number of coprime integers supplies no success lower bound and is itself false uniformly: for prime , , not . Likewise the single-trial success need not be , since it tends to one for prime. The meaningful corrected guarantee is the lower bound above. If an upper-bounded success rate is literally required, one may deliberately retain an accepted result with an independent probability proportional to ; this discards useful successes and is unnecessary for efficient recovery.
Measure the second register of . If the result is , injectivity within one period collapses the first register to the periodic coset state
Apply and measure the first register. By the stated transform identity, the outcome is
for a uniformly random .
Reduce the rational number
to lowest terms and call its denominator . The exact period recovery from a Fourier sample gives
Thus exactly when is coprime to .
The success can be certified with two classical function evaluations. Compute and . Since and , periodicity and injectivity within a period imply
Report only when this equality holds; otherwise report failure. The success probability is
using the standard lower bound for the Euler totient function. This is heralded exact quantum period finding when the period divides the register size.
The distinct values in one period imply that is the least positive period, , and . Write , where and . Use the positive-exponent quantum Fourier transform convention already used in the concept article. The amplitude of first-register value is
By the root-of-unity filter, the inner sum vanishes unless . Define
The distinct give an orthonormal basis of the second register, and the transformed state is
Reindexing modulo shows
Consequently measurement in this common eigenbasis returns each with probability ; the corresponding eigenvalue of is a uniformly sampled th root of unity. A single measured phase reveals the denominator , which need not be . Repeated samples permit exact period recovery from a Fourier sample, for example by taking the least common multiple of their reduced denominators. The simultaneous eigenspaces and their probabilities depend on , not on the particular labels .
The two registers start in . A quantum Fourier transform on the first and evaluation of give
The first measurement, on the function register, returns . The compatible inputs are , so the normalized state becomes
Apply to the first register and put . Its state is
The geometric sum vanishes unless . Thus this is
up to the unchanged second register. The outcomes each have probability , in accordance with the quantum Fourier transform of a periodic coset state.
For the stated second outcome,
The continued-fraction algorithm therefore returns denominator . Since the numerator is coprime to the true period, exact period recovery from a Fourier sample succeeds, and direct evaluation confirms that the least period is