22
1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter [email protected] June 27-29 WIDE University School of Internet with numerous slides from E. Abe Course Outline Lecture 1: Introduction Lecture 2: Quantum Algorithms Lecture 3: Devices and Technologies Lecture 4: Quantum Computer Architecture Lecture 5: Quantum Networking & Wrapup

Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter [email protected] June 27-29 WIDE

  • Upload
    vandan

  • View
    224

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter rdv@tera.ics.keio.ac.jp June 27-29 WIDE

1

Introduction to Quantum ComputingLecture 2: Quantum Algorithms

Rod Van [email protected]

June 27-29WIDE University School of Internetwith numerous slides from E. Abe

Course Outline

● Lecture 1: Introduction● Lecture 2: Quantum Algorithms● Lecture 3: Devices and Technologies● Lecture 4: Quantum Computer Architecture● Lecture 5: Quantum Networking & Wrapup

Page 2: Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter rdv@tera.ics.keio.ac.jp June 27-29 WIDE

2

Outline

● Introduction● Deutsch-Jozsa● Grover's search algorithm● Shor's factoring algorithm● Brief look at Quantum Error Correction (QEC)

How Do Quantum Algos Work?

● Runs are begun by creating a superposition of all possible input values.

● Executing a function gives a superposition of answers of all possible inputs! The hard part is extracting the answer we want.

● Every part of the superposition works independently on the algorithm.

● They all work by using interference. The phase of parts of the superposition are arranged to cancel out and leave only the interesting answer.

Page 3: Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter rdv@tera.ics.keio.ac.jp June 27-29 WIDE

3

n⊗0

0 0 0 0 1

2

0 1

2

0 1

2

1

2 n 2 0 00 0 01 1 11

1

2 n 2 0 1 2 N 11

2 n 2x

N 1

x

H 1

2

1 11 1 2n N created superposition of all

possible inputs

Apply Hadamards to n-qubit register

NO! Final step is to measure the register, and the superposition collapses to ONE state! It's as if we did the computation exactly once.

Quantum Parallelism

12 n 2

For example, x=0,1,…,N-1 calculate f(x) for all values of x

Using the quantum superposition, we run the calculation all at once

So do we get all of the answers for f(x)?

H⊗ n

(|ƒ (0) > + ƒ (1) > + ƒ (2) > + - - - + | ƒ (N-1) > )

H⊗n

Entanglement and Superposition

● Two qubits can have dependent values

00 11

2

1

200 0 01 0 10 1

211

Measure either qubit. If youget 0, you know the otherqubit must be 0.Bit0 Bit1

0 0 50%0 1 0%1 0 0%1 1 50%

1

2

1001

Page 4: Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter rdv@tera.ics.keio.ac.jp June 27-29 WIDE

4

Graphic Representation

Each bar is the amplitude of the wave function, that is, the square root of the probability, of finding the system in a particular state.

1

400 1

401 1

410 1

411

1

400 1

401 1

410 1

411

Example: Search

1

nN 2=

Start with all equalprobabilities:

Flip the phase ofthe answer:

Flip all states aboutthe mean (average):

The analog nature of phase figuresin strongly!

β

Page 5: Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter rdv@tera.ics.keio.ac.jp June 27-29 WIDE

5

Quantum Algorithms● Deutsch-Jozsa(D-J)

– Proc. R. Soc. London A, 439, 553 (1992)● Grover's search algorithm

– Phys. Rev. Lett., 79, 325 (1997)● Shor's algorithm for factoring large numbers

– SIAM J. Comp., 26, 1484 (1997)

D. Deutsch R. Jozsa L. K. Grover P. W. Shor

Deutsch's ProblemDetermine whether a function is “constant” or “balanced”

quantumQuery once to becertain!

constant:f(x) is either 0 for all x, or 1 for all x

balanced: f(x) is 0 for half the values of x, 1 for half the values

e.g., n=2:

e.g., n=2:

classicalMust query 2n-1+1 times to be certain

f x

f(x) =(0,0,0,0) or f(x)=(1,1,1,1)

f(x) =(0,0,1,1)

f(0) =?

f(1) =?

f(2) =?

Page 6: Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter rdv@tera.ics.keio.ac.jp June 27-29 WIDE

6

D-J Circuit

0

0 n

f fS

register

work bit

H x 1

2 z

x 1

2n 2z

∵ H 00 1

2H 1

0 1

2

Hadamard Gate

w h e r e , x x1

x2

xn

z z1

z2

zn

x z x 1 z 1 x 2 z 2 x n z n

transforms:

f Gate

S Gate

H⊗ n

H⊗ n⊗

(-1)xz|z>

(-1)xz|z>

ƒ|x>|y>|x>|y ƒ(x)>⊗

ƒ|x>|0> = |x>|0 ƒ(x)>=|x>|f(x)>⊗

ƒ|x>|f(x)>=|x>|f(x) f(x)>=|x>|0>⊗

S | x > | y > = (-1)y | x > | y >

What Happens in D-J

0 n0 H n f1

2n 2x

x 0 1

2 n 2x

x f x

Page 7: Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter rdv@tera.ics.keio.ac.jp June 27-29 WIDE

7

D-J (More Efficient Version)

Page 8: Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter rdv@tera.ics.keio.ac.jp June 27-29 WIDE

8

D-J and GroverDeutsch-Jozsa takes advantage of interference in the phase to cancel out unwanted terms in the superposition.

But, D-J uses only +1 and -1 in the phase and essentially calculates parity.

Grover's algorithm takes advantage of the full continuous nature of phase to create interference...

(Note: Remember, phase applies to the whole term in the superposition, not just a single qubit! Shift the phase on any qubitand you shift it on the whole term in the superposition.)

Grover's Search

nN 2= items

N 2 n unordered items, we're looking for item “β”

Classically, would have to check about N/2 items

To use Grover's algorithm, create superposition of all N inputs

N repetitions of the Grover iterator G will produce “β”

Hard task!!

β

Page 9: Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter rdv@tera.ics.keio.ac.jp June 27-29 WIDE

9

Grover's Algorithm Circuit

oracle: sometimes called a “gate”, an unknown function that tells us if we have the answer

G Gate Analysis

O 2Ox x 2 x x x

H n H noracle 2 0 0 1

O 1 2

2 1k

k k2N k ,k' ,k''

k k' ' k' kk

k k

k2

kk ∵ α

k

αk

N

sign flip for the answer only!

“inversion about average”

0k 2

Page 10: Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter rdv@tera.ics.keio.ac.jp June 27-29 WIDE

10

G Gate Analysis(2)

2 1 2cos 2sin 2

cos 2 sin 21 00 1

cos sinsin cos

O 1 2

1 00 1

2 01

0 1 1 00 1

G 2 1 Ocos sinsin cos

1

N 1x

x10

01

2

O

flipped with respect to

θ

flipped with respect to

rotate by angle θ

G

let alpha be the superposition of the N-1

possibilities that are wrong (e.g., not β)

N 1N

1

N

cos 2sin 2

∵θ 2arctan 1 N 1

2

2-D plane

2 30

Execution Example, N=4

1

4sin

2

changes in planeEvery value starts with equal amplitude (probability)

12

00 01 10 11

OO

12

00 01 10 11

2 11

2 1

60

1 execution of G gives 100% chance of correct answer (rare case)

2 k

214

12

00 214

12

01 214

12

10 214

12

11

10

Page 11: Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter rdv@tera.ics.keio.ac.jp June 27-29 WIDE

11

Execution Example, N=8

1

8sin

2

G 5

281

28

Gθ41.4°

Every value starts with equal amplitude

2

G11

4 8 1

4 8

G

θ

Executing G twice takes us close to the answer; more takes us PAST the answer

changes in plane

Repeat CountHow many times do we have to repeat G to get the

answer?

Page 12: Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter rdv@tera.ics.keio.ac.jp June 27-29 WIDE

12

Grover and Shor

Grover uses interference in phase to cancel unwanted terms.

Shor goes a step further, broadening the range of conditions in which useful interference occurs, by doing a Fourier transform...

Shor's Factoring Algorithm66554087 ? 6703 9929

An “efficient” classical algorithm for this problem is not known.

Using classical number field sieve, factoring anL-bit number is

Using quantum Fouriertransform (QFT), factoring an L-bit number is

Superpolynomial speedup! (Careful, technicallynot exponential speedup, and not yet proven thatno better classical algorithm exists.)

Page 13: Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter rdv@tera.ics.keio.ac.jp June 27-29 WIDE

13

Quantum Fourier Transformj QFT

N

1

N k 0

N 1

exp 2 ijk N k

H R2

R3

H R2

HR

k1 00 exp 2 i 2k

Circuit for QFT8

QFT818

1 1 1 1 1 1 1 11 1 2 3 4 5 6 7

1 2 4 6 1 2 4 6

1 3 6 1 4 7 2 5

1 4 1 4 1 4 1 4

1 5 2 7 4 1 6 3

1 6 4 2 1 6 4 2

1 7 6 5 4 3 2 1

exp 2 i 8 iUnitary matrix for QFT8

i i 4 0

FFT in quantum form

Page 14: Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter rdv@tera.ics.keio.ac.jp June 27-29 WIDE

14

Order-finding

Page 15: Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter rdv@tera.ics.keio.ac.jp June 27-29 WIDE

15

Order-finding Process

0 43 H 4 14 x 0

15

x 3

Î 3

14 x 0

15

x x 3

14

0 4 8 12 3

14

1 5 9 13 1

14

2 6 10 14 7

14

3 7 11 15 0

measurementgives one of

0,4,8,12Run through classical computer to find r

14

0 4 8 12 3

14

0 i 4 8 i 12 1

14

0 4 8 12 7

14

0 i 4 8 i 12 0

QFT16

QFT16

1

16

1 1 1 11 1 2 15

1 2 4 14

1 15 14 1

exp 2 i 16i i 8 0

Shor's Algorithm Flow

ar 1 modL find smallest r

r e v e n

p gcd ar 2 1,Lq gcd ar 2 1,L

L pq

calculate

a 1 a LL is the number we wish to factor; pick a random

p , q L

1. even2. prime3. power of a prime

Algorithm fails if L is:

NO

NO

YES

YES

quantum order-findingcalculate

Page 16: Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter rdv@tera.ics.keio.ac.jp June 27-29 WIDE

16

Factoring L=15

1 7 4 131 1 2 1 3 1

4 1ar 2 1 48 gcd 48,15 3ar 2 1 50 gcd 50,15 5

a 7

1 141 1

2 1

ar 2 1 13 gcd 13,15 1ar 2 1 15 gcd 15,15 15

a 14

r2 r7 r8 r13 4

Failure!!

1 111 1

2 1

ar 2 1 10 gcd 10,15 5ar 2 1 12 gcd 12,15 3

a 11

r4 r11 r14 2

a 2,4,7,8,11,13,14

Page 17: Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter rdv@tera.ics.keio.ac.jp June 27-29 WIDE

17

Euclid's Method

494 133 3 95

133 95 1 38

95 38 2 19

38 19 2

95

133

3895

19

38

Algorithm for findinggreatest common

denominator

494

133

gcd(494,133)

Π Gate (Circuit)x 2n 1 x n 1 2 n 2 x n 2 2 x 1 x 0

a x mod L a2 n 1 x

n 1 a2n 2 x

n 2 a2 x

1 ax

0 mod L

a2 n 1 x

n 1 mod L a2 n 2 x

n 2 mod L ax

0 mod L

Î x y x axymodL

Î therefore,

U2jU20

U21U2n 1

x0

x1

xj

xn 1

U2jy a2j

y modL

can be constructedusing classical techniques

a2jmodL

Van Meter & ItohPRA 71, 052320 (2005)「xj is the “enable bit” for the

multiplication

Page 18: Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter rdv@tera.ics.keio.ac.jp June 27-29 WIDE

18

Back to Factoring L=15

a 7Step.1 Pick random a

© Colin P. Williams (1997)

Step.2 Order-findingQFT example (N =28=256)

0 50 100 150 200

1

0.1

0.01

0.001

0.0001

0.00001

0 64 128 192

Step.3 Measure to recover r

r 4

Step.4p gcd( )ar 2 1,Lq gcd( )ar 2 1,L

calculate

ar 2 1 48 gcd(48,15)=3ar 2 1 50 gcd(50,15)=5

15 3 5Done!

Other Order-Finding Algos.

● Abelian subgroup, discrete logarithm● QFT based, but very different in classical portion

of algorithm● Hidden subgroup problems in general

Page 19: Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter rdv@tera.ics.keio.ac.jp June 27-29 WIDE

19

Main Classes of Algorithms

● 1: Use the QFT to find periodicity● 2: Grover's algorithm and friends● 3: Simulating quantum physics● (D-J seems to fall outside these)

Architecture Affects Algorithm Efficiency

Long-distance gates

Neighbor onlyoperations requireswapping qubits

2-qubitgate

Single line layout, neighbor only

2-qubitgate

swapqubitvalues

Page 20: Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter rdv@tera.ics.keio.ac.jp June 27-29 WIDE

20

Quantum Error Correction

● Discovered by Shor and Calderbank● Important work done by Steane● Based on known classical techniques, but with

important extensions● Must correct both bit errors and phase errors

3-bit Code EncodingKeep a logical qubit in triplicate:

0 1 enc odeL

000 111

This protects against single bit-flip errors,same as in classical coding.

1

0

0} L

Encoding circuit:

Page 21: Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter rdv@tera.ics.keio.ac.jp June 27-29 WIDE

21

3-bit Code Correction

000 111 er r or 010 101

Bit flip error occurs:

How do you correct?Calculate parity pair-wise; results will tell you which bit is in error,then a simple NOT gate on that bit will correct.

1

2

0

Parity circuit:

This bit now holds parity of 1 & 2

Just measure that bottom bit and you get the parity of that pair;two parities can tell you which bit was in error.

Wait a Minute!You said measurement destroys the superposition, won'twe lose our important quantum state?

Not quite... you only lose as much superposition as youlearn about the state. This is called a “partial trace”. α| 000 > |0 + β | 111 > | 0 > parity

0 111 0 parity 010 parity 101 parity

Measuring this qubit...Tells us nothingabout these qubits.

But measuringthis one wouldtell us somethingand collapse the state!

Page 22: Introduction to Quantum Computing Lecture 2: Quantum ... · 1 Introduction to Quantum Computing Lecture 2: Quantum Algorithms Rod Van Meter rdv@tera.ics.keio.ac.jp June 27-29 WIDE

22

What About Phase?

So far, that gets us bit flip protection. Now we need phase flip...

This is a basis change, and protects us against the phase flip error:

This code can be combined with the bit flip code to create the9-bit Shor code.

Wrap-Up on Algorithms

● “Quantum” algorithms actually have both quantum and classical parts

● Use of quantum interference based on complex,analog phase is critical

● Period-finding algorithms work well(exponential speedup over best known algos, but not yet proven better)