Skip main navigation

Structure of Shor’s algorithm

Let's talk about the structure of Peter Shor's algorithm for factoring large numbers.
ยฉ Keio University

Letโ€™s talk about the structure of Peter Shorโ€™s algorithm for factoring large numbers.

As we saw, a โ€œquantumโ€ algorithm is really a hybrid quantum-classical algorithm. It begins with some classical processing, then uses the quantum computer to execute a particular part of the algorithm (a subroutine or function) and measures the result. It then takes those results and does some more classical post-processing. The quantum computer essentially serves as a coprocessor to the classical computer.

In the case of Shorโ€™s algorithm, the quantum subroutine is known as the period finding routine, which uses an important technique known as the quantum Fourier transform, or QFT, to create interference that gives us the period. We then use a classical technique known as Euclidโ€™s algorithm to find the prime factors of the number (N). We will go through each of these steps briefly, then there is an article for each of the parts that goes into more detail.

Shor's algorithm Fig.1. Block structure of Shorโ€™s algorithm

Modulo Arithmetic

Recall that modulo arithmetic means that any time our result gets to be greater than or equal to the modulus, we subtract the modulus until weโ€™re back between zero and that number minus one.

Doing arithmetic modulo ten is just like keeping track of only the last digit of any addition or multiplication operation, so for example (9 times 9 bmod 10) is just 1, rather than 81.

Consider a function where you add four every step, and do the whole thing modulo seven. If you start with zero, your sequence goes 0, 4, then it should go 8, but since 8 is greater than 7, we subtract 7 and weโ€™re back to 1. Then the next step would be 5. Modulo seven, then, is just like doing math in base seven and keeping only the last digit.

The Period of a Function

A lot of mathematical functions are periodic. That is, if you start by evaluating the function in some place and move forward, eventually youโ€™ll come back to where you started. In fact, the entire sequence of values repeats itself. The time it takes for that repetition to occur is called the period.

Weโ€™ve already talked a lot about waves, so you might suspect that the period of a function is like the period of a wave. In fact, itโ€™s exactly like that!

sinwave Fig.2. A simple sine wave

Rather than a continuous function like a sine wave, letโ€™s look at what happens just with discrete steps, like modulo arithmetic. Go back to the function of adding four modulo seven, which we can write like this: (x_{i+1} = x_i + 4 bmod 7). Our sequence of numbers goes

[0, 4, 1, 5, 2, 6, 3, 0]

After seven steps we are back to zero, where we started. If you keep going, the sequence just repeats itself:

[0, 4, 1, 5, 2, 6, 3, 0, 4, 1, 5, 2, 6, 3, 0, 4, 1, 5, 2, 6, 3, โ€ฆ]

Every 0 is seven steps apart, and even 4 is seven steps apart in that sequence. We say that the period of our function is seven, and we can say that

(f(x + 7) = f(x)).

The Quantum Fourier Transform

Select a prime number (a < N). It turns out that, if we can find the period (r) of the function (f(x) = a^x bmod N) as we increment the variable (x), then we can find the factors of (N). The simplest way to do this, of course, is just to repeat calculating (f(x)) until we find two identical results; the number of steps in between will be the period. While itโ€™s theoretically possible, itโ€™s impractical, because the period grows roughly exponentially as the length of the number grows. For large numbers, that period could be enormous, so big that we could calculate for the lifetime of the universe and never find the period. Itโ€™s less efficient than the number field sieve we already have. We need a different approach.

A common classical technique for finding the frequency of a signal, which we can easily invert to find the period, is the Fourier transform. If we could take the Fourier transform of a sequence of these results, we might find the period. Doing so classically, unfortunately, would require data from a sequence of results like the one we just described. Still obviously impractical.

With a quantum computer, though, the finding of the period of a function suddenly becomes practical. We take all of the possible values of (x) in superposition, calculate (f(x)), and now we have a superposition of all of the function results. If we can pick two different values of (x) out of the superposition that produce the same (f(x)), then we can find the period.

Unfortunately, we canโ€™t do that directly. As we have seen, any time you measure a superposition, you get one of the possible values randomly, depending on the quantum probability amplitudes. Finding only one value for (x) doesnโ€™t help us at all. Instead, though, we can apply the quantum form of the Fourier transform (the QFT), and it will create interference among all of values of (x), in a fashion that lets us directly read out the period (r)!

Of course, this is still no help if either calculating (f(x)) or doing the QFT is computationally expensive. The modular exponentiation and the QFT both turn out to have a cost that is polynomial in the length of the number in bits, a profound reduction compared to the exponential effort necessary to find the period classically.

This is the core of Shorโ€™s algorithm, and one of the most exciting technical results in any field in the last several decades, in our opinion.

Euclidโ€™s Algorithm

The final classical step is take (r) and use it to find the factors. This is done on a classical computer, using Euclidโ€™s algorithm for finding the greatest common denominator (gcd) of two numbers. Euclidโ€™s algorithm is polynomial in the size of the numbers, and indeed is fairly fast on a classical computer, so there is no need to be concerned about the difficulty of this step.

Assuming we have correctly found the period (r), calculating the gcd of (N) with the numbers (a^{(r/2)}+1) and (a^{(r/2)}-1) will give us two prime factors of the number (N).

Putting It All Together

Summarizing, letโ€™s assume weโ€™re trying to factor the number (N), which is written using (n) bits. The algorithm consists of the following steps:

  1. Pick a prime number (a < N).
  2. Use Euclidโ€™s algorithm to check if (a) is a factor of (N); if so, youโ€™re done.
  3. Otherwise, prepare your quantum computer and a program for it to execute quantum period finding.
  4. The first important quantum step is to calculate the superposition of (a^x) for all values of (x), all done modulo (N). (|xrangle) and the remainder both appear in our quantum register.
  5. Measure the remainder. (Technically, this is unnecessary, but it simplifies the explanation, so we will assume we use it.)
  6. Take the quantum Fourier transform (QFT) of (|xrangle.)
  7. Measure the register (|xrangle); call the result (r), which should be a multiple of the period of the modular exponentiation function.
  8. If (r) is even and greater than zero, calculate the numbers (a^{(r/2)}+1) and (a^{(r/2)}-1); if not, rerun the quantum portion of the algorithm to find a new (r).
  9. Use Euclidโ€™s algorithm to calculate the gcd of each of those numbers and (N), and you should have two factors of (N)!

Now, letโ€™s go look at each of the individual techniques, before putting it all together.

ย 

Shorใฎใ‚ขใƒซใ‚ดใƒชใ‚บใƒ ใฎๆง‹้€ 

Peter Shorใฎ็ด ๅ› ๆ•ฐๅˆ†่งฃใ‚ขใƒซใ‚ดใƒชใ‚บใƒ ใซใคใ„ใฆ่ฆ‹ใฆใ„ใใพใ—ใ‚‡ใ†ใ€‚

็งใŸใกใŒ่ฆ‹ใŸใ‚ˆใ†ใซใ€โ€้‡ๅญโ€ใ‚ขใƒซใ‚ดใƒชใ‚บใƒ ใจใ„ใ†ใฎใฏๅฎŸ้š›ใฏใ€้‡ๅญใจๅคๅ…ธใฎใƒใ‚คใƒ–ใƒชใƒƒใƒ‰ใ‚ขใƒซใ‚ดใƒชใ‚บใƒ ใงใ™ใ€‚ๅˆใ‚ใฏๅคๅ…ธ่จˆ็ฎ—ๆฉŸใง็”จใ„ใ‚‰ใ‚Œใฆใ„ใŸใ‚‚ใฎใŒใ€ใใฎๅพŒ้‡ๅญใ‚ณใƒณใƒ”ใƒฅใƒผใ‚ฟใซใ‚ˆใฃใฆใ‚ขใƒซใ‚ดใƒชใ‚บใƒ ใฎ็‰นๅฎšใฎ้ƒจๅˆ†ใ‚’ๅฎŸ่กŒ๏ผˆ็นฐใ‚Š่ฟ”ใ—ใ‚„้–ขๆ•ฐ๏ผ‰ใ™ใ‚‹ใ“ใจใซ็”จใ„ใ‚‰ใ‚Œใ€ใใฎ็ตๆžœใ‚’่จˆๆธฌใ—ใฆใ„ใพใ™ใ€‚ใใ‚Œใ‚‰ใฎ็ตๆžœใŒ็”จใ„ใ‚‰ใ‚Œใ€ๅคๅ…ธ็š„ใชๅพŒๅ‡ฆ็†ใซ็”จใ„ใ‚‰ใ‚Œใฆใ„ใพใ™ใ€‚้‡ๅญใ‚ณใƒณใƒ”ใƒฅใƒผใ‚ฟใƒผใฏใ€ๅคๅ…ธใ‚ณใƒณใƒ”ใƒฅใƒผใ‚ฟใฎ่ฃœๅŠฉ็š„ใชใƒ—ใƒญใ‚ปใƒƒใ‚ตใจใ—ใฆๆดป่บใ™ใ‚‹ใฎใงใ™ใ€‚

Shorใฎใ‚ขใƒซใ‚ดใƒชใ‚บใƒ ใซใŠใ„ใฆใฏใ€้‡ๅญ็š„ใช็นฐใ‚Š่ฟ”ใ—ไฝœๆฅญใฏใ€็นฐใ‚Š่ฟ”ใ—ใฎๅ˜ไฝใ‚’่ฆ‹ใคใ‘ใ‚‹ไธŠใงๅˆฉ็”จใ•ใ‚Œใพใ™ใ€‚ใ“ใ‚Œใฏใ€้‡ๅญใƒ•ใƒผใƒชใ‚จๅค‰ๆ›(Quantum Fourier Transform)ใจๅ‘ผใฐใ‚Œใ‚‹ๆ‰‹ๆณ•ใชใฉใซใŠใ„ใฆใ€ๅ˜ไฝใ‚’ไธŽใˆใ‚‹ๆณขใฎๅนฒๆธ‰ใ‚’ไฝœใ‚Šๅ‡บใ™ไธŠใง็”จใ„ใ‚‰ใ‚Œใพใ™ใ€‚็งใŸใกใฏใใฎไธŠใงใ€ N ใฎ็ด ๅ› ๆ•ฐใ‚’่ฆ‹ใคใ‘ใ‚‹ใŸใ‚ใซใ€ใƒฆใƒผใ‚ฏใƒชใƒƒใƒ‰ใฎใ‚ขใƒซใ‚ดใƒชใ‚บใƒ ๏ผˆใƒฆใƒผใ‚ฏใƒชใƒƒใƒ‰ใฎไบ’้™คๆณ•๏ผ‰ใ‚’็”จใ„ใพใ™ใ€‚ใ“ใ‚Œใ‚‰ใฎใ‚นใƒ†ใƒƒใƒ—ใ‚’็ฐกๅ˜ใซ่ฆ‹ใฆใ„ใใ€ไธ€ใคไธ€ใคใฎ็ดฐใ‹ใ„่จ˜ไบ‹ใ‚’่ฆ‹ใฆใ„ใใพใ—ใ‚‡ใ†ใ€‚

Shor's algorithm Fig.1. Block structure of Shorโ€™s algorithm

ใƒขใ‚ธใƒฅใƒญๆผ”็ฎ—

ใƒขใ‚ธใƒฅใƒญๆผ”็ฎ—๏ผˆmodใชใฉใจๅ‘ผใฐใ‚Œใ‚‹)ใจใฏใ€ๆณ•๏ผˆๅŸบๆบ–ใจใชใ‚‹ๆ•ฐ(N)๏ผ‰ใซๅฏพใ—ใฆ็ญ‰ใ—ใ„ใ€ใพใŸใฏใฉใ‚Œใ  ใ‘ๅคงใใ„ๆ•ฐใซใชใฃใฆใ‚‚ใ€ใใฎๆ•ฐใŒ0ใ‹ใ‚‰(N โ€“ 1)ใพใงใฎ้–“ใซใชใ‚‹ใพใงใ€(N)ๅผ•ใ็ถšใ‘ใ‚‹ใ‚‚ใฎใงใ‚ใฃใŸใจ ใ„ใ†ใ“ใจใ‚’ๆ€ใ„ๅ‡บใ—ใฆใใ ใ•ใ„ใ€‚

ใ“ใฎmodใซใŠใ„ใฆใฏใ€ใฉใฎใ‚ˆใ†ใชๅŠ ๆณ•ใ€ไน—ๆณ•ใซใŠใ„ใฆใ‚‚ใ€ๆœ€ๅพŒใฎๆกใ‚’่ฆ‹ใ‚‹ใ ใ‘ใงๆผ”็ฎ—ใŒๅฏ่ƒฝใงใ™ใ€‚ไพ‹ใˆใฐใ€(9 times 9 bmod 10 equiv 1( neq 81))ใจใชใ‚Šใพใ™ใ€‚

(bmod 7)ใงใ€ๆฏŽๅ›ž๏ผ”ใ‚’่ถณใ—ใฆใ„ใใจใ„ใ†้–ขๆ•ฐใ‚’่€ƒใˆใฆใฟใพใ—ใ‚‡ใ†ใ€‚๏ผใ‹ใ‚‰ๅˆใ‚ใŸใจใ™ใ‚‹ใจใ€0, 4ใใ—ใฆ8ใจใ„ใ†ใ‚ˆใ†ใซๅข—ใˆใฆใ„ใใพใ™ใŒใ€8ใฏ7ใ‚ˆใ‚Šๅคงใใ„ใฎใงใ€7ใ‚’ๅผ•ใ„ใฆใ€1ใซๆˆปใ‚Šใพใ™ใ€‚ใใ—ใฆๅ†ใณ4ใ‚’่ถณใ—ใฆ5ใจใชใ‚Šใพใ™ใ€‚(bmod 7)ใจใ„ใ†ใฎใฏใ€7ใ‚’ๅŸบๆบ–ใจใ—ใŸๆ•ฐๅญฆใจใชใ‚Šใ€ๆœ€็ต‚ๆกใ ใ‘ใ‚’่ฟฝใฃใฆใ„ใ‘ใฐ่‰ฏใ„ใฎใงใ™ใ€‚

้–ขๆ•ฐใฎๅ‘จๆœŸ

ๅคšใใฎๆ•ฐๅญฆ็š„้–ขๆ•ฐใฏๅ‘จๆœŸ็š„ใงใ™ใ€‚ใคใพใ‚Šใ“ใ‚Œใฏใ€ใ‚ใ‚‹ๅœฐ็‚นใง้–ขๆ•ฐใ‚’่ฉ•ไพกใ—ใคใคใ€ๆฎตใ€…ใจๅ…ˆใธ้€ฒใ‚“ใงใ„ใใจใ€็ตๆžœใฏ่ฉ•ไพกใ—ๅง‹ใ‚ใŸ็‚นใซ่ฟ‘ใฅใ„ใฆใ„ใใจใ„ใ†ใ“ใจใงใ™ใ€‚ๅฎŸ้š›ใฏใ€ใ‚ทใƒผใ‚ฑใƒณใ‚นๅ…จไฝ“ใงใ€ใใฎ็นฐใ‚Š่ฟ”ใ—ใŒ่กŒใ‚ใ‚Œใฆใ„ใพใ™ใ€‚ใ“ใฎ็นฐใ‚Š่ฟ”ใ—ใซใ‹ใ‹ใ‚‹ๆ™‚้–“ใฎๅคงใใ•ใ‚’ใ€ๅ‘จๆœŸใจๅ‘ผใณใพใ™ใ€‚

็งใŸใกใฏๆณขใซใคใ„ใฆใ€ๆง˜ใ€…ใซ่ฉฑใ—ใฆใใพใ—ใŸใ€‚ใใฎใŸใ‚ใ€้–ขๆ•ฐใฎๅ‘จๆœŸใจใฏใ€ๆณขใฎๅ‘จๆœŸใฎใ‚ˆใ†ใชใ‚‚ใฎใจ่€ƒใˆใ‚‹ใ‹ใ‚‚ใ—ใ‚Œใพใ›ใ‚“ใ€‚ๅฎŸ้š›ใ€ใใฎใ‚ˆใ†ใชใ‚‚ใฎใชใฎใงใ™๏ผ

sinwave Fig.2. A simple sine wave

ๆญฃๅผฆๆณขใฎใ‚ˆใ†ใชใ€้€ฃ็ถš้–ขๆ•ฐใงใฏใชใใ€ใƒขใ‚ธใƒฅใƒญๆผ”็ฎ—ใฎใ‚ˆใ†ใช้›ขๆ•ฃ็š„ใช้–ขๆ•ฐใซใคใ„ใฆ่ฆ‹ใฆใ„ใใพใ—ใ‚‡ใ†ใ€‚(bmod 7)ใงใ€๏ผ”ใ‚’ๅŠ ใˆใฆใ„ใ้–ขๆ•ฐใซใคใ„ใฆ่ฆ‹ใฆใ„ใใพใ—ใ‚‡ใ†ใ€‚ใใ‚Œใ‚’่กจใ™ใจใ“ใฎใ‚ˆใ†ใซใชใ‚Šใพใ™ใ€‚(x_{i+1} = x_i + 4 bmod 7)ๆ•ฐๅญ—ใฎ้ †็•ชใจใ—ใฆใฏใ€

[0,4,1,5,2,6,3,0]

ใจใ„ใ†ใ‚ˆใ†ใซใชใ‚Šใพใ™ใ€‚ 7ๆฎต้šŽ่ธใ‚“ใ ใ‚ใจใ€ๅˆใ‚ใจๅŒใ˜0ใซๆˆปใ‚Šใพใ™ใ€‚ใ“ใ‚Œใ‚’็นฐใ‚Š่ฟ”ใ—ใฆใ„ใใจใ€ไธ‹ใฎใ‚ˆใ†ใซใ€ๅŒใ˜ๆ•ฐๅญ—ใฎ็นฐใ‚Š่ฟ”ใ—ใŒ็พใ‚Œใพใ™ใ€‚

[0,4,1,5,2,6,3,0,4,1,5,2,6,3,0,4,1,5,2,6,3,โ€ฆ]

0ใ‚‚4ใ‚‚ๅ…จใฆใฎๆ•ฐๅญ—ใŒใ€7ใคใŠใใซๅ‡บใฆใใฆใ„ใพใ™ใ€‚ใใฎใŸใ‚ใ€ใ“ใฎ้–ขๆ•ฐใฎๅ‘จๆœŸใฏ7ใงใ‚ใ‚‹ใจ่จ€ใ†ใ“ใจใŒใงใใพใ™ใ€‚ใใ—ใฆใ“ใ‚Œใ‚’่กจใ™ใจใ€

[f(x+7)=f(x)]

ใจใ„ใ†ใ‚ˆใ†ใซๆ›ธใใ“ใจใŒใงใใพใ™ใ€‚

้‡ๅญใƒ•ใƒผใƒชใ‚จๅค‰ๆ›

(a < N)ใ‚’ๆบ€ใŸใ™็ด ๆ•ฐใ‚’ไธ€ใค้ธใณใพใ™ใ€‚ใใฎๆ•ฐใซใคใ„ใฆ(f(x) = a^x bmod N)ใจใ„ใ†้–ขๆ•ฐ(r)ใฎๅ‘จๆœŸใ‚’็™บ่ฆ‹ใงใใŸๅ ดๅˆใ€(N)็ด ๅ› ๆ•ฐใ‚’็Ÿฅใ‚‹ใ“ใจใŒใงใใพใ™ใ€‚ๆœ€ใ‚‚ๅ˜็ด”ใชๆ–นๆณ•ใฏใ‚‚ใกใ‚ใ‚“ใ€(f(x))ใ‚’2ใคใฎๅŒใ˜็ตๆžœใŒๅพ—ใ‚‰ใ‚Œใ‚‹ใพใง่จˆ็ฎ—ใ—็ถšใ‘ใ‚‹ใ“ใจใงใ™ใ€‚็ขบๅฎŸใซๅ‘จๆœŸใพใงใฎๆฎต้šŽใง็ต‚ใ‚ใ‚‰ใ›ใ‚‹ใ“ใจใŒๅฏ่ƒฝใงใ™ใ€‚ใ“ใ‚Œใฏ็†่ซ–็š„ใซใฏๅฏ่ƒฝใงใ™ใŒใ€็พๅฎŸ็š„ใงใฏใ‚ใ‚Šใพใ›ใ‚“ใ€‚ใชใœใชใ‚‰ใ€ๆ•ฐใŒๅคงใใใชใ‚‹ใซ้€ฃใ‚Œใฆใ€ๅ‘จๆœŸใฏๆŒ‡ๆ•ฐ้–ขๆ•ฐ็š„ใซๅคงใใใชใฃใฆใ„ใใ‹ใ‚‰ใงใ™ใ€‚ใ“ใ‚Œใฏใ€ใ™ใงใซใ‚ใ‚‹ใ‚ˆใ†ใชๆ•ฐใฎใตใ‚‹ใ„ใจๅ‘ผใฐใ‚Œใ‚‹ๆ‰‹ๆณ•ใ‚ˆใ‚Šใ‚‚ใ€ๅŠน็Ž‡็š„ใงใฏใ‚ใ‚Šใพใ›ใ‚“ใ€‚ไป–ใฎๆ‰‹ๆณ•ใŒๅฟ…่ฆใจใชใ‚Šใพใ™ใ€‚

้–ขๆ•ฐใฎๅ‘จๆœŸใ‚’่ฆ‹ใคใ‘ใ‚‹ใŸใ‚ใซใ€ๅ่ปขใ—ใ‚„ใ™ใ„ไฟกๅทใฎๅ‘จๆณขๆ•ฐใ‚’่ฆ‹ใคใ‘ใ‚‹ใŸใ‚ใฎใ€ๅคๅ…ธ็š„ๆ‰‹ๆณ•ใจใ—ใฆใ€ใƒ•ใƒผใƒชใ‚จๅค‰ๆ›ใŒ็”จใ„ใ‚‰ใ‚Œใพใ™ใ€‚ใ‚‚ใ—ใ“ใ‚Œใ‚‰ใฎ็ตๆžœใฎ้€ฃ็ถšๅ€คใฎใƒ•ใƒผใƒชใ‚จๅค‰ๆ›ใฎๅ€คใ‚’ๅพ—ใ‚‹ใ“ใจใŒใงใใ‚Œใฐใ€ๅ‘จๆœŸใ‚’ๅพ—ใ‚‹ใ“ใจใŒใงใใพใ™ใ€‚ไธ้‹ใซใ‚‚ใ€ใ‚ใพใ‚Šใซๅคๅ…ธ็š„ใซ่กŒใ†ใจใ€็งใŸใกใŒๆใ„ใŸใ‚ˆใ†ใช็ตๆžœใฎใ‚ทใƒผใ‚ฑใƒณใ‚นใ‹ใ‚‰ใƒ‡ใƒผใ‚ฟใ‚’ๅ–ใ‚‰ใชใ‘ใ‚Œใฐใชใ‚‰ใชใใชใฃใฆใ—ใพใ„ใพใ™ใ€‚

ใ—ใ‹ใ—้‡ๅญใ‚ณใƒณใƒ”ใƒฅใƒผใ‚ฟใƒผใซใŠใ„ใฆใฏใ€้–ขๆ•ฐใฎๅ‘จๆœŸใ‚’่ฆ‹ใคใ‘ใ‚‹ใ“ใจใฏ้žๅธธใซ็พๅฎŸ็š„ใซใชใฃใฆใใพใ™ใ€‚ๅ…จใฆใฎๅฏ่ƒฝใชๅ€ค(x)ใ‚’้‡ใญๅˆใ‚ใ›็Šถๆ…‹ใจใ—ใ€(f(x))ใ‚’่จˆ็ฎ—ใ—ใพใ™ใ€‚ใใ†ใ™ใ‚‹ใ“ใจใงใ€้–ขๆ•ฐใฎ็ตๆžœใฎๅ…จใฆใฎ้‡ใญๅˆใ‚ใ›็Šถๆ…‹ใ‚’ๅพ—ใ‚‹ใ“ใจใŒใงใใพใ™ใ€‚ใ‚‚ใ—2ใคใฎ็•ฐใชใ‚‹ๅ€ค(x)ใŒๅŒใ˜(f(x))ๅ€คใ‚’่ฟ”ใ—ใŸใจใใ€ใใ‚ŒใŒใใฎ้–ขๆ•ฐใฎๅ‘จๆœŸใจใชใ‚Šใพใ™ใ€‚

ไธ้‹ใซใ‚‚ใ€็งใŸใกใฏใใ‚Œใ‚’็›ดๆŽฅ่กŒใ†ใ“ใจใฏใงใใพใ›ใ‚“ใ€‚ไปŠใพใง่ฆ‹ใฆใใŸใ‚ˆใ†ใซใ€้‡ใญๅˆใ‚ใ›ใฎ็Šถๆ…‹ใ‚’่ฆณๆธฌใ—ใ‚ˆใ†ใจใ™ใ‚‹ใจใ€้‡ๅญ็š„็ขบ็Ž‡ใฎๆŒฏๅน…ใซไพๅญ˜ใ™ใ‚‹ใ€ใƒฉใƒณใƒ€ใƒ ใชๅ€คใŒๅ‡บใฆใใฆใ—ใพใ„ใพใ™ใ€‚(x)ใฎๅ€คไธ€ใคใ ใ‘ใงใฏๅ…จใๅฝนใซ็ซ‹ใกใพใ›ใ‚“ใ€‚ใใฎใ‹ใ‚ใ‚Šใ€ใƒ•ใƒผใƒชใ‚จๅค‰ๆ›ใ‚’้‡ๅญๅฝขๅผใซๅฟœ็”จใ—ใฆใ€(x)ใฎๅ…จใฆใฎ้–“ใงๅนฒๆธ‰ใ‚’ไฝœๆˆใ™ใ‚‹ใ“ใจใงใ€ๆ›ฒใŒใ‚Šใชใ‚Šใซใ‚‚ๅ‘จๆœŸ(r)ใ‚’็›ดๆŽฅๅพ—ใ‚‹ใ“ใจใŒใงใใพใ™ใ€‚

ใ‚‚ใกใ‚ใ‚“ใ€ใ“ใ‚Œใฏ(f(x))ใฎ่จˆ็ฎ—ใ‚„ใ€้‡ๅญใƒ•ใƒผใƒชใ‚จๅค‰ๆ›ใŒใ€ๆŠ€่ก“็š„ใซๅŽณใ—ใ„ใจๅฝนใซใฏ็ซ‹ใกใพใ›ใ‚“ใ€‚ๅ†ชๅ‰ฐไฝ™ใจ้‡ๅญใƒ•ใƒผใƒชใ‚จๅค‰ๆ›ใฏใ€ๆ•ฐใฎๅคงใใ•ใซใ‚ˆใฃใฆใ€ๅคš้ …ๅผๆ™‚้–“ใงใฎ่จˆ็ฎ—ใ‚ณใ‚นใƒˆใŒใ‹ใ‹ใ‚Šใ€ๅคๅ…ธ็š„ๆ–นๆณ•ใงๅ‘จๆœŸใ‚’่ฆ‹ใคใ‘ใ‚‹่ถ…ๅคš้ …ๅผ็š„ใชๆ™‚้–“ใซๆฏ”ในใ‚‹ใจใ€่จˆ็ฎ—ๆ™‚้–“ใ‚’้žๅธธใซๅ‰Šๆธ›ใงใใพใ™ใ€‚

ใ“ใ‚ŒใฏShorใฎใ‚ขใƒซใ‚ดใƒชใ‚บใƒ ใฎไธญๅฟƒใงใ€ไปŠๅพŒๆ•ฐๅๅนดใงๆœ€ใ‚‚ๆŠ€่ก“็š„็ตๆžœใฎๅ‡บใใ†ใชๅˆ†้‡Žใฎไธ€ใคใซใชใ‚‹ใจๆ€ใ„ใพใ™ใ€‚

ใƒฆใƒผใ‚ฏใƒชใƒƒใƒ‰ใฎใ‚ขใƒซใ‚ดใƒชใ‚บใƒ 

ๆœ€ๅพŒใฎๅคๅ…ธ็š„ๆฎต้šŽใฏใ€ๅ‘จๆœŸ(r)ใ‚’็™บ่ฆ‹ใ—ใ€ใใ‚Œใ‚’็”จใ„ใฆ็ด ๅ› ๆ•ฐใ‚’็™บ่ฆ‹ใ™ใ‚‹ใ“ใจใงใ™ใ€‚ใ“ใ‚Œใฏๅคๅ…ธใ‚ณใƒณใƒ”ใƒฅใƒผใ‚ฟใงใ€2ใคใฎๆ•ฐใฎๆœ€ๅคงๅ…ฌ็ด„ๆ•ฐใ‚’่ฆ‹ใคใ‘ใ‚‹ใŸใ‚ใฎใ€ใƒฆใƒผใ‚ฏใƒชใƒƒใƒ‰ใฎใ‚ขใƒซใ‚ดใƒชใ‚บใƒ ใ‚’็”จใ„ใฆ่กŒใ‚ใ‚Œใพใ™ใ€‚ใƒฆใƒผใ‚ฏใƒชใƒƒใƒ‰ใฎใ‚ขใƒซใ‚ดใƒชใ‚บใƒ ใฏๆ•ฐๅญ—ใฎๅคงใใ•ใซใ‚ˆใฃใฆๅคš้ …ๅผๆ™‚้–“็š„ใซ่จˆ็ฎ—ๆ™‚้–“ใŒๅค‰ๅŒ–ใ—ใ€ๅฎŸ้š›ใ€ๅคๅ…ธใ‚ณใƒณใƒ”ใƒฅใƒผใ‚ฟใจ่จˆ็ฎ—้€Ÿๅบฆใฏๅค‰ๅŒ–ใ—ใชใ„ใŸใ‚ใ€ใ“ใฎใ‚นใƒ†ใƒƒใƒ—ใฏ้›ฃใ—ใ่€ƒใˆใ‚‹ๅฟ…่ฆใฏใ‚ใ‚Šใพใ›ใ‚“ใ€‚

ๅ‘จๆœŸ(r)ใ‚’ๆญฃใ—ใ่ฆ‹ใคใ‘ใ‚‰ใ‚ŒใŸใจใ™ใ‚‹ใจใ€(N)ใจ(a^{(r/2)}+1)ใจ(a^{(r/2)}-1)ใฎๆœ€ๅฐๅ…ฌๅ€ๆ•ฐใ‚’่ฆ‹ใคใ‘ใ‚‹ใ“ใจใงใ€(N)ใฎ็ด ๅ› ๆ•ฐใ‚’ๅฐŽใใ“ใจใŒใงใใพใ™ใ€‚

ไปฅไธŠใฎใพใจใ‚

(n)bitใง่กจใ•ใ‚Œใ‚‹ใ€(N)ใฎ็ด ๅ› ๆ•ฐใฎๆฑ‚ใ‚ๆ–นใ‚’ใŠใ•ใ‚‰ใ„ใ—ใฆใฟใพใ—ใ‚‡ใ†ใ€‚ใ‚ขใƒซใ‚ดใƒชใ‚บใƒ ใฏไปฅไธ‹ใฎใ‚นใƒ†ใƒƒใƒ—ใงๆง‹ๆˆใ•ใ‚Œใฆใ„ใพใ™ใ€‚

  1. (N)ใ‚ˆใ‚Šๅฐใ•ใ„็ด ๆ•ฐ(a)ใ‚’้ธใถ
  2. (a)ใŒใ€(N)ใฎ็ด ๅ› ๆ•ฐใงใ‚ใ‚‹ใ‹ใ‚’็ขบใ‹ใ‚ใพใ™ใ€‚ใ‚‚ใ—ใใ†ใงใ‚ใ‚Œใฐใใ‚Œใง็ต‚ใ‚ใ‚Šใงใ™ใ€‚
  3. ใใ†ใงใชใ„ๅ ดๅˆใ€้‡ๅญใ‚ณใƒณใƒ”ใƒฅใƒผใ‚ฟใจใƒ—ใƒญใ‚ฐใƒฉใƒ ใ‚’็”จใ„ใฆใ€ๅ‘จๆœŸใ‚’ๆฑ‚ใ‚ใพใ™ใ€‚
  4. ้‡ๅญใ‚ณใƒณใƒ”ใƒฅใƒผใ‚ฟใซใŠใ‘ใ‚‹ๆœ€ใ‚‚้‡่ฆใชใ‚นใƒ†ใƒƒใƒ—ใฏใ€ๅ…จใฆใฎ(x)ใซๅฏพใ™ใ‚‹(a^x)้‡ใญๅˆใ‚ใ›็Šถๆ…‹ใ‚’่จˆ็ฎ—ใ™ใ‚‹ใ“ใจใงใ™ใ€‚ๅ…จใฆ(bmod N) ใซใ‚ˆใฃใฆ่กŒใ‚ใ‚Œใพใ™ใ€‚(vert xrangle)ใจใ‚ใพใ‚Šใฏใฉใกใ‚‰ใ‚‚้‡ๅญใƒฌใ‚ธใ‚นใ‚ฟใฎไธญใซ็พใ‚Œใพใ™ใ€‚
  5. ไฝ™ใ‚Šใ‚’่จˆ็ฎ—ใ—ใพใ™ใ€‚๏ผˆๆŠ€่ก“็š„ใซใฏๅฟ…่ฆใ‚ใ‚Šใพใ›ใ‚“ใŒใ€่ชฌๆ˜Žใ‚’็ฐกๅ˜ใซใ™ใ‚‹ใŸใ‚ใซใ€ใ“ใฎๆ‰‹ๆณ•ใ‚’็”จใ„ใฆใ„ใใพใ™ใ€‚)
  6. (vert xrangle)ใซๅฏพใ—ใฆ้‡ๅญใƒ•ใƒผใƒชใ‚จๅค‰ๆ›ใ‚’่กŒใ„ใพใ™ใ€‚
  7. ใƒฌใ‚ธใ‚นใ‚ฟ(vert xrangle)ๆธฌๅฎšใ—ใพใ™ใ€‚ใ“ใฎ็ตๆžœใฏใ€ๅ†ชๅ‰ฐไฝ™ใฎๅ‘จๆœŸใฎๅฎŸๆ•ฐๅ€ใจใชใฃใฆใ„ใพใ™ใ€‚
  8. ใ‚‚ใ—(r)ใŒ0ใ‚ˆใ‚Šๅคงใใ‘ใ‚Œใฐ(a^{(r/2)}+1)ใจ(a^{(r/2)}-1)ใ‚’่จˆ็ฎ—ใ—ใ€0ใพใŸใฏ0ใ‚ˆใ‚Šๅฐใ•ใ„ใฎใชใ‚‰ใฐใ€ๆ–ฐใ—ใ„(r)ใ‚’่ฆ‹ใคใ‘ใ‚‹ใŸใ‚ใซๅ†ใณ้‡ๅญ่จˆ็ฎ—ใธๆˆปใ‚Šใพใ™ใ€‚
  9. ใƒฆใƒผใ‚ฏใƒชใƒƒใƒ‰ใฎใ‚ขใƒซใ‚ดใƒชใ‚บใƒ ใ‚’็”จใ„ใฆใ€ๅ„ๅ€คใจ(N)ใฎๆœ€ๅคงๅ…ฌ็ด„ๆ•ฐใ‚’ๆฑ‚ใ‚ใ‚‹ใ“ใจใงใ€(N)ใฎ็ด ๅ› ๆ•ฐใงใ‚ใ‚‹2ใคใฎๆ•ฐๅญ—ใ‚’ๅพ—ใ‚‹ใ“ใจใŒใงใใพใ™ใ€‚

ๅ€‹ใ€…ใฎๆŠ€่ก“ใซใคใ„ใฆใ€ใ‚ˆใ‚Š่ฉณใ—ใ่ฆ‹ใฆใ„ใใพใ—ใ‚‡ใ†ใ€‚

ยฉ Keio University
This article is from the free online

Understanding Quantum Computers

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now