The publication of Shor's quantum algorithm for efficiently factoring numbers [4,5] was the key event that stimulated many theoretical and experimental investigations of quantum computation. One of the reasons why this algorithm is so important is that the security of widely used public key cryptographic protocols relies on the conjectured difficulty of factoring large numbers. An elementary overview of these protocols and the quantum algorithm for breaking them is in [15]. Here, we outline the relationship between factoring and the powerful technique of phase estimation. This relationship helps in understanding many of the existing quantum algorithms and was first explained in [16], motivated by Kitaev's version [17] of the factoring algorithm.
The factoring problem requires writing a whole number
as a product
of primes. (Primes are whole numbers greater than
that are
divisible without remainder only by
and themselves.) Shor's
algorithm solves this problem by reducing it to instances of the
order-finding problem, which will be defined below. The reduction is
based on basic number theory and involves efficient classical
computation. At the core of Shor's algorithm is a quantum algorithm
that solves the order-finding problem efficiently. In this case, an
algorithm is considered efficient if it uses resources bounded by a
polynomial in the number of digits of
. For more
information on the requisite number theory, see any textbook on number
theory [18,19].
We begin by showing that factoring reduces
to order finding. The first observation is that to factor a whole number it
is sufficient to solve the factor-finding problem, whose statement is:
Given a whole number
find a proper factor of
, if one exists.
A ``factor'' of
is a whole number
that satisfies
for
some whole number
. The factor
is ``proper'' if
and
. For example, if
, then
and
are its proper
factors. For some numbers it is easy to find a proper factor. For
example, you can tell that
is even from the least significant
digit (in decimal or binary), in which case
is a proper factor
(unless
, a prime). But many numbers are not so easy. As an
example, you can try to find a proper factor of
by
hand1.
You can complete the factorization of a whole number by recursively
applying an algorithm for the factor-finding problem to all the proper
factors found.
Before we continue the reduction of factoring to order finding, we
briefly explain modular arithmetic, which both simplifies the
discussion and is necessary to avoid computing with numbers that have
exponential numbers of digits. We say that
and
are ``equal
modulo
'', written as
, if
is divisible by
(without remainder). For example,
. Equality
modulo
is well-behaved with respect to addition and
multiplication. That is, if
and
, then
and
. For factoring
, we will be
looking for whole numbers
that are divisible by a proper factor of
. If
has this property, then so does any
with
.
We therefore perform all arithmetic ``modulo
''. One way to think
about this is that we only use whole numbers
that satisfy
. We can implement an arithmetic operation modulo
by
first applying the operation in the usual way and then computing the
remainder after division by
. For example, to obtain
,
we first compute
. The unique
such that
and
is the remainder after division of
by
. Thus
is the result of multiplying
by
modulo
. Consistent with
this procedure, we can think of the expression
as referring
to the remainder of
after division by
.
The second observation in the reduction of factoring to order finding
is that it is sufficient to find a whole number
with the property
that
is a multiple of
but
and
are not. Using
the language of modular arithmetic, the property is expressed as
but
and
. Because
and
are the obvious square roots of
, we say
that
is a ``non-trivial square root of unity'' (modulo
). For
such an
, one can write
for some whole number
. This implies that every prime factor
of
divides either
or
so that either
or
is or shares a
factor with
. Suppose that
is or shares such a factor. Because
is not a multiple of
, the greatest common divisor of
and
is a proper factor of
. Since there exists an efficient
classical algorithm (the ``Euclidean algorithm'') for finding the
greatest common divisor, we can easily find the desired proper factor.
The examples of
and
serve to illustrate the key
features of the algorithm. For
, possible choices for
are
(
) and
(
). For
the first choice, the proper factors emerge immediately:
. For the second, it is necessary to determine the
greatest common divisors. Let
stand for the
greatest common divisor of
and
. The proper factors are
and
. For
, one can
take
, as
. In this case,
is a proper
factor and
is another.
For
even or a power of a prime it is not always possible to find a
non-trivial square root of unity. Because both of these cases can be
handled efficiently by known classical algorithms, we can exclude
them. In every other case, such numbers
exist. One way to find
such an
is to start from any whole number
with
. If
, then according to a basic result in number
theory there is a smallest whole number
such that
. The number
is called the ``order'' of
modulo
. If
is even, say
, then
, so
is a (possibly
trivial) square root of unity. For the example of
, we can try
. The order of
modulo
is
, which gives
,
the first of the two choices in the previous paragraph. For
, again with
, the order is
:
. Thus,
. We can also
try
, in which case with foresight it turns out that
is
divisible by
. A possible problem appears, namely, the
powers
that we want to compute are extremely large.
But modular arithmetic can be used to avoid this problem.
For example, to find the order of
modulo
by a direct search, we can perform the following computation:
![]() |
(52) |
A factor-finding algorithm based on the above observations
is the following:
The efficiency of this algorithm depends on the probability that a
randomly chosen
at step 3 results in finding a factor. By using
an analysis of the group of numbers
that satisfy
, it can be shown that this probability is
sufficiently large.
The main problem that remains to be solved is
that of finding the order of
. A direct search for
the order of
involves
computing the sequence
| (53) |
| FIG. 4: Multiplicative cycles of
|
To introduce the quantum algorithm, we first associate the logical
quantum states
with the numbers
. The map
which takes each number on the cycle to
the next number along the cycle is given by
. For
satisfying
, the map
permutes not only the
numbers on the cycle, but all the numbers modulo
. As a result,
the linear operator
defined by
is unitary. The quantum algorithm
deduces the length of the cycle for
by making measurements to
determine properties of the action of
on superpositions of
the states
. To illustrate the basic ideas, we work
out the example of
and
. The action of
on the
states
in the cycle of
is
completely determined by the eigenstates and eigenvalues of
. For
cyclicly acting permutations, a basis of eigenstates is given by the
``Fourier'' basis for the space spanned by the states in a cycle. For
the cycle of interest, the Fourier basis consists of the states
It is, of course, possible to express the logical state
using
the Fourier basis:
The quantum algorithm for obtaining an eigenvalue is called the
``phase estimation'' algorithm. It exploits a more general version of
the phase kick back we encountered in the solution of the parity
problem. The phase kick back transfers the eigenvalue of an eigenstate
of
to a Fourier basis on a number of additional
qubits called ``helper'' or ``ancilla'' qubits. Which Fourier state
results is then determined by a subroutine called the ``measured
quantum Fourier transform''. We introduce these elements in the next
paragraphs. Their combination for solving the general order-finding
problem is shown in Fig. 10.
Fig. 5 shows how to kick back the eigenvalue of an
eigenstate of
using a network implementing the
controlled-
operation.
| FIG. 5: Phase estimation with one qubit.
The input is a product state on one ancilla qubit and on a second
quantum system as shown. The state
|
![]() |
(56) |
| FIG. 6: Phase estimation with two qubits.
Using two qubits ensures distinguishability of the eigenvalues of
|
To learn one of the eigenvalues of
, the last step is to make
a ``measurement in the Fourier basis''. For one qubit representing
the binary numbers
and
, the Fourier basis is
and
, which is constructed as
discussed after Eq. 54, but using the square root of
unity
instead of the fourth root
. To make a measurement that
determines which of the two basis vectors is present, it suffices to
apply the Hadamard transform
and make a standard measurement,
just as we did twice in the network of Fig. 2.
A more complicated network works with two qubits representing the
binary numbers from
to
. Such a network is shown in
Fig. 7.
| FIG. 7:
The measured quantum Fourier transform [20] on two qubits
representing the numbers |
| (58) |
![]() |
|||
![]() |
(59) |
![]() |
|||
![]() |
|||
![]() |
(60) |
The elements that we used to determine the order of
modulo
can be combined and generalized to determine the order of any
modulo
with
. The general network is shown
in Fig. 10. Two features of the generalization are not
apparent from the example. First, in order for the quantum network to
be efficient, an efficient implementation of the controlled
operation is required. To obtain such an implementation,
first note that to calculate
it suffices
to square
repeatedly modulo
using
until we obtain
. The result is
then multiplied by
. This computation is efficient. For
any given
, it can be converted to an efficient network consisting
of Toffoli and controlled-not gates acting on the binary
representation of
. The conversion can be accomplished with
standard techniques from the theory of reversible classical
computation. The result is an efficient network for
. Basic network theory can then be used to implement the
controlled version of this operation [21].
The understand the second feature, note that we were lucky that the
order of
modulo
was a power of
, which nicely matched the
measured Fourier transform we constructed on two qubits. The measured
Fourier transform on
ancilla qubits can detect exactly
only eigenvalues that are powers of the
'th root of unity
. The phase kicked back by the controlled
operations corresponds to a
'th root of unity. Given a Fourier
state on the cycle of
, the resulting state on the ancilla
qubits has phases that go as powers of a
'th root of
unity. Fortunately, the ancilla's Fourier basis is such that the
measured Fourier transform picks up primarily those basis states whose
generating phase is close to the kick back phase. Thus we are likely
to detect a nearby
. It is still necessary
to infer (a divisor of)
from knowledge of such an
. Since
we know that the order
is bounded by
, the number of possible
phases kicked back that are near the measured
is limited. To
ensure that there is only one possible such phase, it is necessary to
choose
such that
. See also the caption of
Fig. 10.
| FIG. 8: Network for quantum order finding and phase
estimation. The number |