Next: Other Quantum Algorithms
Up: Quantum Algorithms
Previous: Overview of Shor's Algorithm
Contents
Shor's algorithm for factoring a given integer
can be broken into
some simple steps.
- Determine if the number
is a prime, a even number, or an integer
power of a prime number. If it is we will not use Shor's algorithm.
There are efficient classical methods for determining if a integer
belongs to one of the above groups, and providing factors for it if it
does. This step would be performed on a classical computer.
- Pick a integer
that is the power of 2 such that
. This step would be done on a classical computer.
- Pick a random integer
that is coprime to
. When two numbers
are coprime it means that their greatest common divisor is 1. There
are efficient classical methods for picking such an
. This step
would be done on a classical computer.
- Create a quantum register and partition it into two sets, register one
and register two. Thus the state of our quantum computer can be given
by:
reg1, reg2
. Register one must have enough
qubits to represent integers as large as
. Register two must
have enough qubits to represent integers as large as
.
- Load register one with an equally weighted superposition of all
integers from 0 to
. Load register two with the 0 state. This
operation would be performed by our quantum computer. The total state
of the quantum memory register at this point is:
- Apply the transformation
to for each number stored in
register one and store the result in register two. Due to quantum
parallelism this will take only one step, as the quantum computer will
only calculate
, where
is the superposition of states created in step 5.
This step is performed on the quantum computer. The state of the
quantum memory register at this point is:
- Measure the second register, and observe some value
. This has the
side effect of collapsing register one into a equal superposition of
each value a between 0 and
such that
This operation is performed by the quantum computer. The state
of the quantum memory register after this step is:
Where
is the set of
's such that
,
and
is the number of elements in that
set.
- Compute the discrete Fourier transform on register one. The discrete
Fourier transform when applied to a state
changes it in the following manner:
This step is performed by the quantum computer in one step
through quantum parallelism. After the discrete Fourier transform our
register is in the state:
- Measure the state of register one, call this value
, this
integer
has a very high probability of being a multiple of
,
where
is the desired period. This step is performed by the quantum
computer.
- Take the value
, and on a classical computer do some post
processing which calculates
based on knowledge of
and
.
There are many ways to do this post processing, they are complex are
are omitted for clarity in presentation of the quantum core of Shor's
Algorithm. This post processing is done on a classical computer.
- Once you have attained
, a factor of
can be determined by
taking
and
. If you have
found a factor of
, then stop, if not go to step 4. This final
step is done on a classical computer.
Step 11 contains a provision for Shor's algorithm failing to produce
the factors of
. Shor's algorithm can fail for multiple reasons,
for example the discrete Fourier transform could be measured to be 0
in step 9, making the post processing in step 10 impossible. At other
times the algorithm will sometimes find factors of 1 and
, which is
correct but not useful. (Williams, Clearwater)
Next: Other Quantum Algorithms
Up: Quantum Algorithms
Previous: Overview of Shor's Algorithm
Contents
Matthew Hayward
2008-04-26