How Does Shor's Algorithm Factor Integers Effectively?

  • Context: Graduate 
  • Thread starter Thread starter ptabor
  • Start date Start date
  • Tags Tags
    Algorithm
Click For Summary

Discussion Overview

The discussion revolves around Shor's algorithm for factoring integers, specifically focusing on the mechanics of the algorithm and the implications of choosing different values for 'a'. Participants explore the periodicity of the function and the greatest common divisor (gcd) calculations involved in the factorization process.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes the algorithm, detailing the steps to compute the function f(x) = a^x mod N and the significance of the period r in finding factors.
  • Another participant suggests that if the initial gcd of N and 'a' is greater than 1, a factor has been found, and if it is 1, the process continues.
  • There is a question raised about whether the choice of 'a' can lead to finding all factors of N, with one participant noting that they have only found certain factors (6 and 4) in their trials.
  • A correction is made regarding a mathematical error in the gcd calculation, with a participant pointing out that the gcd of (12, 4) is actually 4, not 2.
  • Concerns are expressed about the limitations of the algorithm in finding all factors, as one participant mentions being unable to use certain values for 'a' due to their gcd with N being not equal to 1.

Areas of Agreement / Disagreement

Participants express uncertainty regarding the completeness of the algorithm in finding all factors of N, with some suggesting it may not yield all factors and others questioning the implications of the gcd results. No consensus is reached on whether the algorithm can find all factors or the conditions under which it operates effectively.

Contextual Notes

Participants note limitations in their understanding of how the choice of 'a' affects the outcomes and the implications of the periodicity of the function. There are also unresolved questions about the algorithm's ability to find all factors of N.

ptabor
Messages
14
Reaction score
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
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'.
 
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
 
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.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K