Shor's algorithm
Now we'll turn our attention to the integer factorization problem, and see how it can be solved efficiently on a quantum computer using phase estimation. The algorithm we'll obtain is Shor's algorithm for integer factorization. Shor didn't describe his algorithm specifically in terms of phase estimation, but it is a natural and intuitive way to explain how it works.
We'll begin by discussing an intermediate problem known as the order-finding problem and see how phase estimation provides a solution to this problem. We'll then see how an efficient solution to the order-finding problem gives us an efficient solution to the integer factorization problem. (When a solution to one problem provides a solution to another problem like this, we say that the second problem reduces to the first — so in this case we're reducing integer factorization to order finding.) This second part of Shor's algorithm doesn't make use of quantum computing at all; it's completely classical. Quantum computing is only needed to solve order finding.
The order-finding problem
Some basic number theory
To explain the order-finding problem and how it can be solved using phase estimation, it will be helpful to begin with a couple of basic number theory concepts, and to introduce some handy notation along the way.
To begin, for any given positive integer define the set like this.
For instance, and so on.
These are sets of numbers, but we can think of them as more than sets. In particular, we can think about arithmetic operations on such as addition and multiplication — and if we agree to always take our answers modulo (that is, divide by and take the remainder as the result), we'll always stay within this set when we perform these operations. The two specific operations of addition and multiplication, both taken modulo turn into a ring, which is a fundamentally important type of object in algebra.
For example, and are elements of and if we multiply them together we get which leaves a remainder of when divided by Sometimes we express this as follows.
But we can also simply write provided that it's been made clear that we're working in just to keep our notation as simple as possible.
As an example, here are the addition and multiplication tables for
Among the elements of the elements that satisfy are special. Frequently the set containing these elements is denoted with a star like so.
If we focus our attention on the operation of multiplication, the set forms a group — specifically an abelian group — which is another important type of object in algebra. It's a basic fact about these sets (and finite groups in general), that if we pick any element and repeatedly multiply to itself, we'll always eventually get the number
For a first example, let's take We have that because and if we multiply to itself we get as the table above confirms.
As a second example, let's take If we go through the numbers from to the ones having GCD equal to with are as follows.
For each of these elements, it is possible to raise that number to a positive integer power to get Here are the smallest powers for which this works:
Naturally we're working within for all of these equations, which we haven't bothered to write — we take it to be implicit to avoid cluttering things up. We'll continue to do that throughout the rest of the lesson.
Problem statement and connection to phase estimation
Now we can state the order-finding problem.
Alternatively, in terms of the notation we just introduced above, we're given and we're looking for the smallest positive integer such that This number is called the order of modulo
To connect the order-finding problem to phase estimation, let's think about the operation defined on a system whose classical states correspond to where we multiply by a fixed element
To be clear, we're doing the multiplication in so it's implicit that we're taking the product modulo inside of the ket on the right-hand side of the equation.
For example, if we take and then the action of on the standard basis is as follows.