quantum algorithms - florida atlantic materials/quantum 's algorithm for factoring a given...

Download Quantum Algorithms - Florida Atlantic   materials/quantum  's Algorithm for factoring a given integer N: Quantum Algorithms Bal K. Khadka Florida Atlantic University

Post on 17-Feb-2018

213 views

Category:

Documents

1 download

Embed Size (px)

TRANSCRIPT

  • Shor's Algorithm for factoring a given integer N:

    Quantum AlgorithmsBal K. Khadka

    Florida Atlantic University

  • Shor's Algorithm for factoring a given integer N:

    1 Shor's Algorithm for factoring a given integer N:

    Prodedure

    Given an odd composite number N, nd an integer d such

    that gcd (d ,N) 6= 1.If N is a prime, a even number, or an integer power of a primenumber (can be tested by taking k-th roots of N, for k log2N),we do not use Shor's algorithm because there are ecient classicalmethods for determining it. So we take an odd composite N = pqwhere p and q are two coprime numbers greater than 1. Hence byChinese Remainder Theorem 1 has at least 4 distinct roots moduloN, two of them being 1 and -1. Our aim is to nd a square root bof 1 other than 1 and -1.

  • Shor's Algorithm for factoring a given integer N:

    Shor's algorithm consists of two parts:1) A reduction, which can be done on a classical computer, of thefactoring problem to the problem of order-nding.

    2) A quantum algorithm to solve the order-nding problem.

  • Shor's Algorithm for factoring a given integer N:

    Classical part

    1) Pick a random element x{2, 3, ,N 1}.2) Compute gcd(x ,N). This may be done using the Euclideanalgorithm.3) If gcd(x ,N) 6= 1, then there is a nontrivial factor of N, so we aredone.

  • Shor's Algorithm for factoring a given integer N:

    Classical part

    4) Otherwise, use the period-nding subroutine to nd r, the periodof the following function:f (a) = xamod N, i.e. the order r of x in (ZN), which is thesmallest positive integer r for which f (a + r) = f (a).

    5) If r is odd, go back to step 1.6) If x r/2 = 1mod N, go back to step 1.7) gcd(x r/2 1,N) is a nontrivial factor of N. We are done.

  • Shor's Algorithm for factoring a given integer N:

    def power(x , q,N) :box = []for i in range(q) :

    a = (x i)box .append(a)

    returnbox

  • Shor's Algorithm for factoring a given integer N:

    Example:1

    Let N = 799Pick 7 as an x in classical part. gcd(799, 7) = 1. ok.7368 = 1mod 799 (we can compute using wolfram alpha).Now 7184 1mod 799 = 423 and 7184 + 1mod 799 = 425.gcd(799, 425) = 17 and gcd(799, 423) = 47Therefore 799 = 17 47

  • Shor's Algorithm for factoring a given integer N:

    Quantum part

    Pick an integer q that is a power of 2 such thatN2 q < 2N2. This step would be done on classical computer.Creat a quantum register and partition it into two sets,register one and register two. Thus the state of our quantumcomputer can be given by: |reg1, reg2 > . Register one musthave enough qubits to represent integers as large as q 1.Register two must have enough qubits (say m) to representintegers as large as N 1 then m = plogNq.

  • Shor's Algorithm for factoring a given integer N:

    Quantum part

    Pick an integer q that is a power of 2 such thatN2 q < 2N2. This step would be done on classical computer.Creat a quantum register and partition it into two sets,register one and register two. Thus the state of our quantumcomputer can be given by: |reg1, reg2 > . Register one musthave enough qubits to represent integers as large as q 1.Register two must have enough qubits (say m) to representintegers as large as N 1 then m = plogNq.

  • Shor's Algorithm for factoring a given integer N:

    Quantam part

    Load register one with an equally weighted superposition of allintegers form 0 to q-1, register two with the 0 state.

    this operation would be performed by our quantum computer.The total state of the quantum memory at this point is:1q

    a=q1a=0 |a, 0 >

  • Shor's Algorithm for factoring a given integer N:

    Quantam part

    Load register one with an equally weighted superposition of allintegers form 0 to q-1, register two with the 0 state.

    this operation would be performed by our quantum computer.The total state of the quantum memory at this point is:1q

    a=q1a=0 |a, 0 >

  • Shor's Algorithm for factoring a given integer N:

    Quantam part

    Load register one with an equally weighted superposition of allintegers form 0 to q-1, register two with the 0 state.

    this operation would be performed by our quantum computer.The total state of the quantum memory at this point is:1q

    a=q1a=0 |a, 0 >

  • Shor's Algorithm for factoring a given integer N:

    Apply the transformation xamod N for each number stored inregister one and store the result in register two. Usingquantum parallelism this will take only one step, as thequantum computer will only calculate x |a>mod N, where|a >is the superposition of states created in step 5. The stateof the quantum memory register at this point is:1q

    q1a=0 |a, xamodN >.

  • Shor's Algorithm for factoring a given integer N:

    Perform a measurement in the computational basis todetermine the bit values in the second register. This has theside eect of collapsing register one into an equal superpositionof each value a between 0 and q 1 such that xamod N = y .Suppose that the result is y = x lmod N for the smallest l withthis property. If r is the period of x then x l = x jr+l (mod)Nfor all j .

    The measurement selects the sequence of as values (in therst register), l , l + r , l + 2r , , l +Ar , where A is the largestinteger such that l + Ar q 1, and l r . Clearly A q/r .The state of the quantum memory register after this step is:

    |l >= 1A+1Aj=0|jr + l , y > . (post measurement of the rst

    register.)

  • Shor's Algorithm for factoring a given integer N:

    Perform a measurement in the computational basis todetermine the bit values in the second register. This has theside eect of collapsing register one into an equal superpositionof each value a between 0 and q 1 such that xamod N = y .Suppose that the result is y = x lmod N for the smallest l withthis property. If r is the period of x then x l = x jr+l (mod)Nfor all j .

    The measurement selects the sequence of as values (in therst register), l , l + r , l + 2r , , l +Ar , where A is the largestinteger such that l + Ar q 1, and l r . Clearly A q/r .The state of the quantum memory register after this step is:

    |l >= 1A+1Aj=0|jr + l , y > . (post measurement of the rst

    register.)

  • Shor's Algorithm for factoring a given integer N:

    Perform a measurement in the computational basis todetermine the bit values in the second register. This has theside eect of collapsing register one into an equal superpositionof each value a between 0 and q 1 such that xamod N = y .Suppose that the result is y = x lmod N for the smallest l withthis property. If r is the period of x then x l = x jr+l (mod)Nfor all j .

    The measurement selects the sequence of as values (in therst register), l , l + r , l + 2r , , l +Ar , where A is the largestinteger such that l + Ar q 1, and l r . Clearly A q/r .The state of the quantum memory register after this step is:

    |l >= 1A+1Aj=0|jr + l , y > . (post measurement of the rst

    register.)

  • Shor's Algorithm for factoring a given integer N:

    Perform a measurement in the computational basis todetermine the bit values in the second register. This has theside eect of collapsing register one into an equal superpositionof each value a between 0 and q 1 such that xamod N = y .Suppose that the result is y = x lmod N for the smallest l withthis property. If r is the period of x then x l = x jr+l (mod)Nfor all j .

    The measurement selects the sequence of as values (in therst register), l , l + r , l + 2r , , l +Ar , where A is the largestinteger such that l + Ar q 1, and l r . Clearly A q/r .The state of the quantum memory register after this step is:

    |l >= 1A+1Aj=0|jr + l , y > . (post measurement of the rst

    register.)

  • Shor's Algorithm for factoring a given integer N:

    Special case(r|q)

    Compute the discrete Fourieer transform on register one. Thediscrete Fourier transform when applied to a state |a >changesit in the following manner:

    |a >7 1q

    q1c=0 |c > e2iac/q

    In this case A = qr 1, and the last state is

    |l >=

    rq

    Aj=0|jr + l , y > .

    After the quantum Fourier transform applied on |l > ourregister is in the state:

  • Shor's Algorithm for factoring a given integer N:

    Special case(r|q)

    Compute the discrete Fourieer transform on register one. Thediscrete Fourier transform when applied to a state |a >changesit in the following manner:

    |a >7 1q

    q1c=0 |c > e2iac/q

    In this case A = qr 1, and the last state is

    |l >=

    rq

    Aj=0|jr + l , y > .

    After the quantum Fourier transform applied on |l > ourregister is in the state:

  • Shor's Algorithm for factoring a given integer N:

    Special case(r|q)

    Compute the discrete Fourieer transform on register one. Thediscrete Fourier transform when applied to a state |a >changesit in the following manner:

    |a >7 1q

    q1c=0 |c > e2iac/q

    In this case A = qr 1, and the last state is

    |l >=

    rq

    Aj=0|jr + l , y > .

    After the quantum Fourier transform applied on |l > ourregister is in the state:

  • Shor's Algorithm for factoring a given integer N:

    Measuring rst register

    QFTq|l >= 1qq1

    c=0

    rq

    Aj=0 |c, y > e2ic(jr+l)/q =

    rq

    q1c=0e

    2ilc/q(A

    j=0 e2ijcr/q)|c , y >.

    If c is a multiple of qr, then e2ijcr/q = 1 and if c is not a

    multiple of qr, then

    Aj=0 e

    2ijcr/q = 0. because the above sumis over a set of q

    rroots of unity equally spaced around the unit

    circle.

    Therefore |ou

Recommended

View more >