Exploring Shor's Algorithm: Factoring Integers

  • Thread starter ptabor
  • Start date
  • Tags
    Algorithm
In summary, the algorithm for factorizing an integer N involves selecting an integer a < N, computing the function f(x) = a^x mod N, and finding the greatest common divisor of N and a^(r/2) +/- 1, where f(x) is periodic with period r. This algorithm may not find all factors of N, and in some cases, a new value for a may need to be selected.
  • #1
ptabor
15
0
I'm playing around with the algorithm and I'm having some confusion:

the algorithm is as follows: to factorize some integer N pick some integer a such that a < N.
then compute the function f(x) = a^x mod N
f(x) will be periodic with period r, then to find the factors you find the greatest common divisor of N and a^(r/2) +\- 1

For example, suppose that N = 12. Then let us say that a = 5, then we have f(x) = 5^x mod 12. Plugging in some values for x, we see that
f(1) = 5 mod 12 = 5
f(2) = 25 mod 12 = 1
f(3) = 125 mod 12 = 5
f(4) = 625 mod 12 = 1

so here the period is 2, hence we must find the gcd of 5^(2/2) +\- 1 and N
=> gcd of 12 and 4 is 2; gcd of 12 and 6 is 6
hence 12 = 6*2

But suppose I start over and let a = 4
f(1) = 4 mod 12 = 4
f(2) = 16 mod 12 = 4
f(3) = 64 mod 12 = 4
and so on.

So the period here is 1, and we must find the gcd of 4^(1/2) +\- 1
and 12.

gcd of 3 and 12 is 3, gcd of 1 and 12 is 1. So does this imply that a is also a factor of N? It seems to me that it must, in all cases, but I don't want to make a hasty generalization.
 
Last edited:
Mathematics news on Phys.org
  • #2
You would compute the gcd of N and the 'a' you picked before proceeding with the algorithm. If it's >1 you've found a factor, if it's 1 then you go on. Also if the period is odd, you have to pick a new 'a'.
 
  • #3
ptabor said:
I'm playing around with the algorithm and I'm having some confusion:

the algorithm is as follows: to factorize some integer N pick some integer a such that a < N.
then compute the function f(x) = a^x mod N
f(x) will be periodic with period r, then to find the factors you find the greatest common divisor of N and a^(r/2) +\- 1

For example, suppose that N = 12. Then let us say that a = 5, then we have f(x) = 5^x mod 12. Plugging in some values for x, we see that
f(1) = 5 mod 12 = 5
f(2) = 25 mod 12 = 1
f(3) = 125 mod 12 = 5
f(4) = 625 mod 12 = 1

so here the period is 2, hence we must find the gcd of 5^(2/2) +\- 1 and N
=> gcd of 12 and 4 is 2; gcd of 12 and 6 is 6
hence 12 = 6*2

But suppose I start over and let a = 4
f(1) = 4 mod 12 = 4
f(2) = 16 mod 12 = 4
f(3) = 64 mod 12 = 4
and so on.

So the period here is 1, and we must find the gcd of 4^(1/2) +\- 1
and 12.

gcd of 3 and 12 is 3, gcd of 1 and 12 is 1. So does this imply that a is also a factor of N? It seems to me that it must, in all cases, but I don't want to make a hasty generalization.


I've never heard of this method. It sounds neat. :smile:

I do want to make a quick point, though:
so here the period is 2, hence we must find the gcd of 5^(2/2) +\- 1 and N
=> gcd of 12 and 4 is 2; gcd of 12 and 6 is 6
hence 12 = 6*2

(12,4)=4, not 2. Sorry to be so picky! :rolleyes:

-Dan
 
  • #4
thanks for the correct, tops. I noticed the simple math error but didn't bother to fix it in the post =/

In any event, is this algorithm supposed to find all factors of N? I've performed it many times, and have only been able to come up with 6 and 4, not 2 and 3.

for instance, if a = 7 then we get 7 +/- 1 = 8, 6 - yielding 6 and 4 again.
if a = 11 then we get 11 +/- 1 = 12, 10 yielding 12 and 2 - where 12 is a trivial factor.
I can't let a = 2, 3, 4, 6, 8, 9, 10 because the gcd of these numbers with 12 is != 1.

Apparently I'm missing something here.
 

1. What is Shor's algorithm?

Shor's algorithm is a quantum algorithm developed by mathematician Peter Shor that is used to efficiently factor large integers into their prime factors. This algorithm has significant implications for cryptography and the security of modern encryption techniques.

2. How does Shor's algorithm work?

Shor's algorithm uses a quantum computer to perform mathematical operations on a superposition of states, allowing it to quickly find the prime factors of a given integer. It involves modular exponentiation and the quantum Fourier transform to find the period of a function, which is then used to determine the prime factors of the number.

3. Why is factoring integers important?

Factoring integers is important because it is the basis for many modern encryption methods used to secure sensitive information. By being able to efficiently factor large integers, Shor's algorithm poses a potential threat to the security of these encryption techniques.

4. What are the applications of Shor's algorithm?

In addition to its implications for cryptography and encryption, Shor's algorithm has potential applications in other fields such as chemistry and physics. It can be used to simulate quantum systems and solve complex mathematical problems that are difficult for classical computers to handle.

5. Is Shor's algorithm currently being used?

No, Shor's algorithm is not currently being used in practical applications due to the limited availability and capabilities of quantum computers. However, research and development in this area is ongoing and it is expected that Shor's algorithm will have significant impacts in the future as quantum computing technology continues to advance.

Similar threads

Replies
5
Views
843
Replies
1
Views
1K
  • General Math
Replies
3
Views
1K
Replies
5
Views
2K
  • Precalculus Mathematics Homework Help
Replies
7
Views
1K
  • Precalculus Mathematics Homework Help
Replies
1
Views
868
Replies
6
Views
1K
  • General Math
Replies
5
Views
2K
Replies
1
Views
890
Replies
6
Views
2K
Back
Top