User:MARKALOIDE/sandbox

Notation edit

  •   denotes the tensor product. The notation is used to concatenate two qubits.
  •   for   denotes qubits. The notation is used for both a column vector and a tensor. For example,   is a 1-qubit in the zero-state, and   is a 2-qubits.


routine ===

 
Quantum subroutine in Shor's algorithm.

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:

  1. Initialize the registers of   qubits to the zero-position where  .
  2. 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.

  1. Construct   as a quantum function and apply it to the above state, to obtain
 
 
  1. 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.
  2. Apply the inverse quantum Fourier transform to the input register. This transform (operating on a superposition of   states) uses a  -th root of unity such 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.

  1. 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  .

  1. 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: