This is the user sandbox of MARKALOIDE. A user sandbox is a subpage of the user's user page. It serves as a testing spot and page development space for the user and is not an encyclopedia article. Create or edit your own sandbox here.
Finished writing a draft article? Are you ready to request review of it by an experienced editor for possible inclusion in Wikipedia? Submit your draft for review!
The quantum circuits used for this algorithm are custom designed for each choice of and each choice of the random used in . Given , find such that , which implies that . The input and output qubit registers need to hold superpositions of values from to , and so have qubits each. Using what might appear to be twice as many qubits as necessary guarantees that there are at least different values of that produce the same , even as the period approaches .
Proceed as follows:
Initialize the registers of qubits to the zero-position where .
Apply the hadamard gate in parallel to each of the qubits to get
where denotes the tensor product. This state is a superposition of states where every qubit is a superposition of 0 and 1.
Construct as a quantum function and apply it to the above state, to obtain
This is still a superposition of states. However, the qubits, i.e, the input qubits and () output qubits, are now entangled or not separable, as the state cannot be written as a tensor product of states of individual qubits.
Apply the inverse quantum Fourier transform to the input register. This transform (operating on a superposition of states) uses a -th root of unitysuch as to distribute the amplitude of any given state equally among all of the states, and to do so in a different way for each different . We thus obtain
This leads to the final state
Now, we reorder this sum as
This is a superposition of many more than states, but many fewer than states, as there are fewer than distinct values of . Let
be a -th root of unity,
be the period of ,
be the smallest of the for which (we actually have ), and
write
indexes these , running from to , so that .
Then is a unit vector in the complex plane ( is a root of unity, and and are integers), and the coefficient of in the final state is
Each term in this sum represents a different path to the same result, and quantum interference occurs — constructive when the unit vectors point in nearly the same direction in the complex plane, which requires that point along the positive real axis.
Perform a measurement. We obtain some outcome in the input register and some outcome in the output register. As is periodic, the probability of measuring some state is given by
Analysis now shows that this probability is higher the closer the unit vector is to the positive real axis, or the closer is to an integer. Unless is a power of , it will not be a factor of .
Since is close to some integer , the known value is close to the unknown value . Performing [classical] continued fraction expansion on allows us to find approximations of it that satisfy two conditions: