...

/

Shor's Algorithm - From Factoring to Period Finding

Shor's Algorithm - From Factoring to Period Finding

Let’s devise a framework to find the non-trivial square root X. In doing so, we shall translate our problem of factorization to a problem that closely relates to period finding.

As a refresher, when we want to factor an integer NN, we want to find the non-trivial square root XX of the congruence X21 (mod N)X^{2}\equiv1\space (mod \space N). Then we feed the obtained XX into an efficient algorithm that calculates the greatest common divisor of two numbers to obtain two factors of NN with gcd(N,X±1)gcd(N, X\pm1). Now, the agenda of this lesson is to find XX. So, let’s get started.

Let’s revisit our problem from the previous lesson. We want to factor N=21N=21. Let’s pick an XX at random, where 1<X<N11 < X < N-1. The inequality exists as we are not interested in obtaining 11 or NN itself as its own factor, defeating the purpose of our original problem. Let’s say we pick N=2N=2. Now, we create a table with two columns and multiple rows. In the first column, we have aa, which is the number to which we shall be raising X=2X=2. In the second column, we have a function f(a)=Xa (mod N)f(a)=X^{a}\space (mod\space N), which shows us the remainder we get after raising X=2X=2 to that aa and then dividing it by N=21N=21.

aa f(a)=Xa (mod N)f(a)=X^{a}\space (mod\space N)
0{0} 201 (mod 21)2^{0}\equiv1\space (mod \space 21)
1{1}
...
Access this course and 1400+ top-rated courses and projects.