You are on page 1of 236

Quantum Algorithms

Lecture: Joran van Apeldoorn


Exercises: Arjan Cornelissen

9th of September
Quantum algorithms

There are many quantum algorithms.

1 / 39
Quantum algorithms

There are many quantum algorithms.


There are even more misconceptions about quantum algorithms.

1 / 39
Quantum algorithms

There are many quantum algorithms.


There are even more misconceptions about quantum algorithms.
Goal: Get an understanding of how quantum algorithms work

1 / 39
Quantum algorithms

There are many quantum algorithms.


There are even more misconceptions about quantum algorithms.
Goal: Get an understanding of how quantum algorithms work
and how they do not work.

1 / 39
Quantum algorithms

There are many quantum algorithms.


There are even more misconceptions about quantum algorithms.
Goal: Get an understanding of how quantum algorithms work
and how they do not work.
We will focus on the techniques and insight.
(The not so famous, but really cool stuff)

1 / 39
Overview

Basics - Quantum states, gates and circuits.

2 / 39
Overview

Basics - Quantum states, gates and circuits.


Amplitude amplification - Picking out solutions.

2 / 39
Overview

Basics - Quantum states, gates and circuits.


Amplitude amplification - Picking out solutions.
Phase estimation - Investigating unitaries.

2 / 39
Overview

Basics - Quantum states, gates and circuits.


Amplitude amplification - Picking out solutions.
Phase estimation - Investigating unitaries.
Amplitude estimation - Estimating probabilities.

2 / 39
Overview

Basics - Quantum states, gates and circuits.


Amplitude amplification - Picking out solutions.
Phase estimation - Investigating unitaries.
Amplitude estimation - Estimating probabilities.
Overview of other algorithms
§ Shors factoring algorithm.
§ HHL for systems of linear equations.
§ Gradient computation.

2 / 39
Overview

Basics - Quantum states, gates and circuits.


Amplitude amplification - Picking out solutions.
Phase estimation - Investigating unitaries.
Amplitude estimation - Estimating probabilities.
Overview of other algorithms
§ Shors factoring algorithm.
§ HHL for systems of linear equations.
§ Gradient computation.
A quick quiz!

2 / 39
Basics
Quantum states

A bit is 0 or 1, a qubit is in a superposition of |0y and |1y:

|ψy “ α0 |0y ` α1 |1y

3 / 39
Quantum states

A bit is 0 or 1, a qubit is in a superposition of |0y and |1y:

|ψy “ α0 |0y ` α1 |1y

If we measure then we get one outcome.


The probability of measuring |0y is |α0 |2 .
The probability of measuring |1y is |α1 |2 .

3 / 39
Quantum states

A bit is 0 or 1, a qubit is in a superposition of |0y and |1y:

|ψy “ α0 |0y ` α1 |1y

If we measure then we get one outcome.


The probability of measuring |0y is |α0 |2 .
The probability of measuring |1y is |α1 |2 .
We combine qubits to create bigger states via tensor products.

3 / 39
Quantum states

A bit is 0 or 1, a qubit is in a superposition of |0y and |1y:

|ψy “ α0 |0y ` α1 |1y

If we measure then we get one outcome.


The probability of measuring |0y is |α0 |2 .
The probability of measuring |1y is |α1 |2 .
We combine qubits to create bigger states via tensor products.
Quantum states are normalized complex vectors, the classical
states |0y , |1y , |2y , . . . form a basis. (why normalized?)

3 / 39
Quantum states

A bit is 0 or 1, a qubit is in a superposition of |0y and |1y:

|ψy “ α0 |0y ` α1 |1y

If we measure then we get one outcome.


The probability of measuring |0y is |α0 |2 .
The probability of measuring |1y is |α1 |2 .
We combine qubits to create bigger states via tensor products.
Quantum states are normalized complex vectors, the classical
states |0y , |1y , |2y , . . . form a basis. (why normalized?)
For a qubit: „  „ 
1 0
|0y “ |1y “
0 1

3 / 39
Quantum gates

We can change states by applying unitaries, since they keep


vectors normalized.

4 / 39
Quantum gates

We can change states by applying unitaries, since they keep


vectors normalized.
Unitaries on only a few qubits are called gates.

4 / 39
Quantum gates

We can change states by applying unitaries, since they keep


vectors normalized.
Unitaries on only a few qubits are called gates.
„  „ 
1 0 0 1
I :“ , X :“ ,
0 1 1 0

1 1 1
„  „ 
1 0
Z :“ , H :“ ? .
0 ´1 2 1 ´1

4 / 39
Quantum gates

We can change states by applying unitaries, since they keep


vectors normalized.
Unitaries on only a few qubits are called gates.
„  „ 
1 0 0 1
I :“ , X :“ ,
0 1 1 0

1 1 1
„  „ 
1 0
Z :“ , H :“ ? .
0 ´1 2 1 ´1

I does nothing.

4 / 39
Quantum gates

We can change states by applying unitaries, since they keep


vectors normalized.
Unitaries on only a few qubits are called gates.
„  „ 
1 0 0 1
I :“ , X :“ ,
0 1 1 0

1 1 1
„  „ 
1 0
Z :“ , H :“ ? .
0 ´1 2 1 ´1

I does nothing.
X changes |0y into |1y and vice versa.

4 / 39
Quantum gates

We can change states by applying unitaries, since they keep


vectors normalized.
Unitaries on only a few qubits are called gates.
„  „ 
1 0 0 1
I :“ , X :“ ,
0 1 1 0

1 1 1
„  „ 
1 0
Z :“ , H :“ ? .
0 ´1 2 1 ´1

I does nothing.
X changes |0y into |1y and vice versa.
Z adds a ´1 in front of |1y.

4 / 39
Quantum gates

We can change states by applying unitaries, since they keep


vectors normalized.
Unitaries on only a few qubits are called gates.
„  „ 
1 0 0 1
I :“ , X :“ ,
0 1 1 0

1 1 1
„  „ 
1 0
Z :“ , H :“ ? .
0 ´1 2 1 ´1

I does nothing.
X changes |0y into |1y and vice versa.
Z adds a ´1 in front of |1y.
|0y`|1y |0y´|1y
H changes |0y and |1y into ?
2
and ?
2
.

4 / 39
Changing the basis
Claim: H is a basis transform

5 / 39
Changing the basis
Claim: H is a basis transform
|0y ` |1y |0y ´ |1y
|`y :“ ? |´y :“ ?
2 2

5 / 39
Changing the basis
Claim: H is a basis transform
|0y ` |1y |0y ´ |1y
|`y :“ ? |´y :“ ?
2 2

|1y

|0y

5 / 39
Changing the basis
Claim: H is a basis transform
|0y ` |1y |0y ´ |1y
|`y :“ ? |´y :“ ?
2 2

|1y
|`y

|0y

|´y

5 / 39
A first circuit

H Z H
What does this circuit do? We only need to try a basis (Why?).

6 / 39
A first circuit

H Z H
What does this circuit do? We only need to try a basis (Why?).
On |0y:

|0y ` |1y
|0y ÞÑ ?
2

6 / 39
A first circuit

H Z H
What does this circuit do? We only need to try a basis (Why?).
On |0y:

|0y ` |1y |0y ´ |1y


|0y ÞÑ ? ÞÑ ?
2 2

6 / 39
A first circuit

H Z H
What does this circuit do? We only need to try a basis (Why?).
On |0y:

|0y ` |1y |0y ´ |1y 1


|0y ÞÑ ? ÞÑ ? ÞÑ p|0y ` |1y ´ p|0y ´ |1yqq
2 2 2

6 / 39
A first circuit

H Z H
What does this circuit do? We only need to try a basis (Why?).
On |0y:

|0y ` |1y |0y ´ |1y 1


|0y ÞÑ ? ÞÑ ? ÞÑ p|0y ` |1y ´ p|0y ´ |1yqq “ |1y
2 2 2

6 / 39
A first circuit

H Z H
What does this circuit do? We only need to try a basis (Why?).
On |0y:

|0y ` |1y |0y ´ |1y 1


|0y ÞÑ ? ÞÑ ? ÞÑ p|0y ` |1y ´ p|0y ´ |1yqq “ |1y
2 2 2

On |1y:

|0y ´ |1y
|1y ÞÑ ?
2

6 / 39
A first circuit

H Z H
What does this circuit do? We only need to try a basis (Why?).
On |0y:

|0y ` |1y |0y ´ |1y 1


|0y ÞÑ ? ÞÑ ? ÞÑ p|0y ` |1y ´ p|0y ´ |1yqq “ |1y
2 2 2

On |1y:

|0y ´ |1y |0y ` |1y


|1y ÞÑ ? ÞÑ ?
2 2

6 / 39
A first circuit

H Z H
What does this circuit do? We only need to try a basis (Why?).
On |0y:

|0y ` |1y |0y ´ |1y 1


|0y ÞÑ ? ÞÑ ? ÞÑ p|0y ` |1y ´ p|0y ´ |1yqq “ |1y
2 2 2

On |1y:

|0y ´ |1y |0y ` |1y 1


|1y ÞÑ ? ÞÑ ? ÞÑ p|0y ` |1y ` |0y ´ |1yq
2 2 2

6 / 39
A first circuit

H Z H
What does this circuit do? We only need to try a basis (Why?).
On |0y:

|0y ` |1y |0y ´ |1y 1


|0y ÞÑ ? ÞÑ ? ÞÑ p|0y ` |1y ´ p|0y ´ |1yqq “ |1y
2 2 2

On |1y:

|0y ´ |1y |0y ` |1y 1


|1y ÞÑ ? ÞÑ ? ÞÑ p|0y ` |1y ` |0y ´ |1yq “ |0y
2 2 2

This is a X gate!

6 / 39
A first circuit

H Z H
What does this circuit do? We only need to try a basis (Why?).
On |0y:

|0y ` |1y |0y ´ |1y 1


|0y ÞÑ ? ÞÑ ? ÞÑ p|0y ` |1y ´ p|0y ´ |1yqq “ |1y
2 2 2

On |1y:

|0y ´ |1y |0y ` |1y 1


|1y ÞÑ ? ÞÑ ? ÞÑ p|0y ` |1y ` |0y ´ |1yq “ |0y
2 2 2

This is a X gate! Z is just X in the t|`y , |´yu basis (and vice versa).

6 / 39
Reflections

We can also see this in our image.

|1y
|`y

|0y

|´y

7 / 39
Reflections

We can also see this in our image.


Z is a reflection through the |0y state.

|1y
|`y

|0y

|´y

7 / 39
Reflections

We can also see this in our image.


Z is a reflection through the |0y state.
X is a reflection through the |`y state.
|1y
|`y

|0y

|´y

7 / 39
More gates

A phase is a factor of the form ei2πθ .

8 / 39
More gates

A phase is a factor of the form ei2πθ .


„ i2πθ 
i2πθ
e 0
e I “
0 ei2πθ

8 / 39
More gates

A phase is a factor of the form ei2πθ .


„ i2πθ 
i2πθ
e 0
e I “
0 ei2πθ
„ 
1 0
π{2 “
0 eiπ{2

8 / 39
More gates

A phase is a factor of the form ei2πθ .


„ i2πθ 
i2πθ
e 0
e I “
0 ei2πθ
„ 
1 0
π{2 “
0 eiπ{2

We can also make gates controlled:

‚ “

8 / 39
More gates

A phase is a factor of the form ei2πθ .


„ i2πθ 
i2πθ
e 0
e I “
0 ei2πθ
„ 
1 0
π{2 “
0 eiπ{2

We can also make gates controlled:

1 0 0 0
» fi
—0 1 0 0ffi
‚ “ ‚ “—
–0

0 0 1fl
0 0 1 0
X

8 / 39
Oracles

Classical algorithms make calls to the memory to get the input.

9 / 39
Oracles

Classical algorithms make calls to the memory to get the input.


Quantum algorithms get an oracle that mimics this.

9 / 39
Oracles

Classical algorithms make calls to the memory to get the input.


Quantum algorithms get an oracle that mimics this.
Oracle is a fancy word for black-box.

9 / 39
Oracles

Classical algorithms make calls to the memory to get the input.


Quantum algorithms get an oracle that mimics this.
Oracle is a fancy word for black-box.
A binary oracle for an input x P t0, 1un is a unitary

Ox |iy|by “ |iy|b ‘ xi y

where ‘ is addition modulo 2 (or the XOR)

9 / 39
Oracles

Classical algorithms make calls to the memory to get the input.


Quantum algorithms get an oracle that mimics this.
Oracle is a fancy word for black-box.
A binary oracle for an input x P t0, 1un is a unitary

Ox |iy|by “ |iy|b ‘ xi y

where ‘ is addition modulo 2 (or the XOR)


A phase oracle for an input x P t0, 1un is a unitary

Ox,˘ |iy “ p´1qxi |iy

9 / 39
Oracles

Classical algorithms make calls to the memory to get the input.


Quantum algorithms get an oracle that mimics this.
Oracle is a fancy word for black-box.
A binary oracle for an input x P t0, 1un is a unitary

Ox |iy|by “ |iy|b ‘ xi y

where ‘ is addition modulo 2 (or the XOR)


A phase oracle for an input x P t0, 1un is a unitary

Ox,˘ |iy “ p´1qxi |iy

We often want a controlled phase oracle:

Ox,˘ |iy |0y “ |iy |0y , Ox,˘ |iy |1y “ p´1qxi |iy |1y

9 / 39
Interpreting oracles

Let us look closer at a binary oracle.

Ox |iy|by “ |iy|b ‘ xi y

10 / 39
Interpreting oracles

Let us look closer at a binary oracle.


#
|iy|by if xi “ 0
Ox |iy|by “ |iy|b ‘ xi y “ ˇ Dˇ D
ˇi ˇb̄ if xi “ 1

10 / 39
Interpreting oracles

Let us look closer at a binary oracle.


#
|iy|by if xi “ 0
Ox |iy|by “ |iy|b ‘ xi y “ ˇ Dˇ D
ˇi ˇb̄ if xi “ 1

So a X is applied to b if xi “ 1.

10 / 39
Interpreting oracles

Let us look closer at a binary oracle.


#
|iy|by if xi “ 0
Ox |iy|by “ |iy|b ‘ xi y “ ˇ Dˇ D
ˇi ˇb̄ if xi “ 1

So a X is applied to b if xi “ 1.
Let us look closer at a controlled phase oracle.
#
|iy|by if xi “ 0
Ox,˘ |iy|by “
|iy Z |by if xi “ 1

10 / 39
Interpreting oracles

Let us look closer at a binary oracle.


#
|iy|by if xi “ 0
Ox |iy|by “ |iy|b ‘ xi y “ ˇ Dˇ D
ˇi ˇb̄ if xi “ 1

So a X is applied to b if xi “ 1.
Let us look closer at a controlled phase oracle.
#
|iy|by if xi “ 0
Ox,˘ |iy|by “
|iy Z |by if xi “ 1

A Z is applied to b if xi “ 1.

10 / 39
Interpreting oracles

Let us look closer at a binary oracle.


#
|iy|by if xi “ 0
Ox |iy|by “ |iy|b ‘ xi y “ ˇ Dˇ D
ˇi ˇb̄ if xi “ 1

So a X is applied to b if xi “ 1.
Let us look closer at a controlled phase oracle.
#
|iy|by if xi “ 0
Ox,˘ |iy|by “
|iy Z |by if xi “ 1

A Z is applied to b if xi “ 1.
How would you convert between the two types of oracle?

10 / 39
Amplitude amplification
Randomized algorithms

Let us get back to classical computing for a while:

11 / 39
Randomized algorithms

Let us get back to classical computing for a while:


An algorithm is randomized if it uses random bits.

11 / 39
Randomized algorithms

Let us get back to classical computing for a while:


An algorithm is randomized if it uses random bits.
Maybe our algorithm does not always work, it has a success
probability p.

11 / 39
Randomized algorithms

Let us get back to classical computing for a while:


An algorithm is randomized if it uses random bits.
Maybe our algorithm does not always work, it has a success
probability p.
Formally, The algorithm outputs:

11 / 39
Randomized algorithms

Let us get back to classical computing for a while:


An algorithm is randomized if it uses random bits.
Maybe our algorithm does not always work, it has a success
probability p.
Formally, The algorithm outputs:
§ a 1 and a good solution with probability p, or

11 / 39
Randomized algorithms

Let us get back to classical computing for a while:


An algorithm is randomized if it uses random bits.
Maybe our algorithm does not always work, it has a success
probability p.
Formally, The algorithm outputs:
§ a 1 and a good solution with probability p, or
§ a 0 and a bad solution with probability 1 ´ p.

11 / 39
Randomized algorithms

Let us get back to classical computing for a while:


An algorithm is randomized if it uses random bits.
Maybe our algorithm does not always work, it has a success
probability p.
Formally, The algorithm outputs:
§ a 1 and a good solution with probability p, or
§ a 0 and a bad solution with probability 1 ´ p.
An algorithm works with high probability if p ě 2{3.

11 / 39
Randomized algorithms

Let us get back to classical computing for a while:


An algorithm is randomized if it uses random bits.
Maybe our algorithm does not always work, it has a success
probability p.
Formally, The algorithm outputs:
§ a 1 and a good solution with probability p, or
§ a 0 and a bad solution with probability 1 ´ p.
An algorithm works with high probability if p ě 2{3.
What can we do if p is small?

11 / 39
Randomized algorithms

Let us get back to classical computing for a while:


An algorithm is randomized if it uses random bits.
Maybe our algorithm does not always work, it has a success
probability p.
Formally, The algorithm outputs:
§ a 1 and a good solution with probability p, or
§ a 0 and a bad solution with probability 1 ´ p.
An algorithm works with high probability if p ě 2{3.
What can we do if p is small?
Repeat
1
ˆ ˙
O
p
times.

11 / 39
Example: prime finding

Consider to following algorithm:


Prime finding

1. Pick a random n-bit number k.


2. Check if k is prime.
3. Return whether k is prime and k itself.

12 / 39
Example: prime finding

Consider to following algorithm:


Prime finding

1. Pick a random n-bit number k.


2. Check if k is prime.
3. Return whether k is prime and k itself.

Probability of k being a prime is « n1 .

12 / 39
Example: prime finding

Consider to following algorithm:


Prime finding

1. Pick a random n-bit number k.


2. Check if k is prime.
3. Return whether k is prime and k itself.

Probability of k being a prime is « n1 .


ñ O pnq repetitions suffice.

12 / 39
Quantum algorithms with small success probability

Back to quantum:

13 / 39
Quantum algorithms with small success probability

Back to quantum:
Quantum algorithms are inherently random.

13 / 39
Quantum algorithms with small success probability

Back to quantum:
Quantum algorithms are inherently random.
A Hadamard gate can be used to flip a coin:
1
H |0y “ ? p|0y ` |1yq
2

13 / 39
Quantum algorithms with small success probability

Back to quantum:
Quantum algorithms are inherently random.
A Hadamard gate can be used to flip a coin:
1
H |0y “ ? p|0y ` |1yq
2

A quantum algorithm might produce the state

U |0y “ αG |Gy |1y ` αB |By |0y

13 / 39
Quantum algorithms with small success probability

Back to quantum:
Quantum algorithms are inherently random.
A Hadamard gate can be used to flip a coin:
1
H |0y “ ? p|0y ` |1yq
2

A quantum algorithm might produce the state

U |0y “ αG |Gy |1y ` αB |By |0y

|Gy |1y is the “Good” part of the state, |By |0y is the “Bad” part.

13 / 39
Quantum algorithms with small success probability

Back to quantum:
Quantum algorithms are inherently random.
A Hadamard gate can be used to flip a coin:
1
H |0y “ ? p|0y ` |1yq
2

A quantum algorithm might produce the state

U |0y “ αG |Gy |1y ` αB |By |0y

|Gy |1y is the “Good” part of the state, |By |0y is the “Bad” part.
Is we just measure then the success probability is p “ |αG |2 .

13 / 39
Three states

Let us write |ψy :“ αG |Gy |1y ` αB |By |0y

14 / 39
Three states

Let us write |ψy :“ αG |Gy |1y ` αB |By |0y


What is the inner product between the good and the bad part?

14 / 39
Three states

Let us write |ψy :“ αG |Gy |1y ` αB |By |0y


What is the inner product between the good and the bad part?

xG|By x1|0y “ xG|By ¨ 0 “ 0

14 / 39
Three states

Let us write |ψy :“ αG |Gy |1y ` αB |By |0y


What is the inner product between the good and the bad part?

xG|By x1|0y “ xG|By ¨ 0 “ 0

So these two states are orthogonal!

14 / 39
Three states

Let us write |ψy :“ αG |Gy |1y ` αB |By |0y


What is the inner product between the good and the bad part?

xG|By x1|0y “ xG|By ¨ 0 “ 0

So these two states are orthogonal!


|ψy is written in the t|Gy|1y , |By|0yu basis.

14 / 39
Three states

Let us write |ψy :“ αG |Gy |1y ` αB |By |0y


What is the inner product between the good and the bad part?

xG|By x1|0y “ xG|By ¨ 0 “ 0

So these two states are orthogonal!


|ψy is written in the t|Gy|1y , |By|0yu basis.
Everything is in a 2-dimensional subspace.

14 / 39
Three states - a picture

|Gy|1y

|By|0y
Three states - a picture

|Gy|1y

|ψy
|By|0y

|ψy “ αG |Gy |1y ` αB |By |0y


Three states - a picture

|Gy|1y

|ψy
|By|0y

|ψy “ αG |Gy |1y ` αB |By |0y


Three states - a picture

|Gy|1y

|ψy
θ |By|0y

|ψy “ sin pθq |Gy |1y ` cos pθq |By |0y


Three states - a picture

|Gy|1y

|ψy
θ |By|0y
θ
|ψ 1 y

|ψy “ sin pθq |Gy |1y ` cos pθq |By |0y


ˇ 1D
ˇψ “ ´ sin pθq |Gy |1y ` cos pθq |By |0y
Three states - a picture

|Gy|1y

|ψ 2 y

|ψy
θ |By|0y
θ
|ψ 1 y

|ψy “ sin pθq |Gy |1y ` cos pθq |By |0y


ˇ 1D
ˇψ “ ´ sin pθq |Gy |1y ` cos pθq |By |0y
Three states - a picture

|Gy|1y

|ψ 2 y

2θ |ψy
θ |By|0y
θ
|ψ 1 y

|ψy “ sin pθq |Gy |1y ` cos pθq |By |0y


ˇ 1D
ˇψ “ ´ sin pθq |Gy |1y ` cos pθq |By |0y
ˇ 2D
ˇψ “ sin p3θq |Gy |1y ` cos p3θq |By |0y
Three states - a picture

|Gy|1y

|ψ 2 y

2θ |ψy
θ |By|0y
θ
|ψ 1 y

|ψy “ sin pθq |Gy |1y ` cos pθq |By |0y


ˇ 1D
ˇψ “ ´ sin pθq |Gy |1y ` cos pθq |By |0y
ˇ 2D
ˇψ “ sin p3θq |Gy |1y ` cos p3θq |By |0y

15 / 39
Amplitude amplification

Two reflections: through |By|0y and |ψy.

16 / 39
Amplitude amplification

Two reflections: through |By|0y and |ψy.


The product is a rotation A, with angle 2θ.

16 / 39
Amplitude amplification

Two reflections: through |By|0y and |ψy.


The product is a rotation A, with angle 2θ.
After k iterations of A we get

sin pp2k ` 1qθq |Gy |1y ` cos pp2k ` 1qθq |By |0y

16 / 39
Amplitude amplification

Two reflections: through |By|0y and |ψy.


The product is a rotation A, with angle 2θ.
After k iterations of A we get

sin pp2k ` 1qθq |Gy |1y ` cos pp2k ` 1qθq |By |0y

If p2k ` 1qθ « π{2 then |sin pp2k ` 1qθq|2 « 1.

16 / 39
Amplitude amplification

Two reflections: through |By|0y and |ψy.


The product is a rotation A, with angle 2θ.
After k iterations of A we get

sin pp2k ` 1qθq |Gy |1y ` cos pp2k ` 1qθq |By |0y

If p2k ` 1qθ « π{2 then |sin pp2k ` 1qθq|2 « 1.


Since θ “ arcsin αG we want
ˆ ˙
π
k« ´ 1 {2
2 arcsin αG

16 / 39
Amplitude amplification

Two reflections: through |By|0y and |ψy.


The product is a rotation A, with angle 2θ.
After k iterations of A we get

sin pp2k ` 1qθq |Gy |1y ` cos pp2k ` 1qθq |By |0y

If p2k ` 1qθ « π{2 then |sin pp2k ` 1qθq|2 « 1.


Since θ “ arcsin αG we want

1
ˆ ˙ ˆ ˙
π
k« ´ 1 {2 “ O
2 arcsin αG |αG |

16 / 39
Amplitude amplification

Two reflections: through |By|0y and |ψy.


The product is a rotation A, with angle 2θ.
After k iterations of A we get

sin pp2k ` 1qθq |Gy |1y ` cos pp2k ` 1qθq |By |0y

If p2k ` 1qθ « π{2 then |sin pp2k ` 1qθq|2 « 1.


Since θ “ arcsin αG we want

1 1
ˆ ˙ ˆ ˙ ˆ ˙
π
k« ´ 1 {2 “ O “O ?
2 arcsin αG |αG | p

16 / 39
Amplitude amplification

Two reflections: through |By|0y and |ψy.


The product is a rotation A, with angle 2θ.
After k iterations of A we get

sin pp2k ` 1qθq |Gy |1y ` cos pp2k ` 1qθq |By |0y

If p2k ` 1qθ « π{2 then |sin pp2k ` 1qθq|2 « 1.


Since θ “ arcsin αG we want

1 1
ˆ ˙ ˆ ˙ ˆ ˙
π
k« ´ 1 {2 “ O “O ?
2 arcsin αG |αG | p

Nice, but can we actually implement these reflections?

16 / 39
Implementing the reflections

The reflection through |By|0y:

17 / 39
Implementing the reflections

The reflection through |By|0y:


Do nothing to the bad state.
Add a ´1 to the good state.

17 / 39
Implementing the reflections

The reflection through |By|0y:


Do nothing to the bad state.
Add a ´1 to the good state.
Apply a Z gate to the last bit.

17 / 39
Implementing the reflections

The reflection through |By|0y:


Do nothing to the bad state.
Add a ´1 to the good state.
Apply a Z gate to the last bit.
The reflection through |ψy:

17 / 39
Implementing the reflections

The reflection through |By|0y:


Do nothing to the bad state.
Add a ´1 to the good state.
Apply a Z gate to the last bit.
The reflection through |ψy:
Do nothing to |ψy.
Add a ´1 to states orthogonal to it.

17 / 39
Implementing the reflections

The reflection through |By|0y:


Do nothing to the bad state.
Add a ´1 to the good state.
Apply a Z gate to the last bit.
The reflection through |ψy:
Do nothing to |ψy.
Add a ´1 to states orthogonal to it.
Use that |ψy “ U |0y:
1. Apply U´1 to map |ψy to |0y.
2. Reflect through |0y.
3. Apply U to map |0y to back to |ψy.

17 / 39
Example: the search problem

Before amplitude amplification there was Grover (’96).

18 / 39
Example: the search problem

Before amplitude amplification there was Grover (’96).

Search problem
Input: x P t0, 1un with k ones.
Goal: Find an i such that xi “ 1 with few queries.

18 / 39
Example: the search problem

Before amplitude amplification there was Grover (’96).

Search problem
Input: x P t0, 1un with k ones.
Goal: Find an i such that xi “ 1 with few queries.

How can we do this classically?

18 / 39
Example: the search problem

Before amplitude amplification there was Grover (’96).

Search problem
Input: x P t0, 1un with k ones.
Goal: Find an i such that xi “ 1 with few queries.

How can we do this classically?


Go over the bits: O pnq queries.

18 / 39
Example: the search problem

Before amplitude amplification there was Grover (’96).

Search problem
Input: x P t0, 1un with k ones.
Goal: Find an i such that xi “ 1 with few queries.

How can we do this classically?


Go over the bits: O pnq queries.
Randomly pick an i and repeat: O pn{kq queries.

18 / 39
Example: the search problem

And with a quantum algorithm?

19 / 39
Example: the search problem

And with a quantum algorithm?


Let U be:
Setup a uniform superposition over the i by applying H to all bits.
n
1 ÿ
? |iy |0y
n i“0

19 / 39
Example: the search problem

And with a quantum algorithm?


Let U be:
Setup a uniform superposition over the i by applying H to all bits.
n
1 ÿ
? |iy |0y
n i“0

Query in superposition
n
1 ÿ
? |iy |xi y
n i“0

19 / 39
Example: the search problem

And with a quantum algorithm?


Let U be:
Setup a uniform superposition over the i by applying H to all bits.
n
1 ÿ
? |iy |0y
n i“0

Query in superposition
n
˜ ¸
1 ÿ ÿ
? |iy |xi y “ |iy |1y
n i“0 i:xi “1

19 / 39
Example: the search problem

And with a quantum algorithm?


Let U be:
Setup a uniform superposition over the i by applying H to all bits.
n
1 ÿ
? |iy |0y
n i“0

Query in superposition
n
˜ ¸
1 ÿ 1 ÿ
? |iy |xi y “ ? |iy |1y
n i“0 k i:xi “1

19 / 39
Example: the search problem

And with a quantum algorithm?


Let U be:
Setup a uniform superposition over the i by applying H to all bits.
n
1 ÿ
? |iy |0y
n i“0

Query in superposition
n
c ˜ ¸
1 ÿ k 1 ÿ
? |iy |xi y “ ? |iy |1y
n i“0 n k i:x “1
i

19 / 39
Example: the search problem

And with a quantum algorithm?


Let U be:
Setup a uniform superposition over the i by applying H to all bits.
n
1 ÿ
? |iy |0y
n i“0

Query in superposition
n
c ˜ ¸
1 ÿ k 1 ÿ
? |iy |xi y “ ? |iy |1y ` p. . . q |0y
n i“0 n k i:x “1i

19 / 39
Example: the search problem

And with a quantum algorithm?


Let U be:
Setup a uniform superposition over the i by applying H to all bits.
n
1 ÿ
? |iy |0y
n i“0

Query in superposition
n
c ˜ ¸
1 ÿ k 1 ÿ
? |iy |xi y “ ? |iy |1y ` p. . . q |0y
n i“0 n k i:x “1i

`a n ˘
With O k iterations we are done!

19 / 39
Phase estimation
Eigenvalues of unitaries

Eigenvectors and eigenvalues


If
U |ψy “ λ |ψy
then |ψy is an eigenvector and λ is the corresponding eigenvalue.

20 / 39
Eigenvalues of unitaries

Eigenvectors and eigenvalues


If
U |ψy “ λ |ψy
then |ψy is an eigenvector and λ is the corresponding eigenvalue.

For example
Z |0y “ 1 ¨ |0y

20 / 39
Eigenvalues of unitaries

Eigenvectors and eigenvalues


If
U |ψy “ λ |ψy
then |ψy is an eigenvector and λ is the corresponding eigenvalue.

For example
Z |0y “ 1 ¨ |0y

Z |1y “ ´1 ¨ |1y

20 / 39
Eigenvalues of unitaries

Eigenvectors and eigenvalues


If
U |ψy “ λ |ψy
then |ψy is an eigenvector and λ is the corresponding eigenvalue.

For example
Z |0y “ 1 ¨ |0y

Z |1y “ ´1 ¨ |1y
In general for a unitary U and eigenvector |ψy of U:

U |ψy “ ei2πθ |ψy

Remember: eiθ is called a phase.

20 / 39
Goal of phase estimation

Goal
Given a U and |ψy, s.t.,

U |ψy “ ei2πθ |ψy

calculate θ (up to some precision) by applying U in some way.

21 / 39
Goal of phase estimation

Goal
Given a U and |ψy, s.t.,

U |ψy “ ei2πθ |ψy

calculate θ (up to some precision) by applying U in some way.

Example: if we know that U “ I or U “ Z and do phase estimation on


|ψy “ |1y:

21 / 39
Goal of phase estimation

Goal
Given a U and |ψy, s.t.,

U |ψy “ ei2πθ |ψy

calculate θ (up to some precision) by applying U in some way.

Example: if we know that U “ I or U “ Z and do phase estimation on


|ψy “ |1y:
If U “ I then U |1y “ 1 ¨ |1y “ ei2π0 |1y so θ “ 0.

21 / 39
Goal of phase estimation

Goal
Given a U and |ψy, s.t.,

U |ψy “ ei2πθ |ψy

calculate θ (up to some precision) by applying U in some way.

Example: if we know that U “ I or U “ Z and do phase estimation on


|ψy “ |1y:
If U “ I then U |1y “ 1 ¨ |1y “ ei2π0 |1y so θ “ 0.
1
If U “ Z then U |1y “ ´1 ¨ |1y “ ei2π 2 |1y so θ “ 21 .

21 / 39
A `1 or ´1 eigenvalue

What can we do if U either applies a `1 or ´1 phase and we want a


binary description of this phase?

22 / 39
A `1 or ´1 eigenvalue

What can we do if U either applies a `1 or ´1 phase and we want a


binary description of this phase? We use our oracle conversion trick!

|0y H ‚ H

|ψy U

22 / 39
A `1 or ´1 eigenvalue

What can we do if U either applies a `1 or ´1 phase and we want a


binary description of this phase? We use our oracle conversion trick!

|0y H ‚ H

|ψy U
1
Let’s check this for a ´1 “ ei2π 2 phase:

22 / 39
A `1 or ´1 eigenvalue

What can we do if U either applies a `1 or ´1 phase and we want a


binary description of this phase? We use our oracle conversion trick!

|0y H ‚ H

|ψy U
1
Let’s check this for a ´1 “ ei2π 2 phase:
We start in |0y|ψy.

22 / 39
A `1 or ´1 eigenvalue

What can we do if U either applies a `1 or ´1 phase and we want a


binary description of this phase? We use our oracle conversion trick!

|0y H ‚ H

|ψy U
1
Let’s check this for a ´1 “ ei2π 2 phase:
We start in |0y|ψy.
We apply H to get ?1 p|0y|ψy ` |1y|ψyq.
2

22 / 39
A `1 or ´1 eigenvalue

What can we do if U either applies a `1 or ´1 phase and we want a


binary description of this phase? We use our oracle conversion trick!

|0y H ‚ H

|ψy U
1
Let’s check this for a ´1 “ ei2π 2 phase:
We start in |0y|ψy.
We apply H to get ?1 p|0y|ψy ` |1y|ψyq.
2
We apply U only to the |1y part:
?1 p|0y|ψy ` |1y U |ψyq “ ?1 p|0y|ψy ´ |1y |ψyq.
2 2

22 / 39
A `1 or ´1 eigenvalue

What can we do if U either applies a `1 or ´1 phase and we want a


binary description of this phase? We use our oracle conversion trick!

|0y H ‚ H

|ψy U
1
Let’s check this for a ´1 “ ei2π 2 phase:
We start in |0y|ψy.
We apply H to get ?1 p|0y|ψy ` |1y|ψyq.
2
We apply U only to the |1y part:
?1 p|0y|ψy ` |1y U |ψyq “ ?1 p|0y|ψy ´ |1y |ψyq.
2 2
We apply H again and get |1y|ψy.

22 / 39
A bit about binary
What if we want to estimate other phases as well?

23 / 39
A bit about binary
What if we want to estimate other phases as well?
In general a phase is ei2πθ .

23 / 39
A bit about binary
What if we want to estimate other phases as well?
In general a phase is ei2πθ .
We can write θ in binary:

θ “ 10.110101

23 / 39
A bit about binary
What if we want to estimate other phases as well?
In general a phase is ei2πθ .
We can write θ in binary:

θ “ 10.110101

The part before the decimal does not matter since

ei2π1 “ ei2π2 “ ei2π3 “ . . .

23 / 39
A bit about binary
What if we want to estimate other phases as well?
In general a phase is ei2πθ .
We can write θ in binary:

θ “ 10.110101

The part before the decimal does not matter since

ei2π1 “ ei2π2 “ ei2π3 “ . . .

So we only need to write down the part behind the decimal.

23 / 39
A bit about binary
What if we want to estimate other phases as well?
In general a phase is ei2πθ .
We can write θ in binary:

θ “ 10.110101

The part before the decimal does not matter since

ei2π1 “ ei2π2 “ ei2π3 “ . . .

So we only need to write down the part behind the decimal.


1
A phase of 1 “ ei2π0.0 and a phase of ´1 “ ei2π 2 “ ei2π0.1
(in binary!)

23 / 39
A bit about binary
What if we want to estimate other phases as well?
In general a phase is ei2πθ .
We can write θ in binary:

θ “ 10.110101

The part before the decimal does not matter since

ei2π1 “ ei2π2 “ ei2π3 “ . . .

So we only need to write down the part behind the decimal.


1
A phase of 1 “ ei2π0.0 and a phase of ´1 “ ei2π 2 “ ei2π0.1
(in binary!)
If this is only one bit (θ “ 0.0 or θ “ 0.1 “ 21 ) then we know
what to do.
23 / 39
Last bit phase estimation

Let U |ψy “ ei2πθ |ψy for θ “ 0.b3 b2 b1 , then we can calculate b1 !

24 / 39
Last bit phase estimation

Let U |ψy “ ei2πθ |ψy for θ “ 0.b3 b2 b1 , then we can calculate b1 !


˘4
We look at U 4 , so U 4 |ψy “ ei2πθ |ψy “ ei2π4θ |ψy.
`

24 / 39
Last bit phase estimation

Let U |ψy “ ei2πθ |ψy for θ “ 0.b3 b2 b1 , then we can calculate b1 !


˘4
We look at U 4 , so U 4 |ψy “ ei2πθ |ψy “ ei2π4θ |ψy.
`

Now the phase corresponds with 4θ “ b3 b2 .b1

24 / 39
Last bit phase estimation

Let U |ψy “ ei2πθ |ψy for θ “ 0.b3 b2 b1 , then we can calculate b1 !


˘4
We look at U 4 , so U 4 |ψy “ ei2πθ |ψy “ ei2π4θ |ψy.
`

Now the phase corresponds with 4θ “ b3 b2 .b1


Simply use our previous circuit to get the last bit:

|0y H ‚ H |b1 y

|ψy U4 |ψy

24 / 39
Two bit phase estimation

Let U |ψy “ ei2πθ |ψy for θ “ 0.b3 b2 b1 , can we calculate b2 as well?

25 / 39
Two bit phase estimation

Let U |ψy “ ei2πθ |ψy for θ “ 0.b3 b2 b1 , can we calculate b2 as well?


We could look at U 2 ? The phase corresponds with 2θ “ b3 .b2 b1 .

25 / 39
Two bit phase estimation

Let U |ψy “ ei2πθ |ψy for θ “ 0.b3 b2 b1 , can we calculate b2 as well?


We could look at U 2 ? The phase corresponds with 2θ “ b3 .b2 b1 .
If b1 “ 0 then we can just use our algorithm. But what if b1 “ 1?

25 / 39
Two bit phase estimation

Let U |ψy “ ei2πθ |ψy for θ “ 0.b3 b2 b1 , can we calculate b2 as well?


We could look at U 2 ? The phase corresponds with 2θ “ b3 .b2 b1 .
If b1 “ 0 then we can just use our algorithm. But what if b1 “ 1?
Solution: calculate b1 and then make a change to U if necessary:

|0y H ‚ ‚ H |b2 y
|0y H ‚ H |b1 y
|ψy U4 |ψy U2 e´i2π0.0b1 I |ψy

25 / 39
Two bit phase estimation

Let U |ψy “ ei2πθ |ψy for θ “ 0.b3 b2 b1 , can we calculate b2 as well?


We could look at U 2 ? The phase corresponds with 2θ “ b3 .b2 b1 .
If b1 “ 0 then we can just use our algorithm. But what if b1 “ 1?
Solution: calculate b1 and then make a change to U if necessary:

|0y H ‚ ‚ H |b2 y
|0y H ‚ H |b1 y
|ψy U4 |ψy U2 e´i2π0.0b1 I |ψy

This works because U2 e´i2π0.b1 adds a phase with


0.b2 b1 ´ 0.0b1 “ 0.b2 .

25 / 39
Three bit phase estimation

Let U |ψy “ ei2πθ |ψy for θ “ 0.b3 b2 b1 , can we calculate all the bits?

26 / 39
Three bit phase estimation

Let U |ψy “ ei2πθ |ψy for θ “ 0.b3 b2 b1 , can we calculate all the bits?
Yes! just keep going:

|0y H ‚ ‚ H |b2 y ¨ ¨ ¨
|0y H ‚ H |b1 y ¨¨¨
|ψy U4 |ψy U2 e´i2π0.0b1 I |ψy ¨ ¨ ¨

¨¨¨ |0y H ‚ ‚ ‚ H |b3 y


¨¨¨ |b2 y
¨¨¨ |b1 y
¨¨¨ |ψy U e´i2π0.0b2 I e´i2π0.00b1 I |ψy

26 / 39
Clean up

Can we clean up this circuit?

27 / 39
Clean up

Can we clean up this circuit? Consider

¨¨¨ |xy ‚ ¨¨¨


¨¨¨ |b1 y ¨¨¨
¨¨¨ |ψy e´i2π0.0b1 I ¨¨¨

27 / 39
Clean up

Can we clean up this circuit? Consider

¨¨¨ |xy ‚ ¨¨¨


¨¨¨ |b1 y ¨¨¨
¨¨¨ |ψy e´i2π0.0b1 I ¨¨¨

This applies a phase of e´i2π0.0b1 to the state if x “ 1.

27 / 39
Clean up

Can we clean up this circuit? Consider

¨¨¨ |xy ‚ ¨¨¨


¨¨¨ |b1 y ¨¨¨
¨¨¨ |ψy e´i2π0.0b1 I ¨¨¨

This applies a phase of e´i2π0.0b1 to the state if x “ 1.


ô Applies a phase of e´iπ{2 to the state is x “ 1 and b1 “ 1.

27 / 39
Clean up

Can we clean up this circuit? Consider

¨¨¨ |xy ‚ ¨¨¨


¨¨¨ |b1 y ¨¨¨
¨¨¨ |ψy e´i2π0.0b1 I ¨¨¨

This applies a phase of e´i2π0.0b1 to the state if x “ 1.


ô Applies a phase of e´iπ{2 to the state is x “ 1 and b1 “ 1.
ô Applies a phase gate ´π{2 to |xy if b1 “ 1.

27 / 39
Clean up

Can we clean up this circuit? Consider

¨¨¨ |xy ‚ ¨¨¨


¨¨¨ |b1 y ¨¨¨
¨¨¨ |ψy e´i2π0.0b1 I ¨¨¨

This applies a phase of e´i2π0.0b1 to the state if x “ 1.


ô Applies a phase of e´iπ{2 to the state is x “ 1 and b1 “ 1.
ô Applies a phase gate ´π{2 to |xy if b1 “ 1.

¨¨¨ |xy ´π{2 ¨¨¨


¨¨¨ |b1 y ‚ ¨¨¨
¨¨¨ |ψy ¨¨¨

27 / 39
The inverse quantum Fourier transform

Can we clean up this circuit?

|0y H ‚ ‚ H |b2 y ¨ ¨ ¨
|0y H ‚ H |b1 y ¨¨¨
|ψy U4 |ψy U2 e´i2π0.0b1 I |ψy ¨ ¨ ¨

¨¨¨ |0y H ‚ ‚ ‚ H |b3 y


¨¨¨ |b2 y
¨¨¨ |b1 y
¨¨¨ |ψy U e´i2π0.0b2 I e´i2π0.00b1 I |ψy

28 / 39
The inverse quantum Fourier transform

Can we clean up this circuit?

|0y H ‚ ´π{2 H |b2 y ¨ ¨ ¨


|0y H ‚ H |b1 y ‚ ¨¨¨
|ψy U4 |ψy U2 |ψy ¨ ¨ ¨

¨¨¨ |0y H ‚ ´π{2 ´π{4 H |b3 y


¨¨¨ ‚ |b2 y
¨¨¨ ‚ |b1 y
¨¨¨ |ψy U |ψy

28 / 39
The inverse quantum Fourier transform

Can we clean up this circuit?

|0y H ‚ ´π{2 ´π{4 H

|0y H ‚ ´π{2 H ‚
|0y H ‚ H ‚ ‚
|ψy U4 U2 U1

28 / 39
The inverse quantum Fourier transform

Can we clean up this circuit?


_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
|0y H ‚  ´π{2 ´π{4 H 
 
 
|0y H ‚  ´π{2 H ‚ 
 
|0y H ‚  H ‚ ‚ 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|ψy U4 U2 U1
This circuit is called the inverse quantum Fourier transform (QFT´1 ).

28 / 39
The inverse quantum Fourier transform

Can we clean up this circuit?


_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
|0y H ‚  ´π{2 ´π{4 H 
 
 
|0y H ‚  ´π{2 H ‚ 
 
|0y H ‚  H ‚ ‚ 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|ψy U4 U2 U1
This circuit is called the inverse quantum Fourier transform (QFT´1 ).

(The inverse quantum Fourier transform actually also swaps the order
of the qubits, but this does not matter for our purpose)

28 / 39
The inverse quantum Fourier transform

Can we clean up this circuit?


_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
|0y H ‚  ´π{2 ´π{4 H 
 
 
|0y H ‚  ´π{2 H ‚ 
 
|0y H ‚  H ‚ ‚ 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|ψy U4 U2 U1
This circuit is called the inverse quantum Fourier transform (QFT´1 ).

(The inverse quantum Fourier transform actually also swaps the order
of the qubits, but this does not matter for our purpose)
1
In total we need to apply Uk for k „ ε

28 / 39
Example: finding an eigenvector

What happens if |ψy is not an eigenvector?

29 / 39
Example: finding an eigenvector

What happens if |ψy is not an eigenvector?


Let
|ψy “ α0 |φ0 y ` α1 |φ1 y
where U |φ0 y “ ei2πθ0 |φy and U |φ1 y “ ei2πθ1 |φy.

29 / 39
Example: finding an eigenvector

What happens if |ψy is not an eigenvector?


Let
|ψy “ α0 |φ0 y ` α1 |φ1 y
where U |φ0 y “ ei2πθ0 |φy and U |φ1 y “ ei2πθ1 |φy.
If we apply phase estimation we get (by linearity):

PEU |0y|ψy “ α0 |θ0 y|φ0 y ` α1 |θ1 y|φ1 y

29 / 39
Example: finding an eigenvector

What happens if |ψy is not an eigenvector?


Let
|ψy “ α0 |φ0 y ` α1 |φ1 y
where U |φ0 y “ ei2πθ0 |φy and U |φ1 y “ ei2πθ1 |φy.
If we apply phase estimation we get (by linearity):

PEU |0y|ψy “ α0 |θ0 y|φ0 y ` α1 |θ1 y|φ1 y

Measuring the first register gives us a random θi , what happens


to the second register?

29 / 39
Amplitude estimation
A problem with amplitude amplification

In amplitude amplification we had the state

|ψy “ αG |Gy|1y ` αB |By|0y

30 / 39
A problem with amplitude amplification

In amplitude amplification we had the state

|ψy “ αG |Gy|1y ` αB |By|0y “ sin pθq |Gy|1y ` cos pθq |By|0y .

30 / 39
A problem with amplitude amplification

In amplitude amplification we had the state

|ψy “ αG |Gy|1y ` αB |By|0y “ sin pθq |Gy|1y ` cos pθq |By|0y .

Each iteration applies a rotation by 2θ, increasing the angle.

30 / 39
A problem with amplitude amplification

In amplitude amplification we had the state

|ψy “ αG |Gy|1y ` αB |By|0y “ sin pθq |Gy|1y ` cos pθq |By|0y .

Each iteration applies a rotation by 2θ, increasing the angle.


But how many iterations are needed? We might not know θ.

30 / 39
A problem with amplitude amplification

In amplitude amplification we had the state

|ψy “ αG |Gy|1y ` αB |By|0y “ sin pθq |Gy|1y ` cos pθq |By|0y .

Each iteration applies a rotation by 2θ, increasing the angle.


But how many iterations are needed? We might not know θ.
For example for search: how many solutions are there?

30 / 39
A problem with amplitude amplification

In amplitude amplification we had the state

|ψy “ αG |Gy|1y ` αB |By|0y “ sin pθq |Gy|1y ` cos pθq |By|0y .

Each iteration applies a rotation by 2θ, increasing the angle.


But how many iterations are needed? We might not know θ.
For example for search: how many solutions are there?
Too many iterations decreases the success probability again!

30 / 39
A closer look at the amplitude amplification iterate

In the basis t|Gy|1y , |By|0yu the iterate is a rotation:


„ 
cos p2θq ´ sin p2θq
sin p2θq cos p2θq

31 / 39
A closer look at the amplitude amplification iterate

In the basis t|Gy|1y , |By|0yu the iterate is a rotation:


„ 
cos p2θq ´ sin p2θq
sin p2θq cos p2θq

What are the eigenvalues of a rotation?

31 / 39
A closer look at the amplitude amplification iterate

In the basis t|Gy|1y , |By|0yu the iterate is a rotation:


„ 
cos p2θq ´ sin p2θq
sin p2θq cos p2θq

What are the eigenvalues of a rotation?

ei2θ , e´i2θ

31 / 39
A closer look at the amplitude amplification iterate

In the basis t|Gy|1y , |By|0yu the iterate is a rotation:


„ 
cos p2θq ´ sin p2θq
sin p2θq cos p2θq

What are the eigenvalues of a rotation?

ei2θ , e´i2θ

The eigenvectors also lie in the 2-dimensional subspace.

31 / 39
Amplitude estimation

Amplitude estimation
Input: A unitary that prepares

|ψy “ αG |Gy|1y ` αB |By|0y .

Goal: Estimate the probability of |Gy|1y up to error ε.

32 / 39
Amplitude estimation

Amplitude estimation
Input: A unitary that prepares

|ψy “ αG |Gy|1y ` αB |By|0y .

Goal: Estimate the probability of |Gy|1y up to error ε.

We use phase estimation on the amplitude amplification iterate!

32 / 39
Amplitude estimation

Amplitude estimation
Input: A unitary that prepares

|ψy “ αG |Gy|1y ` αB |By|0y .

Goal: Estimate the probability of |Gy|1y up to error ε.

We use phase estimation on the amplitude amplification iterate!


The eigenvectors form a (orthonormal) basis for the two
dimensional space.

32 / 39
Amplitude estimation

Amplitude estimation
Input: A unitary that prepares

|ψy “ αG |Gy|1y ` αB |By|0y .

Goal: Estimate the probability of |Gy|1y up to error ε.

We use phase estimation on the amplitude amplification iterate!


The eigenvectors form a (orthonormal) basis for the two
dimensional space.
|ψy is some linear combination of the eigenvectors.

32 / 39
Amplitude estimation

Amplitude estimation
Input: A unitary that prepares

|ψy “ αG |Gy|1y ` αB |By|0y .

Goal: Estimate the probability of |Gy|1y up to error ε.

We use phase estimation on the amplitude amplification iterate!


The eigenvectors form a (orthonormal) basis for the two
dimensional space.
|ψy is some linear combination of the eigenvectors.
Using phase estimation we find either 2θ or ´2θ.

32 / 39
Amplitude estimation

Amplitude estimation
Input: A unitary that prepares

|ψy “ αG |Gy|1y ` αB |By|0y .

Goal: Estimate the probability of |Gy|1y up to error ε.

We use phase estimation on the amplitude amplification iterate!


The eigenvectors form a (orthonormal) basis for the two
dimensional space.
|ψy is some linear combination of the eigenvectors.
Using phase estimation we find either 2θ or ´2θ.
Both tell us θ and hence the probability up to error ε in
1
ˆ ˙
O uses of U
ε

32 / 39
Example: Speeding up Monte Carlo methods

In classical computing a Monte Carlo method samples a lot of times


to estimate a probability.

33 / 39
Example: Speeding up Monte Carlo methods

In classical computing a Monte Carlo method samples a lot of times


to estimate a probability.

33 / 39
Example: Speeding up Monte Carlo methods

In classical computing a Monte Carlo method samples a lot of times


to estimate a probability.

33 / 39
Example: Speeding up Monte Carlo methods

In classical computing a Monte Carlo method samples a lot of times


to estimate a probability.

33 / 39
Example: Speeding up Monte Carlo methods

In classical computing a Monte Carlo method samples a lot of times


to estimate a probability.

33 / 39
Example: Speeding up Monte Carlo methods

In classical computing a Monte Carlo method samples a lot of times


to estimate a probability.

33 / 39
Example: Speeding up Monte Carlo methods

In classical computing a Monte Carlo method samples a lot of times


to estimate a probability.

33 / 39
Example: Speeding up Monte Carlo methods

In classical computing a Monte Carlo method samples a lot of times


to estimate a probability.

33 / 39
Example: Speeding up Monte Carlo methods

In classical computing a Monte Carlo method samples a lot of times


to estimate a probability.

33 / 39
Example: Speeding up Monte Carlo methods

In classical computing a Monte Carlo method samples a lot of times


to estimate a probability.

1
A classical algorithm requires „ ε2
samples to estimate, quantum 1ε .

33 / 39
Overview of some other algo-
rithms
Some other algorithms

There are many more quantum algorithms, often using the discoed
techniques. We will quickly discuss some other important algorithms:
Shor’s algorithm & factoring integers
HHL for “solving” linear systems
Faster gradient computation

34 / 39
Factoring

Problem: given a (large) number N, what are the prime factors?

35 / 39
Factoring

Problem: given a (large) number N, what are the prime factors?

15 “

35 / 39
Factoring

Problem: given a (large) number N, what are the prime factors?

15 “ 3 ˆ 5

35 / 39
Factoring

Problem: given a (large) number N, what are the prime factors?

15 “ 3 ˆ 5

391 “

35 / 39
Factoring

Problem: given a (large) number N, what are the prime factors?

15 “ 3 ˆ 5

391 “ 17 ˆ 23

35 / 39
Factoring

Problem: given a (large) number N, what are the prime factors?

15 “ 3 ˆ 5

391 “ 17 ˆ 23

Best known classical algorithms run in exponential time in the


number of bits.

35 / 39
Factoring

Problem: given a (large) number N, what are the prime factors?

15 “ 3 ˆ 5

391 “ 17 ˆ 23

Best known classical algorithms run in exponential time in the


number of bits.
Most modern cryptography assumes this is hard to solve.

35 / 39
Factoring

Problem: given a (large) number N, what are the prime factors?

15 “ 3 ˆ 5

391 “ 17 ˆ 23

Best known classical algorithms run in exponential time in the


number of bits.
Most modern cryptography assumes this is hard to solve.
Quantum computers can break this in polynomial time.

35 / 39
Shor’s factoring algorithm (’94)

A rough sketch:

36 / 39
Shor’s factoring algorithm (’94)

A rough sketch:
A function f is periodic if fpaq “ fpbq ô b “ a ` t ¨ k for the
period k and some t.

36 / 39
Shor’s factoring algorithm (’94)

A rough sketch:
A function f is periodic if fpaq “ fpbq ô b “ a ` t ¨ k for the
period k and some t.
Classical literature: Factoring is equivalent to period finding for

fpxq “ ax mod N

36 / 39
Shor’s factoring algorithm (’94)

A rough sketch:
A function f is periodic if fpaq “ fpbq ô b “ a ` t ¨ k for the
period k and some t.
Classical literature: Factoring is equivalent to period finding for

fpxq “ ax mod N

Finding this period is believed to be hard classically.

36 / 39
Shor’s factoring algorithm (’94)

A rough sketch:
A function f is periodic if fpaq “ fpbq ô b “ a ` t ¨ k for the
period k and some t.
Classical literature: Factoring is equivalent to period finding for

fpxq “ ax mod N

Finding this period is believed to be hard classically.


Let U be a unitary such that U |fpaqy “ |fpa ` 1qy.

36 / 39
Shor’s factoring algorithm (’94)

A rough sketch:
A function f is periodic if fpaq “ fpbq ô b “ a ` t ¨ k for the
period k and some t.
Classical literature: Factoring is equivalent to period finding for

fpxq “ ax mod N

Finding this period is believed to be hard classically.


Let U be a unitary such that U |fpaqy “ |fpa ` 1qy.
Now Uk |fpaqy “ |fpa ` kqy “ |fpaqy so |fpaqy has eigenvalue 1
under Uk .

36 / 39
Shor’s factoring algorithm (’94)

A rough sketch:
A function f is periodic if fpaq “ fpbq ô b “ a ` t ¨ k for the
period k and some t.
Classical literature: Factoring is equivalent to period finding for

fpxq “ ax mod N

Finding this period is believed to be hard classically.


Let U be a unitary such that U |fpaqy “ |fpa ` 1qy.
Now Uk |fpaqy “ |fpa ` kqy “ |fpaqy so |fpaqy has eigenvalue 1
under Uk .
t
So |fpaqy is a combination of eigenvectors with eigenvalues ei2π k .

36 / 39
Shor’s factoring algorithm (’94)

A rough sketch:
A function f is periodic if fpaq “ fpbq ô b “ a ` t ¨ k for the
period k and some t.
Classical literature: Factoring is equivalent to period finding for

fpxq “ ax mod N

Finding this period is believed to be hard classically.


Let U be a unitary such that U |fpaqy “ |fpa ` 1qy.
Now Uk |fpaqy “ |fpa ` kqy “ |fpaqy so |fpaqy has eigenvalue 1
under Uk .
t
So |fpaqy is a combination of eigenvectors with eigenvalues ei2π k .
Phase estimation on U gives a value kt , with a few we can learn k.

36 / 39
Shor’s factoring algorithm (’94)

A rough sketch:
A function f is periodic if fpaq “ fpbq ô b “ a ` t ¨ k for the
period k and some t.
Classical literature: Factoring is equivalent to period finding for

fpxq “ ax mod N

Finding this period is believed to be hard classically.


Let U be a unitary such that U |fpaqy “ |fpa ` 1qy.
Now Uk |fpaqy “ |fpa ` kqy “ |fpaqy so |fpaqy has eigenvalue 1
under Uk .
t
So |fpaqy is a combination of eigenvectors with eigenvalues ei2π k .
Phase estimation on U gives a value kt , with a few we can learn k.
Small detail: we can implement Uk faster then k repetition, why?

36 / 39
HHL algorithm for systems of linear equations

An important problem in computer science is linear system solving.


Linear system solving
Given s-sparse matrix A P RNˆN and a vector b P RN , find a x such
that
Ax “ b

37 / 39
HHL algorithm for systems of linear equations

An important problem in computer science is linear system solving.


Linear system solving
Given s-sparse matrix A P RNˆN and a vector b P RN , find a x such
that
Ax “ b

r N2.37 or O σmax pAq


Takes O
` ˘
r pNsκq time to solve. (κ “
σmin pAq )

37 / 39
HHL algorithm for systems of linear equations

An important problem in computer science is linear system solving.


Linear system solving
Given s-sparse matrix A P RNˆN and a vector b P RN , find a x such
that
Ax “ b

r N2.37 or O σmax pAq


Takes O
` ˘
r pNsκq time to solve. (κ “
σmin pAq )

Quantum linear system solving (HHL ’09)


Given s-sparse matrix A P RNˆN and way to prepare |by P RN , prepare
a state |xy such that
A |xy 9 |by

37 / 39
HHL algorithm for systems of linear equations

An important problem in computer science is linear system solving.


Linear system solving
Given s-sparse matrix A P RNˆN and a vector b P RN , find a x such
that
Ax “ b

r N2.37 or O σmax pAq


Takes O
` ˘
r pNsκq time to solve. (κ “
σmin pAq )

Quantum linear system solving (HHL ’09)


Given s-sparse matrix A P RNˆN and way to prepare |by P RN , prepare
a state |xy such that
A |xy 9 |by

Takes only O
r psκq time

37 / 39
HHL algorithm for systems of linear equations

An important problem in computer science is linear system solving.


Linear system solving
Given s-sparse matrix A P RNˆN and a vector b P RN , find a x such
that
Ax “ b

r N2.37 or O σmax pAq


Takes O
` ˘
r pNsκq time to solve. (κ “
σmin pAq )

Quantum linear system solving (HHL ’09)


Given s-sparse matrix A P RNˆN and way to prepare |by P RN , prepare
a state |xy such that
A |xy 9 |by

Takes only O
r psκq time, but is not the same problem!

37 / 39
Gradient computation (Jordan ’05)

Gradient computation
Given black-box access to a function f : Rn Ñ R, estimate the
gradient at 0.

38 / 39
Gradient computation (Jordan ’05)

Gradient computation
Given black-box access to a function f : Rn Ñ R, estimate the
gradient at 0.

Classical algorithm: “walk” a bit in each direction and look at the


difference: O pnq queries.

38 / 39
Gradient computation (Jordan ’05)

Gradient computation
Given black-box access to a function f : Rn Ñ R, estimate the
gradient at 0.

Classical algorithm: “walk” a bit in each direction and look at the


difference: O pnq queries.
Quantum can do better!

38 / 39
Gradient computation (Jordan ’05)

Gradient computation
Given black-box access to a function f : Rn Ñ R, estimate the
gradient at 0.

Classical algorithm: “walk” a bit in each direction and look at the


difference: O pnq queries.
Quantum can do better!
Assume f is (close to) linear: fpxq « ni“1 ai xi , want the ai ’s.
ř

38 / 39
Gradient computation (Jordan ’05)

Gradient computation
Given black-box access to a function f : Rn Ñ R, estimate the
gradient at 0.

Classical algorithm: “walk” a bit in each direction and look at the


difference: O pnq queries.
Quantum can do better!
Assume f is (close to) linear: fpxq « ni“1 ai xi , want the ai ’s.
ř

Idea: query fpxq in the phase

|x1 y|. . .y|xn y ÞÑ ei2πfpxq |x1 y|. . .y|xn y

38 / 39
Gradient computation (Jordan ’05)

Gradient computation
Given black-box access to a function f : Rn Ñ R, estimate the
gradient at 0.

Classical algorithm: “walk” a bit in each direction and look at the


difference: O pnq queries.
Quantum can do better!
Assume f is (close to) linear: fpxq « ni“1 ai xi , want the ai ’s.
ř

Idea: query fpxq in the phase


řn
|x1 y|. . .y|xn y ÞÑ ei2πfpxq |x1 y|. . .y|xn y “ e i“1 ai xi |x1 y|. . .y|xn y

38 / 39
Gradient computation (Jordan ’05)

Gradient computation
Given black-box access to a function f : Rn Ñ R, estimate the
gradient at 0.

Classical algorithm: “walk” a bit in each direction and look at the


difference: O pnq queries.
Quantum can do better!
Assume f is (close to) linear: fpxq « ni“1 ai xi , want the ai ’s.
ř

Idea: query fpxq in the phase


řn
|x1 y|. . .y|xn y ÞÑ ei2πfpxq |x1 y|. . .y|xn y “ e i“1 ai xi |x1 y|. . .y|xn y

“ ea1 x1 |x1 y . . . ean xn |xn y

38 / 39
Gradient computation (Jordan ’05)

Gradient computation
Given black-box access to a function f : Rn Ñ R, estimate the
gradient at 0.

Classical algorithm: “walk” a bit in each direction and look at the


difference: O pnq queries.
Quantum can do better!
Assume f is (close to) linear: fpxq « ni“1 ai xi , want the ai ’s.
ř

Idea: query fpxq in the phase


řn
|x1 y|. . .y|xn y ÞÑ ei2πfpxq |x1 y|. . .y|xn y “ e i“1 ai xi |x1 y|. . .y|xn y

“ ea1 x1 |x1 y . . . ean xn |xn y

Use phase estimation on all n coordinates at the same time!


38 / 39
A quiz

By show of hand, true or false?

39 / 39
A quiz

By show of hand, true or false?


1. Quantum computers are exponentially faster at search problems
than classical computers because they can try everything in
superposition.

39 / 39
A quiz

By show of hand, true or false?


1. Quantum computers are exponentially faster at search problems
than classical computers because they can try everything in
superposition.
2. Quantum computers are exponentially faster at some problems.

39 / 39
A quiz

By show of hand, true or false?


1. Quantum computers are exponentially faster at search problems
than classical computers because they can try everything in
superposition.
2. Quantum computers are exponentially faster at some problems.
3. Quantum computers are quadratically faster at many problems
that include sampling.

39 / 39
A quiz

By show of hand, true or false?


1. Quantum computers are exponentially faster at search problems
than classical computers because they can try everything in
superposition.
2. Quantum computers are exponentially faster at some problems.
3. Quantum computers are quadratically faster at many problems
that include sampling.
4. Quantum computers can break most modern cryptography.

39 / 39
A quiz

By show of hand, true or false?


1. Quantum computers are exponentially faster at search problems
than classical computers because they can try everything in
superposition.
2. Quantum computers are exponentially faster at some problems.
3. Quantum computers are quadratically faster at many problems
that include sampling.
4. Quantum computers can break most modern cryptography.
5. Quantum computers can solve linear systems of equations faster.

39 / 39
A quiz

By show of hand, true or false?


1. Quantum computers are exponentially faster at search problems
than classical computers because they can try everything in
superposition.
2. Quantum computers are exponentially faster at some problems.
3. Quantum computers are quadratically faster at many problems
that include sampling.
4. Quantum computers can break most modern cryptography.
5. Quantum computers can solve linear systems of equations faster.
6. Quantum computers are wierd but cool.

39 / 39
That was it!

You might also like