Grover’s Algorithm
Quantum Search Algorithm in O(
√
N) complexity
C. Haaland
December 30, 2017
Outline
Classical Search
Quantum Mechanics Overview
Notation
Mathematics
QM Background
Grover’s Algorithm
Explanation
References
Classical Search
Motivation
“Imagine a phone directory containing N names arranged in
completely random order. In order to find someone’s phone
number with a probability of 0.5, any classical algorithm
(whether deterministic or probabilistic) will need to look at a
minimum of N/2 names.”
Classical Search
Motivation
“Imagine a phone directory containing N names arranged in
completely random order. In order to find someone’s phone
number with a probability of 0.5, any classical algorithm
(whether deterministic or probabilistic) will need to look at a
minimum of N/2 names.”
Consider the function F : {0, 1}3 → {0, 1},
F(x, y, z) =(x ∨ y ∨ z)∧
(¬x ∨ ¬y ∨ z)∧
(x ∨ ¬y ∨ ¬z)∧
(¬x ∨ y ∨ ¬z)
Question: For what values of the input does F(x, y, z) = 1?
Classical Search
Complexity
Problems are O(N) on a classical computer
Lov Grover published a quantum algorithm in 1996 with
complexity O(
√
N).
For large N, this represents a significant improvement over the
classical case
Quantum algorithm cannot guarantee the correct answer, only
returns the solution with high probability
Outline
Classical Search
Quantum Mechanics Overview
Notation
Mathematics
QM Background
Grover’s Algorithm
Explanation
References
Outline
Classical Search
Quantum Mechanics Overview
Notation
Mathematics
QM Background
Grover’s Algorithm
Explanation
References
Notation
R is set of real numbers
Notation
R is set of real numbers
C is set of complex numbers (e.g. x + iy)
Notation
R is set of real numbers
C is set of complex numbers (e.g. x + iy)
Rn (Cn) indicates column vector of n real (complex) numbers
respectively
Notation
R is set of real numbers
C is set of complex numbers (e.g. x + iy)
Rn (Cn) indicates column vector of n real (complex) numbers
respectively
z∗ is the complex conjugate
If z = x + iy then z∗
= x − iy
Notation
R is set of real numbers
C is set of complex numbers (e.g. x + iy)
Rn (Cn) indicates column vector of n real (complex) numbers
respectively
z∗ is the complex conjugate
If z = x + iy then z∗
= x − iy
|ψ is Dirac notation for a column vector (ket vector)
Notation
R is set of real numbers
C is set of complex numbers (e.g. x + iy)
Rn (Cn) indicates column vector of n real (complex) numbers
respectively
z∗ is the complex conjugate
If z = x + iy then z∗
= x − iy
|ψ is Dirac notation for a column vector (ket vector)
ψ| is Dirac notation for a row vector (bra vector)
Notation (cont’d)
A ∈ Rm×n(Cm×n) means A is a matrix of real (complex)
numbers with m rows and n columns
Notation (cont’d)
A ∈ Rm×n(Cm×n) means A is a matrix of real (complex)
numbers with m rows and n columns
When m = n we call A an operator
Notation (cont’d)
A ∈ Rm×n(Cm×n) means A is a matrix of real (complex)
numbers with m rows and n columns
When m = n we call A an operator
A† is Hermitian/adjoint/conjugate transpose of A
Notation (cont’d)
A ∈ Rm×n(Cm×n) means A is a matrix of real (complex)
numbers with m rows and n columns
When m = n we call A an operator
A† is Hermitian/adjoint/conjugate transpose of A
If a matrix A has elements Aij the matrix A†
has entries A∗
ji
An example is ψ| = |ψ †
Notation (cont’d)
A ∈ Rm×n(Cm×n) means A is a matrix of real (complex)
numbers with m rows and n columns
When m = n we call A an operator
A† is Hermitian/adjoint/conjugate transpose of A
If a matrix A has elements Aij the matrix A†
has entries A∗
ji
An example is ψ| = |ψ †
The quantity φ|ψ is called the inner product
The quantity is a scalar with value
n
i=1 φ∗
i ψi
Outline
Classical Search
Quantum Mechanics Overview
Notation
Mathematics
QM Background
Grover’s Algorithm
Explanation
References
Vector Norm
The norm/length/magnitude squared of |ψ ∈ Cn is defined as
ψ|ψ =
n
i=1
ψ∗
i ψi =
n
i=1
|ψi |2
Vector Norm
The norm/length/magnitude squared of |ψ ∈ Cn is defined as
ψ|ψ =
n
i=1
ψ∗
i ψi =
n
i=1
|ψi |2
This will always be 1 for a valid quantum mechanical state
Matrices
From the definition of the adjoint
(A|ψ )†
= (|ψ )†
A†
= ψ|A†
where A ∈ Cn×n
Matrices
From the definition of the adjoint
(A|ψ )†
= (|ψ )†
A†
= ψ|A†
where A ∈ Cn×n
Because the norm of a quantum state is 1, if |φ = U|ψ then
φ|φ = 1
Matrices
From the definition of the adjoint
(A|ψ )†
= (|ψ )†
A†
= ψ|A†
where A ∈ Cn×n
Because the norm of a quantum state is 1, if |φ = U|ψ then
φ|φ = 1
From this we have ( ψ|U†
)(U|ψ ) = 1 which means UT
U = I
Matrices
From the definition of the adjoint
(A|ψ )†
= (|ψ )†
A†
= ψ|A†
where A ∈ Cn×n
Because the norm of a quantum state is 1, if |φ = U|ψ then
φ|φ = 1
From this we have ( ψ|U†
)(U|ψ ) = 1 which means UT
U = I
An operator satisfying this property is called unitary
Matrices
From the definition of the adjoint
(A|ψ )†
= (|ψ )†
A†
= ψ|A†
where A ∈ Cn×n
Because the norm of a quantum state is 1, if |φ = U|ψ then
φ|φ = 1
From this we have ( ψ|U†
)(U|ψ ) = 1 which means UT
U = I
An operator satisfying this property is called unitary
Unitary operators are the way in which quantum states are
altered or evolved
H =
1
√
2
1 1
1 −1
, σx =
0 1
1 0
, σy =
0 i
−i 0
, σz =
1 0
0 −1
Linearity
Linearity of a function f means
f (x + y) = f (x) + f (y)
f (αx) = αf (x)
Linearity
Linearity of a function f means
f (x + y) = f (x) + f (y)
f (αx) = αf (x)
Matrix multiplication is linear
Linearity
Linearity of a function f means
f (x + y) = f (x) + f (y)
f (αx) = αf (x)
Matrix multiplication is linear
Common modeling approximation in engineering
Example: log(1 + x) is very nearly x for small x
Linearity & QM
Linearity is a fundamental property of QM
“With classical fields, we often use linear equations,
such as the differential equations that allow us to
solve for small oscillatory motion of, say, a pendu-
lum. In such a classical case, the linear equation is
an approximation; a pendulum with twice the am-
plitude of oscillation will not oscillate at exactly the
same frequency, for example. Hence we cannot take
the solution derived at one amplitude of oscillation of
the pendulum and merely scale it up for larger ampli-
tudes of oscillation, except as a first approximation.
We should emphasize right away, however, that, in
quantum mechanics, this linearity of the equations
with respect to the quantum mechanical amplitude
is not an approximation of any kind; it is apparently
an absolute property.”-David Miller (Prof. Stanford
University)
Outline
Classical Search
Quantum Mechanics Overview
Notation
Mathematics
QM Background
Grover’s Algorithm
Explanation
References
Quantum State
Single Particle System
Single particle can be in one of two states
Quantum State
Single Particle System
Single particle can be in one of two states
Electron, for example, can be spin up, |0 , or spin down, |1
Quantum State
Single Particle System
Single particle can be in one of two states
Electron, for example, can be spin up, |0 , or spin down, |1
Particle encodes a single quantum bit or qubit
Quantum State
Single Particle System
Single particle can be in one of two states
Electron, for example, can be spin up, |0 , or spin down, |1
Particle encodes a single quantum bit or qubit
A qubit is a vector in C2
represented as
|0 =
1
0
, |1 =
0
1
Quantum State
Single Particle System
Single particle can be in one of two states
Electron, for example, can be spin up, |0 , or spin down, |1
Particle encodes a single quantum bit or qubit
A qubit is a vector in C2
represented as
|0 =
1
0
, |1 =
0
1
Measuring, we will find the particle in exactly one of the two
states
Quantum State
Single Particle System
Single particle can be in one of two states
Electron, for example, can be spin up, |0 , or spin down, |1
Particle encodes a single quantum bit or qubit
A qubit is a vector in C2
represented as
|0 =
1
0
, |1 =
0
1
Measuring, we will find the particle in exactly one of the two
states
Before measurement this is not true!
Quantum State
Single Particle System
Single particle can be in one of two states
Electron, for example, can be spin up, |0 , or spin down, |1
Particle encodes a single quantum bit or qubit
A qubit is a vector in C2
represented as
|0 =
1
0
, |1 =
0
1
Measuring, we will find the particle in exactly one of the two
states
Before measurement this is not true!
Particle exists in a linear superposition of these states
Quantum State
Single Particle System
Single particle can be in one of two states
Electron, for example, can be spin up, |0 , or spin down, |1
Particle encodes a single quantum bit or qubit
A qubit is a vector in C2
represented as
|0 =
1
0
, |1 =
0
1
Measuring, we will find the particle in exactly one of the two
states
Before measurement this is not true!
Particle exists in a linear superposition of these states
State will be |ψ = ψ0|0 + ψ1|1
ψ0, ψ1 ∈ C and |ψ0|2
+ |ψ1|2
= 1
Quantum State
Single Particle System
Single particle can be in one of two states
Electron, for example, can be spin up, |0 , or spin down, |1
Particle encodes a single quantum bit or qubit
A qubit is a vector in C2
represented as
|0 =
1
0
, |1 =
0
1
Measuring, we will find the particle in exactly one of the two
states
Before measurement this is not true!
Particle exists in a linear superposition of these states
State will be |ψ = ψ0|0 + ψ1|1
ψ0, ψ1 ∈ C and |ψ0|2
+ |ψ1|2
= 1
Classical analogy is Schrodinger’s cat that is both alive and
dead
Quantum State
Multi-Particle System
Suppose we have n particles each of which can be in one of
two states
Quantum State
Multi-Particle System
Suppose we have n particles each of which can be in one of
two states
The system represents n qubits of information
Quantum State
Multi-Particle System
Suppose we have n particles each of which can be in one of
two states
The system represents n qubits of information
There are N = 2n
possible different states
|0 . . . 00 , |0 . . . 01 , |0 . . . 10 , . . . , |1 . . . 11
Quantum State
Multi-Particle System
Suppose we have n particles each of which can be in one of
two states
The system represents n qubits of information
There are N = 2n
possible different states
|0 . . . 00 , |0 . . . 01 , |0 . . . 10 , . . . , |1 . . . 11
Each state is a standard basis vector in RN
(i.e. one
component equal to 1 and the rest 0)
Note: The vector components are not the same as the entries
of the Dirac notation
Quantum State
Multi-Particle System
Suppose we have n particles each of which can be in one of
two states
The system represents n qubits of information
There are N = 2n
possible different states
|0 . . . 00 , |0 . . . 01 , |0 . . . 10 , . . . , |1 . . . 11
Each state is a standard basis vector in RN
(i.e. one
component equal to 1 and the rest 0)
Note: The vector components are not the same as the entries
of the Dirac notation
Measuring, we will find the system to be in one of N = 2n
possible states |ψ ∈ RN
Quantum State
Multi-Particle System
Suppose we have n particles each of which can be in one of
two states
The system represents n qubits of information
There are N = 2n
possible different states
|0 . . . 00 , |0 . . . 01 , |0 . . . 10 , . . . , |1 . . . 11
Each state is a standard basis vector in RN
(i.e. one
component equal to 1 and the rest 0)
Note: The vector components are not the same as the entries
of the Dirac notation
Measuring, we will find the system to be in one of N = 2n
possible states |ψ ∈ RN
Before measurement, it will be in a linear superposition of
these states
Quantum State
Multi-Particle System
Suppose we have n particles each of which can be in one of
two states
The system represents n qubits of information
There are N = 2n
possible different states
|0 . . . 00 , |0 . . . 01 , |0 . . . 10 , . . . , |1 . . . 11
Each state is a standard basis vector in RN
(i.e. one
component equal to 1 and the rest 0)
Note: The vector components are not the same as the entries
of the Dirac notation
Measuring, we will find the system to be in one of N = 2n
possible states |ψ ∈ RN
Before measurement, it will be in a linear superposition of
these states
Its state will be
|ψ = ψ0|0 . . . 00 + ψ1|0 . . . 01 + · · · + ψN−1|1 . . . 11 where
ψi ∈ C and
N−1
i=0 |ψi |2
= 1
Born Rule
What are the coefficients ψi respresenting physically?
Born Rule
What are the coefficients ψi respresenting physically?
ψi cannot be measured, but |ψi |2
can!
Born Rule
What are the coefficients ψi respresenting physically?
ψi cannot be measured, but |ψi |2
can!
Squared magnitude is the probability of measuring the system
in state i
Born Rule
What are the coefficients ψi respresenting physically?
ψi cannot be measured, but |ψi |2
can!
Squared magnitude is the probability of measuring the system
in state i
This interpretation is called the Born Rule
Born Rule
What are the coefficients ψi respresenting physically?
ψi cannot be measured, but |ψi |2
can!
Squared magnitude is the probability of measuring the system
in state i
This interpretation is called the Born Rule
This is empirical and more like a postulate
Born Rule
What are the coefficients ψi respresenting physically?
ψi cannot be measured, but |ψi |2
can!
Squared magnitude is the probability of measuring the system
in state i
This interpretation is called the Born Rule
This is empirical and more like a postulate
Many attempts to derive it from first principles
Born Rule
What are the coefficients ψi respresenting physically?
ψi cannot be measured, but |ψi |2
can!
Squared magnitude is the probability of measuring the system
in state i
This interpretation is called the Born Rule
This is empirical and more like a postulate
Many attempts to derive it from first principles
Are we sure it’s completely random?
Born Rule
What are the coefficients ψi respresenting physically?
ψi cannot be measured, but |ψi |2
can!
Squared magnitude is the probability of measuring the system
in state i
This interpretation is called the Born Rule
This is empirical and more like a postulate
Many attempts to derive it from first principles
Are we sure it’s completely random?
As far as we can tell, it is actually random (cf. Bell’s
Inequalities)
Born Rule
What are the coefficients ψi respresenting physically?
ψi cannot be measured, but |ψi |2
can!
Squared magnitude is the probability of measuring the system
in state i
This interpretation is called the Born Rule
This is empirical and more like a postulate
Many attempts to derive it from first principles
Are we sure it’s completely random?
As far as we can tell, it is actually random (cf. Bell’s
Inequalities)
Some interpretations of this phenomenon are
Born Rule
What are the coefficients ψi respresenting physically?
ψi cannot be measured, but |ψi |2
can!
Squared magnitude is the probability of measuring the system
in state i
This interpretation is called the Born Rule
This is empirical and more like a postulate
Many attempts to derive it from first principles
Are we sure it’s completely random?
As far as we can tell, it is actually random (cf. Bell’s
Inequalities)
Some interpretations of this phenomenon are
Copenhagen Interpretation
Many World’s Hypothesis
Quantum Decoherence
Quantum Measurement
Wave Particle Duality
A wave (of water say) impinging on a screen with two
openings will yield a diffraction pattern
Quantum Measurement
Wave Particle Duality
A wave (of water say) impinging on a screen with two
openings will yield a diffraction pattern
Each opening becomes the source of a new wave front
Quantum Measurement
Wave Particle Duality
A wave (of water say) impinging on a screen with two
openings will yield a diffraction pattern
Each opening becomes the source of a new wave front
The two waves interfere with each other forming alternating
peaks and troughs
Quantum Measurement
Wave Particle Duality
A wave (of water say) impinging on a screen with two
openings will yield a diffraction pattern
Each opening becomes the source of a new wave front
The two waves interfere with each other forming alternating
peaks and troughs
Quantum Measurement (cont’d)
Wave Particle Duality
Perform the same experiment with an electron gun
Quantum Measurement (cont’d)
Wave Particle Duality
Perform the same experiment with an electron gun
A diffraction pattern is observed!
This indicates electrons are like waves
Quantum Measurement (cont’d)
Wave Particle Duality
Perform the same experiment with an electron gun
A diffraction pattern is observed!
This indicates electrons are like waves
Now we have an apparatus that can shoot only a single
electron at a time
Quantum Measurement (cont’d)
Wave Particle Duality
Perform the same experiment with an electron gun
A diffraction pattern is observed!
This indicates electrons are like waves
Now we have an apparatus that can shoot only a single
electron at a time
A diffraction pattern! The electron is interfering with itself
Quantum Measurement (cont’d)
Wave Particle Duality
Perform the same experiment with an electron gun
A diffraction pattern is observed!
This indicates electrons are like waves
Now we have an apparatus that can shoot only a single
electron at a time
A diffraction pattern! The electron is interfering with itself
A measurement device is placed on one of the slits to see
which one the electron went through
Quantum Measurement (cont’d)
Wave Particle Duality
Perform the same experiment with an electron gun
A diffraction pattern is observed!
This indicates electrons are like waves
Now we have an apparatus that can shoot only a single
electron at a time
A diffraction pattern! The electron is interfering with itself
A measurement device is placed on one of the slits to see
which one the electron went through
Diffraction pattern is gone.
Electron behaves like a particle that goes through one slit or
the other when measured
The act of measurement has altered the outcome
Outline
Classical Search
Quantum Mechanics Overview
Notation
Mathematics
QM Background
Grover’s Algorithm
Explanation
References
Outline
Classical Search
Quantum Mechanics Overview
Notation
Mathematics
QM Background
Grover’s Algorithm
Explanation
References
Grover’s Algorithm
Function Inversion
Often framed in the context of unstructured database search
Grover’s Algorithm
Function Inversion
Often framed in the context of unstructured database search
More precisely, searches a function for a single satisfying input
Grover’s Algorithm
Function Inversion
Often framed in the context of unstructured database search
More precisely, searches a function for a single satisfying input
Given y, find the corresponding x such that f (x) = y.
Invert the function f (·)
To search an explicit list (i.e. unstructured database), need a
function backing it
Grover’s Algorithm
Function Inversion
Often framed in the context of unstructured database search
More precisely, searches a function for a single satisfying input
Given y, find the corresponding x such that f (x) = y.
Invert the function f (·)
To search an explicit list (i.e. unstructured database), need a
function backing it
If there is no solution or multiple solutions, algorithm does not
work out of the box
Grover’s Algorithm
Algorithm
We search for index |ω
Grover’s Algorithm
Algorithm
We search for index |ω
Initialize n qubits to quantum state |s ∈ RN (N = 2n) which
is the uniform superposition of states
Grover’s Algorithm
Algorithm
We search for index |ω
Initialize n qubits to quantum state |s ∈ RN (N = 2n) which
is the uniform superposition of states
|s
1
√
N
N
i=1
|x =
1
√
N
1
Grover’s Algorithm
Algorithm
We search for index |ω
Initialize n qubits to quantum state |s ∈ RN (N = 2n) which
is the uniform superposition of states
|s
1
√
N
N
i=1
|x =
1
√
N
1
Repeat r = π
4
√
N times
Grover’s Algorithm
Algorithm
We search for index |ω
Initialize n qubits to quantum state |s ∈ RN (N = 2n) which
is the uniform superposition of states
|s
1
√
N
N
i=1
|x =
1
√
N
1
Repeat r = π
4
√
N times
Define the oracle operator Uω ∈ Rn×n
as
Uω = I − 2|ω ω| = diag(1, 1, . . . , −1, , . . . , 1, 1
0,1,...,ω,...,N−2,N−1
)
Apply the operator Uω to the qubit state
Grover’s Algorithm
Algorithm
We search for index |ω
Initialize n qubits to quantum state |s ∈ RN (N = 2n) which
is the uniform superposition of states
|s
1
√
N
N
i=1
|x =
1
√
N
1
Repeat r = π
4
√
N times
Define the oracle operator Uω ∈ Rn×n
as
Uω = I − 2|ω ω| = diag(1, 1, . . . , −1, , . . . , 1, 1
0,1,...,ω,...,N−2,N−1
)
Apply the operator Uω to the qubit state
Define the operator Us ∈ Rn×n
as
Us = 2|s s| − I
Apply the operator Us to the qubit state
Grover’s Algorithm
Algorithm
We search for index |ω
Initialize n qubits to quantum state |s ∈ RN (N = 2n) which
is the uniform superposition of states
|s
1
√
N
N
i=1
|x =
1
√
N
1
Repeat r = π
4
√
N times
Define the oracle operator Uω ∈ Rn×n
as
Uω = I − 2|ω ω| = diag(1, 1, . . . , −1, , . . . , 1, 1
0,1,...,ω,...,N−2,N−1
)
Apply the operator Uω to the qubit state
Define the operator Us ∈ Rn×n
as
Us = 2|s s| − I
Apply the operator Us to the qubit state
Measure qubits
Inversion About the Mean
The operator Us can be written as
Us =





2
N − 1 2
N · · · 2
N
2
N
2
N − 1 · · · 2
N
...
...
...
...
2
N
2
N · · · 2
N − 1





Applying the operator to |x gives the update
xi ← −xi +
2
N
N
j=1
xj
Adds twice the mean of the coefficients to negation of each
state
State xω was already negated which boosts its value.
Grover’s Example
N=4
For the case of N = 4 we need only compute r = π
4
√
4 = 1
iteration
Uω|s = (I − 2|ω ω|)|s = |s − 2|ω ω|s = |s − 2|ω (1/
√
4)
Us |s −
2
√
4
|ω = (2|s s| − I) (|s − |ω )
= 2|s s|s − |s − |s s|ω + |ω
= 2|s − |s − |s − |ω
= |ω
Measure the system to get the answer
Grover’s Illustration (N=8, ω=3)
Grover’s Illustration (N=8, ω=3)
Grover’s Illustration (N=8, ω=3)
Grover’s Illustration (N=8, ω=3)
Grover’s Illustration (N=8, ω=3)
Graphical
Grover’s Algorithm
Notes
If the solution does not exist, an answer is returned at random
Grover’s Algorithm
Notes
If the solution does not exist, an answer is returned at random
Performing more iterations will degrade the solution
probability
Grover’s Algorithm
Notes
If the solution does not exist, an answer is returned at random
Performing more iterations will degrade the solution
probability
Multiple solutions will change the optimal number of
iterations needed
The Quantum Oracle
The oracle is a (problem dependent) function such that
f (ω) = 1 and 0 otherwise
The Quantum Oracle
The oracle is a (problem dependent) function such that
f (ω) = 1 and 0 otherwise
Each state is then multiplied with (−1)f (x)
to “mark” the
solution
The Quantum Oracle
The oracle is a (problem dependent) function such that
f (ω) = 1 and 0 otherwise
Each state is then multiplied with (−1)f (x)
to “mark” the
solution
Quantum oracle must be able to evaluate on the superposition
of indices
The Quantum Oracle
The oracle is a (problem dependent) function such that
f (ω) = 1 and 0 otherwise
Each state is then multiplied with (−1)f (x)
to “mark” the
solution
Quantum oracle must be able to evaluate on the superposition
of indices
Classically, we can only evaluate one query at a time
The Quantum Oracle
The oracle is a (problem dependent) function such that
f (ω) = 1 and 0 otherwise
Each state is then multiplied with (−1)f (x)
to “mark” the
solution
Quantum oracle must be able to evaluate on the superposition
of indices
Classically, we can only evaluate one query at a time
QM has natural parallelism; if f can evaluate x or y, then we
can evaluate f 1√
2
(x + y)
The Quantum Oracle
The oracle is a (problem dependent) function such that
f (ω) = 1 and 0 otherwise
Each state is then multiplied with (−1)f (x)
to “mark” the
solution
Quantum oracle must be able to evaluate on the superposition
of indices
Classically, we can only evaluate one query at a time
QM has natural parallelism; if f can evaluate x or y, then we
can evaluate f 1√
2
(x + y)
A quantum circuit with quantum gates can be built to
evaluate the predicate
The Quantum Oracle
The oracle is a (problem dependent) function such that
f (ω) = 1 and 0 otherwise
Each state is then multiplied with (−1)f (x)
to “mark” the
solution
Quantum oracle must be able to evaluate on the superposition
of indices
Classically, we can only evaluate one query at a time
QM has natural parallelism; if f can evaluate x or y, then we
can evaluate f 1√
2
(x + y)
A quantum circuit with quantum gates can be built to
evaluate the predicate
Gates such as Hadamard, Pauli Spin, Phase shift, CNOT etc
(all are unitary operators) used to build oracles
The Quantum Oracle
The oracle is a (problem dependent) function such that
f (ω) = 1 and 0 otherwise
Each state is then multiplied with (−1)f (x)
to “mark” the
solution
Quantum oracle must be able to evaluate on the superposition
of indices
Classically, we can only evaluate one query at a time
QM has natural parallelism; if f can evaluate x or y, then we
can evaluate f 1√
2
(x + y)
A quantum circuit with quantum gates can be built to
evaluate the predicate
Gates such as Hadamard, Pauli Spin, Phase shift, CNOT etc
(all are unitary operators) used to build oracles
Programming a quantum computer is more like programming
an FPGA than writing software
Usefulness of Grover’s
The O(
√
N) bound assumes predicate can be evaluated on
superposition of all states
Usefulness of Grover’s
The O(
√
N) bound assumes predicate can be evaluated on
superposition of all states
f (·) must be implemented in quantum hardware using
quantum gates
May be difficult to find compact gate representation
Problems like database search must first convert to an implicit
list
Cost of evaluating f (·) may dominate
Current State of Quantum Computing
IBM claims to have a working prototype of a 50 qubit
quantum computer
Current State of Quantum Computing
IBM claims to have a working prototype of a 50 qubit
quantum computer
D Wave solves optimization problems by exploiting QM effects
Current State of Quantum Computing
IBM claims to have a working prototype of a 50 qubit
quantum computer
D Wave solves optimization problems by exploiting QM effects
Much of quantum computing is still theoretical and uses
simulation
Q#, Libquantum, IBM Q etc
Simulation requires lots of memory (e.g. 32 qubits implies
2 · 232
real numbers)
Outline
Classical Search
Quantum Mechanics Overview
Notation
Mathematics
QM Background
Grover’s Algorithm
Explanation
References
References
https://en.wikipedia.org/wiki/Grover%27s algorithm
https://quantiki.org/wiki/grovers-search-algorithm
Quantum Mechanics for Scientists and Engineers - David
Miller
https://web.eecs.umich.edu/ imarkov/pubs/jour/cise05-
grov.pdf

More Related Content

PPT
Quantum Information
PPTX
Grover's algorithm simplified.pptx
PPTX
Quantum error correction
PPTX
Quantum machine learning basics
PPTX
5 Qubit Modalities Used In Quantum Computing.pptx
PPTX
An introduction to quantum machine learning.pptx
PPTX
Shors'algorithm simplified.pptx
PPTX
Quantum computing in machine learning
Quantum Information
Grover's algorithm simplified.pptx
Quantum error correction
Quantum machine learning basics
5 Qubit Modalities Used In Quantum Computing.pptx
An introduction to quantum machine learning.pptx
Shors'algorithm simplified.pptx
Quantum computing in machine learning

What's hot (20)

PPTX
Shor’s algorithm the ppt
PPTX
Grover's algorithm - Introduction to quantum computing
PPT
Quantum computer
PDF
Quantum computation - Introduction
PPTX
Quantum computing seminar
PPTX
Quantum gates
PPTX
Quantum computing - Introduction
PPT
Fundamentals of Quantum Computing
PDF
Introduction to Quantum Computing
PPTX
Quantum Computing
PDF
Quantum Computing: The Why and How
PDF
Quantum computing
PPTX
Presentation on quantum computers
PDF
Neuromorphic computing for neural networks
PDF
Problem Solving
PDF
Post Quantum Cryptography: Technical Overview
PPTX
Quantum programming
PPTX
Quantum Computation simplified.pptx
PPT
Quantum Computing
PPTX
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...
Shor’s algorithm the ppt
Grover's algorithm - Introduction to quantum computing
Quantum computer
Quantum computation - Introduction
Quantum computing seminar
Quantum gates
Quantum computing - Introduction
Fundamentals of Quantum Computing
Introduction to Quantum Computing
Quantum Computing
Quantum Computing: The Why and How
Quantum computing
Presentation on quantum computers
Neuromorphic computing for neural networks
Problem Solving
Post Quantum Cryptography: Technical Overview
Quantum programming
Quantum Computation simplified.pptx
Quantum Computing
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...
Ad

Similar to Grovers Algorithm (20)

PDF
MMath Paper, Canlin Zhang
PDF
Quantum Computation and the Stabilizer Formalism for Error Correction
PDF
notes.pdf
PDF
Quantum computing notes_DN_30 1 2023.pdf
PDF
Module 2- Mathematical Formulation-Completed .pdf
PPT
lecture2.ppt quantum computing dave bacon
PDF
Algebraic foundations of quantum computing
PPTX
Quantum Computation 101 (Almost)
PPT
2007 001-motivation-to-quantum-computing
PDF
No Cloning Theorem with essential Mathematics and Physics
PDF
Smooth entropies a tutorial
PPT
Quantum Computation and Algorithms
PDF
Quantum Cryptography
PPT
1619 quantum computing
PPTX
Fundamentals of quantum computing part i rev
PDF
Quantum computing for CS students: the unitary circuit model
PDF
Mathematics of quantum mechanics bridge course calicut university
PDF
Operators n dirac in qm
PDF
chapter2_alt
PDF
Quantum algorithm for solving linear systems of equations
MMath Paper, Canlin Zhang
Quantum Computation and the Stabilizer Formalism for Error Correction
notes.pdf
Quantum computing notes_DN_30 1 2023.pdf
Module 2- Mathematical Formulation-Completed .pdf
lecture2.ppt quantum computing dave bacon
Algebraic foundations of quantum computing
Quantum Computation 101 (Almost)
2007 001-motivation-to-quantum-computing
No Cloning Theorem with essential Mathematics and Physics
Smooth entropies a tutorial
Quantum Computation and Algorithms
Quantum Cryptography
1619 quantum computing
Fundamentals of quantum computing part i rev
Quantum computing for CS students: the unitary circuit model
Mathematics of quantum mechanics bridge course calicut university
Operators n dirac in qm
chapter2_alt
Quantum algorithm for solving linear systems of equations
Ad

Recently uploaded (20)

PDF
Water Supply and Sanitary Engineering Textbook
PDF
Human CELLS and structure in Anatomy and human physiology
PDF
M01-Manage Safety and Environmental Protection 1.pdf
PPTX
Retail.pptx internet of things mtech 2 nd sem
PPTX
240409 Data Center Training Programs by Uptime Institute (Drafting).pptx
PDF
Snapchat product teardown product management
PDF
BBC NW_Tech Facilities_30 Odd Yrs Ago [J].pdf
PDF
ForSee by Languify Teardown final product management
PDF
Operating systems-POS-U1.2.pdf cse gghhu
PDF
B461227.pdf American Journal of Multidisciplinary Research and Review
PDF
August 2025 Top Read Articles in - Bioscience & Engineering Recent Research T...
PDF
ITEC 1010 - Networks and Cloud Computing
PDF
Design and Implementation of Low-Cost Electric Vehicles (EVs) Supercharger: A...
PDF
Manual variador de corriente directa parker.pdf
PDF
PhD defense presentation in field of Computer Science
PPTX
PPT-HEART-DISEASE[1].pptx presentationss
PDF
ITEC 1010 - Information and Organizations Database System and Big data
PDF
02. INDUSTRIAL REVOLUTION & Cultural, Technical and territorial transformatio...
PDF
The Journal of Finance - July 1993 - JENSEN - The Modern Industrial Revolutio...
PPTX
CC PPTS unit-I PPT Notes of Cloud Computing
Water Supply and Sanitary Engineering Textbook
Human CELLS and structure in Anatomy and human physiology
M01-Manage Safety and Environmental Protection 1.pdf
Retail.pptx internet of things mtech 2 nd sem
240409 Data Center Training Programs by Uptime Institute (Drafting).pptx
Snapchat product teardown product management
BBC NW_Tech Facilities_30 Odd Yrs Ago [J].pdf
ForSee by Languify Teardown final product management
Operating systems-POS-U1.2.pdf cse gghhu
B461227.pdf American Journal of Multidisciplinary Research and Review
August 2025 Top Read Articles in - Bioscience & Engineering Recent Research T...
ITEC 1010 - Networks and Cloud Computing
Design and Implementation of Low-Cost Electric Vehicles (EVs) Supercharger: A...
Manual variador de corriente directa parker.pdf
PhD defense presentation in field of Computer Science
PPT-HEART-DISEASE[1].pptx presentationss
ITEC 1010 - Information and Organizations Database System and Big data
02. INDUSTRIAL REVOLUTION & Cultural, Technical and territorial transformatio...
The Journal of Finance - July 1993 - JENSEN - The Modern Industrial Revolutio...
CC PPTS unit-I PPT Notes of Cloud Computing

Grovers Algorithm

  • 1. Grover’s Algorithm Quantum Search Algorithm in O( √ N) complexity C. Haaland December 30, 2017
  • 2. Outline Classical Search Quantum Mechanics Overview Notation Mathematics QM Background Grover’s Algorithm Explanation References
  • 3. Classical Search Motivation “Imagine a phone directory containing N names arranged in completely random order. In order to find someone’s phone number with a probability of 0.5, any classical algorithm (whether deterministic or probabilistic) will need to look at a minimum of N/2 names.”
  • 4. Classical Search Motivation “Imagine a phone directory containing N names arranged in completely random order. In order to find someone’s phone number with a probability of 0.5, any classical algorithm (whether deterministic or probabilistic) will need to look at a minimum of N/2 names.” Consider the function F : {0, 1}3 → {0, 1}, F(x, y, z) =(x ∨ y ∨ z)∧ (¬x ∨ ¬y ∨ z)∧ (x ∨ ¬y ∨ ¬z)∧ (¬x ∨ y ∨ ¬z) Question: For what values of the input does F(x, y, z) = 1?
  • 5. Classical Search Complexity Problems are O(N) on a classical computer Lov Grover published a quantum algorithm in 1996 with complexity O( √ N). For large N, this represents a significant improvement over the classical case Quantum algorithm cannot guarantee the correct answer, only returns the solution with high probability
  • 6. Outline Classical Search Quantum Mechanics Overview Notation Mathematics QM Background Grover’s Algorithm Explanation References
  • 7. Outline Classical Search Quantum Mechanics Overview Notation Mathematics QM Background Grover’s Algorithm Explanation References
  • 8. Notation R is set of real numbers
  • 9. Notation R is set of real numbers C is set of complex numbers (e.g. x + iy)
  • 10. Notation R is set of real numbers C is set of complex numbers (e.g. x + iy) Rn (Cn) indicates column vector of n real (complex) numbers respectively
  • 11. Notation R is set of real numbers C is set of complex numbers (e.g. x + iy) Rn (Cn) indicates column vector of n real (complex) numbers respectively z∗ is the complex conjugate If z = x + iy then z∗ = x − iy
  • 12. Notation R is set of real numbers C is set of complex numbers (e.g. x + iy) Rn (Cn) indicates column vector of n real (complex) numbers respectively z∗ is the complex conjugate If z = x + iy then z∗ = x − iy |ψ is Dirac notation for a column vector (ket vector)
  • 13. Notation R is set of real numbers C is set of complex numbers (e.g. x + iy) Rn (Cn) indicates column vector of n real (complex) numbers respectively z∗ is the complex conjugate If z = x + iy then z∗ = x − iy |ψ is Dirac notation for a column vector (ket vector) ψ| is Dirac notation for a row vector (bra vector)
  • 14. Notation (cont’d) A ∈ Rm×n(Cm×n) means A is a matrix of real (complex) numbers with m rows and n columns
  • 15. Notation (cont’d) A ∈ Rm×n(Cm×n) means A is a matrix of real (complex) numbers with m rows and n columns When m = n we call A an operator
  • 16. Notation (cont’d) A ∈ Rm×n(Cm×n) means A is a matrix of real (complex) numbers with m rows and n columns When m = n we call A an operator A† is Hermitian/adjoint/conjugate transpose of A
  • 17. Notation (cont’d) A ∈ Rm×n(Cm×n) means A is a matrix of real (complex) numbers with m rows and n columns When m = n we call A an operator A† is Hermitian/adjoint/conjugate transpose of A If a matrix A has elements Aij the matrix A† has entries A∗ ji An example is ψ| = |ψ †
  • 18. Notation (cont’d) A ∈ Rm×n(Cm×n) means A is a matrix of real (complex) numbers with m rows and n columns When m = n we call A an operator A† is Hermitian/adjoint/conjugate transpose of A If a matrix A has elements Aij the matrix A† has entries A∗ ji An example is ψ| = |ψ † The quantity φ|ψ is called the inner product The quantity is a scalar with value n i=1 φ∗ i ψi
  • 19. Outline Classical Search Quantum Mechanics Overview Notation Mathematics QM Background Grover’s Algorithm Explanation References
  • 20. Vector Norm The norm/length/magnitude squared of |ψ ∈ Cn is defined as ψ|ψ = n i=1 ψ∗ i ψi = n i=1 |ψi |2
  • 21. Vector Norm The norm/length/magnitude squared of |ψ ∈ Cn is defined as ψ|ψ = n i=1 ψ∗ i ψi = n i=1 |ψi |2 This will always be 1 for a valid quantum mechanical state
  • 22. Matrices From the definition of the adjoint (A|ψ )† = (|ψ )† A† = ψ|A† where A ∈ Cn×n
  • 23. Matrices From the definition of the adjoint (A|ψ )† = (|ψ )† A† = ψ|A† where A ∈ Cn×n Because the norm of a quantum state is 1, if |φ = U|ψ then φ|φ = 1
  • 24. Matrices From the definition of the adjoint (A|ψ )† = (|ψ )† A† = ψ|A† where A ∈ Cn×n Because the norm of a quantum state is 1, if |φ = U|ψ then φ|φ = 1 From this we have ( ψ|U† )(U|ψ ) = 1 which means UT U = I
  • 25. Matrices From the definition of the adjoint (A|ψ )† = (|ψ )† A† = ψ|A† where A ∈ Cn×n Because the norm of a quantum state is 1, if |φ = U|ψ then φ|φ = 1 From this we have ( ψ|U† )(U|ψ ) = 1 which means UT U = I An operator satisfying this property is called unitary
  • 26. Matrices From the definition of the adjoint (A|ψ )† = (|ψ )† A† = ψ|A† where A ∈ Cn×n Because the norm of a quantum state is 1, if |φ = U|ψ then φ|φ = 1 From this we have ( ψ|U† )(U|ψ ) = 1 which means UT U = I An operator satisfying this property is called unitary Unitary operators are the way in which quantum states are altered or evolved H = 1 √ 2 1 1 1 −1 , σx = 0 1 1 0 , σy = 0 i −i 0 , σz = 1 0 0 −1
  • 27. Linearity Linearity of a function f means f (x + y) = f (x) + f (y) f (αx) = αf (x)
  • 28. Linearity Linearity of a function f means f (x + y) = f (x) + f (y) f (αx) = αf (x) Matrix multiplication is linear
  • 29. Linearity Linearity of a function f means f (x + y) = f (x) + f (y) f (αx) = αf (x) Matrix multiplication is linear Common modeling approximation in engineering Example: log(1 + x) is very nearly x for small x
  • 30. Linearity & QM Linearity is a fundamental property of QM “With classical fields, we often use linear equations, such as the differential equations that allow us to solve for small oscillatory motion of, say, a pendu- lum. In such a classical case, the linear equation is an approximation; a pendulum with twice the am- plitude of oscillation will not oscillate at exactly the same frequency, for example. Hence we cannot take the solution derived at one amplitude of oscillation of the pendulum and merely scale it up for larger ampli- tudes of oscillation, except as a first approximation. We should emphasize right away, however, that, in quantum mechanics, this linearity of the equations with respect to the quantum mechanical amplitude is not an approximation of any kind; it is apparently an absolute property.”-David Miller (Prof. Stanford University)
  • 31. Outline Classical Search Quantum Mechanics Overview Notation Mathematics QM Background Grover’s Algorithm Explanation References
  • 32. Quantum State Single Particle System Single particle can be in one of two states
  • 33. Quantum State Single Particle System Single particle can be in one of two states Electron, for example, can be spin up, |0 , or spin down, |1
  • 34. Quantum State Single Particle System Single particle can be in one of two states Electron, for example, can be spin up, |0 , or spin down, |1 Particle encodes a single quantum bit or qubit
  • 35. Quantum State Single Particle System Single particle can be in one of two states Electron, for example, can be spin up, |0 , or spin down, |1 Particle encodes a single quantum bit or qubit A qubit is a vector in C2 represented as |0 = 1 0 , |1 = 0 1
  • 36. Quantum State Single Particle System Single particle can be in one of two states Electron, for example, can be spin up, |0 , or spin down, |1 Particle encodes a single quantum bit or qubit A qubit is a vector in C2 represented as |0 = 1 0 , |1 = 0 1 Measuring, we will find the particle in exactly one of the two states
  • 37. Quantum State Single Particle System Single particle can be in one of two states Electron, for example, can be spin up, |0 , or spin down, |1 Particle encodes a single quantum bit or qubit A qubit is a vector in C2 represented as |0 = 1 0 , |1 = 0 1 Measuring, we will find the particle in exactly one of the two states Before measurement this is not true!
  • 38. Quantum State Single Particle System Single particle can be in one of two states Electron, for example, can be spin up, |0 , or spin down, |1 Particle encodes a single quantum bit or qubit A qubit is a vector in C2 represented as |0 = 1 0 , |1 = 0 1 Measuring, we will find the particle in exactly one of the two states Before measurement this is not true! Particle exists in a linear superposition of these states
  • 39. Quantum State Single Particle System Single particle can be in one of two states Electron, for example, can be spin up, |0 , or spin down, |1 Particle encodes a single quantum bit or qubit A qubit is a vector in C2 represented as |0 = 1 0 , |1 = 0 1 Measuring, we will find the particle in exactly one of the two states Before measurement this is not true! Particle exists in a linear superposition of these states State will be |ψ = ψ0|0 + ψ1|1 ψ0, ψ1 ∈ C and |ψ0|2 + |ψ1|2 = 1
  • 40. Quantum State Single Particle System Single particle can be in one of two states Electron, for example, can be spin up, |0 , or spin down, |1 Particle encodes a single quantum bit or qubit A qubit is a vector in C2 represented as |0 = 1 0 , |1 = 0 1 Measuring, we will find the particle in exactly one of the two states Before measurement this is not true! Particle exists in a linear superposition of these states State will be |ψ = ψ0|0 + ψ1|1 ψ0, ψ1 ∈ C and |ψ0|2 + |ψ1|2 = 1 Classical analogy is Schrodinger’s cat that is both alive and dead
  • 41. Quantum State Multi-Particle System Suppose we have n particles each of which can be in one of two states
  • 42. Quantum State Multi-Particle System Suppose we have n particles each of which can be in one of two states The system represents n qubits of information
  • 43. Quantum State Multi-Particle System Suppose we have n particles each of which can be in one of two states The system represents n qubits of information There are N = 2n possible different states |0 . . . 00 , |0 . . . 01 , |0 . . . 10 , . . . , |1 . . . 11
  • 44. Quantum State Multi-Particle System Suppose we have n particles each of which can be in one of two states The system represents n qubits of information There are N = 2n possible different states |0 . . . 00 , |0 . . . 01 , |0 . . . 10 , . . . , |1 . . . 11 Each state is a standard basis vector in RN (i.e. one component equal to 1 and the rest 0) Note: The vector components are not the same as the entries of the Dirac notation
  • 45. Quantum State Multi-Particle System Suppose we have n particles each of which can be in one of two states The system represents n qubits of information There are N = 2n possible different states |0 . . . 00 , |0 . . . 01 , |0 . . . 10 , . . . , |1 . . . 11 Each state is a standard basis vector in RN (i.e. one component equal to 1 and the rest 0) Note: The vector components are not the same as the entries of the Dirac notation Measuring, we will find the system to be in one of N = 2n possible states |ψ ∈ RN
  • 46. Quantum State Multi-Particle System Suppose we have n particles each of which can be in one of two states The system represents n qubits of information There are N = 2n possible different states |0 . . . 00 , |0 . . . 01 , |0 . . . 10 , . . . , |1 . . . 11 Each state is a standard basis vector in RN (i.e. one component equal to 1 and the rest 0) Note: The vector components are not the same as the entries of the Dirac notation Measuring, we will find the system to be in one of N = 2n possible states |ψ ∈ RN Before measurement, it will be in a linear superposition of these states
  • 47. Quantum State Multi-Particle System Suppose we have n particles each of which can be in one of two states The system represents n qubits of information There are N = 2n possible different states |0 . . . 00 , |0 . . . 01 , |0 . . . 10 , . . . , |1 . . . 11 Each state is a standard basis vector in RN (i.e. one component equal to 1 and the rest 0) Note: The vector components are not the same as the entries of the Dirac notation Measuring, we will find the system to be in one of N = 2n possible states |ψ ∈ RN Before measurement, it will be in a linear superposition of these states Its state will be |ψ = ψ0|0 . . . 00 + ψ1|0 . . . 01 + · · · + ψN−1|1 . . . 11 where ψi ∈ C and N−1 i=0 |ψi |2 = 1
  • 48. Born Rule What are the coefficients ψi respresenting physically?
  • 49. Born Rule What are the coefficients ψi respresenting physically? ψi cannot be measured, but |ψi |2 can!
  • 50. Born Rule What are the coefficients ψi respresenting physically? ψi cannot be measured, but |ψi |2 can! Squared magnitude is the probability of measuring the system in state i
  • 51. Born Rule What are the coefficients ψi respresenting physically? ψi cannot be measured, but |ψi |2 can! Squared magnitude is the probability of measuring the system in state i This interpretation is called the Born Rule
  • 52. Born Rule What are the coefficients ψi respresenting physically? ψi cannot be measured, but |ψi |2 can! Squared magnitude is the probability of measuring the system in state i This interpretation is called the Born Rule This is empirical and more like a postulate
  • 53. Born Rule What are the coefficients ψi respresenting physically? ψi cannot be measured, but |ψi |2 can! Squared magnitude is the probability of measuring the system in state i This interpretation is called the Born Rule This is empirical and more like a postulate Many attempts to derive it from first principles
  • 54. Born Rule What are the coefficients ψi respresenting physically? ψi cannot be measured, but |ψi |2 can! Squared magnitude is the probability of measuring the system in state i This interpretation is called the Born Rule This is empirical and more like a postulate Many attempts to derive it from first principles Are we sure it’s completely random?
  • 55. Born Rule What are the coefficients ψi respresenting physically? ψi cannot be measured, but |ψi |2 can! Squared magnitude is the probability of measuring the system in state i This interpretation is called the Born Rule This is empirical and more like a postulate Many attempts to derive it from first principles Are we sure it’s completely random? As far as we can tell, it is actually random (cf. Bell’s Inequalities)
  • 56. Born Rule What are the coefficients ψi respresenting physically? ψi cannot be measured, but |ψi |2 can! Squared magnitude is the probability of measuring the system in state i This interpretation is called the Born Rule This is empirical and more like a postulate Many attempts to derive it from first principles Are we sure it’s completely random? As far as we can tell, it is actually random (cf. Bell’s Inequalities) Some interpretations of this phenomenon are
  • 57. Born Rule What are the coefficients ψi respresenting physically? ψi cannot be measured, but |ψi |2 can! Squared magnitude is the probability of measuring the system in state i This interpretation is called the Born Rule This is empirical and more like a postulate Many attempts to derive it from first principles Are we sure it’s completely random? As far as we can tell, it is actually random (cf. Bell’s Inequalities) Some interpretations of this phenomenon are Copenhagen Interpretation Many World’s Hypothesis Quantum Decoherence
  • 58. Quantum Measurement Wave Particle Duality A wave (of water say) impinging on a screen with two openings will yield a diffraction pattern
  • 59. Quantum Measurement Wave Particle Duality A wave (of water say) impinging on a screen with two openings will yield a diffraction pattern Each opening becomes the source of a new wave front
  • 60. Quantum Measurement Wave Particle Duality A wave (of water say) impinging on a screen with two openings will yield a diffraction pattern Each opening becomes the source of a new wave front The two waves interfere with each other forming alternating peaks and troughs
  • 61. Quantum Measurement Wave Particle Duality A wave (of water say) impinging on a screen with two openings will yield a diffraction pattern Each opening becomes the source of a new wave front The two waves interfere with each other forming alternating peaks and troughs
  • 62. Quantum Measurement (cont’d) Wave Particle Duality Perform the same experiment with an electron gun
  • 63. Quantum Measurement (cont’d) Wave Particle Duality Perform the same experiment with an electron gun A diffraction pattern is observed! This indicates electrons are like waves
  • 64. Quantum Measurement (cont’d) Wave Particle Duality Perform the same experiment with an electron gun A diffraction pattern is observed! This indicates electrons are like waves Now we have an apparatus that can shoot only a single electron at a time
  • 65. Quantum Measurement (cont’d) Wave Particle Duality Perform the same experiment with an electron gun A diffraction pattern is observed! This indicates electrons are like waves Now we have an apparatus that can shoot only a single electron at a time A diffraction pattern! The electron is interfering with itself
  • 66. Quantum Measurement (cont’d) Wave Particle Duality Perform the same experiment with an electron gun A diffraction pattern is observed! This indicates electrons are like waves Now we have an apparatus that can shoot only a single electron at a time A diffraction pattern! The electron is interfering with itself A measurement device is placed on one of the slits to see which one the electron went through
  • 67. Quantum Measurement (cont’d) Wave Particle Duality Perform the same experiment with an electron gun A diffraction pattern is observed! This indicates electrons are like waves Now we have an apparatus that can shoot only a single electron at a time A diffraction pattern! The electron is interfering with itself A measurement device is placed on one of the slits to see which one the electron went through Diffraction pattern is gone. Electron behaves like a particle that goes through one slit or the other when measured The act of measurement has altered the outcome
  • 68. Outline Classical Search Quantum Mechanics Overview Notation Mathematics QM Background Grover’s Algorithm Explanation References
  • 69. Outline Classical Search Quantum Mechanics Overview Notation Mathematics QM Background Grover’s Algorithm Explanation References
  • 70. Grover’s Algorithm Function Inversion Often framed in the context of unstructured database search
  • 71. Grover’s Algorithm Function Inversion Often framed in the context of unstructured database search More precisely, searches a function for a single satisfying input
  • 72. Grover’s Algorithm Function Inversion Often framed in the context of unstructured database search More precisely, searches a function for a single satisfying input Given y, find the corresponding x such that f (x) = y. Invert the function f (·) To search an explicit list (i.e. unstructured database), need a function backing it
  • 73. Grover’s Algorithm Function Inversion Often framed in the context of unstructured database search More precisely, searches a function for a single satisfying input Given y, find the corresponding x such that f (x) = y. Invert the function f (·) To search an explicit list (i.e. unstructured database), need a function backing it If there is no solution or multiple solutions, algorithm does not work out of the box
  • 75. Grover’s Algorithm Algorithm We search for index |ω Initialize n qubits to quantum state |s ∈ RN (N = 2n) which is the uniform superposition of states
  • 76. Grover’s Algorithm Algorithm We search for index |ω Initialize n qubits to quantum state |s ∈ RN (N = 2n) which is the uniform superposition of states |s 1 √ N N i=1 |x = 1 √ N 1
  • 77. Grover’s Algorithm Algorithm We search for index |ω Initialize n qubits to quantum state |s ∈ RN (N = 2n) which is the uniform superposition of states |s 1 √ N N i=1 |x = 1 √ N 1 Repeat r = π 4 √ N times
  • 78. Grover’s Algorithm Algorithm We search for index |ω Initialize n qubits to quantum state |s ∈ RN (N = 2n) which is the uniform superposition of states |s 1 √ N N i=1 |x = 1 √ N 1 Repeat r = π 4 √ N times Define the oracle operator Uω ∈ Rn×n as Uω = I − 2|ω ω| = diag(1, 1, . . . , −1, , . . . , 1, 1 0,1,...,ω,...,N−2,N−1 ) Apply the operator Uω to the qubit state
  • 79. Grover’s Algorithm Algorithm We search for index |ω Initialize n qubits to quantum state |s ∈ RN (N = 2n) which is the uniform superposition of states |s 1 √ N N i=1 |x = 1 √ N 1 Repeat r = π 4 √ N times Define the oracle operator Uω ∈ Rn×n as Uω = I − 2|ω ω| = diag(1, 1, . . . , −1, , . . . , 1, 1 0,1,...,ω,...,N−2,N−1 ) Apply the operator Uω to the qubit state Define the operator Us ∈ Rn×n as Us = 2|s s| − I Apply the operator Us to the qubit state
  • 80. Grover’s Algorithm Algorithm We search for index |ω Initialize n qubits to quantum state |s ∈ RN (N = 2n) which is the uniform superposition of states |s 1 √ N N i=1 |x = 1 √ N 1 Repeat r = π 4 √ N times Define the oracle operator Uω ∈ Rn×n as Uω = I − 2|ω ω| = diag(1, 1, . . . , −1, , . . . , 1, 1 0,1,...,ω,...,N−2,N−1 ) Apply the operator Uω to the qubit state Define the operator Us ∈ Rn×n as Us = 2|s s| − I Apply the operator Us to the qubit state Measure qubits
  • 81. Inversion About the Mean The operator Us can be written as Us =      2 N − 1 2 N · · · 2 N 2 N 2 N − 1 · · · 2 N ... ... ... ... 2 N 2 N · · · 2 N − 1      Applying the operator to |x gives the update xi ← −xi + 2 N N j=1 xj Adds twice the mean of the coefficients to negation of each state State xω was already negated which boosts its value.
  • 82. Grover’s Example N=4 For the case of N = 4 we need only compute r = π 4 √ 4 = 1 iteration Uω|s = (I − 2|ω ω|)|s = |s − 2|ω ω|s = |s − 2|ω (1/ √ 4) Us |s − 2 √ 4 |ω = (2|s s| − I) (|s − |ω ) = 2|s s|s − |s − |s s|ω + |ω = 2|s − |s − |s − |ω = |ω Measure the system to get the answer
  • 87. Grover’s Illustration (N=8, ω=3) Graphical
  • 88. Grover’s Algorithm Notes If the solution does not exist, an answer is returned at random
  • 89. Grover’s Algorithm Notes If the solution does not exist, an answer is returned at random Performing more iterations will degrade the solution probability
  • 90. Grover’s Algorithm Notes If the solution does not exist, an answer is returned at random Performing more iterations will degrade the solution probability Multiple solutions will change the optimal number of iterations needed
  • 91. The Quantum Oracle The oracle is a (problem dependent) function such that f (ω) = 1 and 0 otherwise
  • 92. The Quantum Oracle The oracle is a (problem dependent) function such that f (ω) = 1 and 0 otherwise Each state is then multiplied with (−1)f (x) to “mark” the solution
  • 93. The Quantum Oracle The oracle is a (problem dependent) function such that f (ω) = 1 and 0 otherwise Each state is then multiplied with (−1)f (x) to “mark” the solution Quantum oracle must be able to evaluate on the superposition of indices
  • 94. The Quantum Oracle The oracle is a (problem dependent) function such that f (ω) = 1 and 0 otherwise Each state is then multiplied with (−1)f (x) to “mark” the solution Quantum oracle must be able to evaluate on the superposition of indices Classically, we can only evaluate one query at a time
  • 95. The Quantum Oracle The oracle is a (problem dependent) function such that f (ω) = 1 and 0 otherwise Each state is then multiplied with (−1)f (x) to “mark” the solution Quantum oracle must be able to evaluate on the superposition of indices Classically, we can only evaluate one query at a time QM has natural parallelism; if f can evaluate x or y, then we can evaluate f 1√ 2 (x + y)
  • 96. The Quantum Oracle The oracle is a (problem dependent) function such that f (ω) = 1 and 0 otherwise Each state is then multiplied with (−1)f (x) to “mark” the solution Quantum oracle must be able to evaluate on the superposition of indices Classically, we can only evaluate one query at a time QM has natural parallelism; if f can evaluate x or y, then we can evaluate f 1√ 2 (x + y) A quantum circuit with quantum gates can be built to evaluate the predicate
  • 97. The Quantum Oracle The oracle is a (problem dependent) function such that f (ω) = 1 and 0 otherwise Each state is then multiplied with (−1)f (x) to “mark” the solution Quantum oracle must be able to evaluate on the superposition of indices Classically, we can only evaluate one query at a time QM has natural parallelism; if f can evaluate x or y, then we can evaluate f 1√ 2 (x + y) A quantum circuit with quantum gates can be built to evaluate the predicate Gates such as Hadamard, Pauli Spin, Phase shift, CNOT etc (all are unitary operators) used to build oracles
  • 98. The Quantum Oracle The oracle is a (problem dependent) function such that f (ω) = 1 and 0 otherwise Each state is then multiplied with (−1)f (x) to “mark” the solution Quantum oracle must be able to evaluate on the superposition of indices Classically, we can only evaluate one query at a time QM has natural parallelism; if f can evaluate x or y, then we can evaluate f 1√ 2 (x + y) A quantum circuit with quantum gates can be built to evaluate the predicate Gates such as Hadamard, Pauli Spin, Phase shift, CNOT etc (all are unitary operators) used to build oracles Programming a quantum computer is more like programming an FPGA than writing software
  • 99. Usefulness of Grover’s The O( √ N) bound assumes predicate can be evaluated on superposition of all states
  • 100. Usefulness of Grover’s The O( √ N) bound assumes predicate can be evaluated on superposition of all states f (·) must be implemented in quantum hardware using quantum gates May be difficult to find compact gate representation Problems like database search must first convert to an implicit list Cost of evaluating f (·) may dominate
  • 101. Current State of Quantum Computing IBM claims to have a working prototype of a 50 qubit quantum computer
  • 102. Current State of Quantum Computing IBM claims to have a working prototype of a 50 qubit quantum computer D Wave solves optimization problems by exploiting QM effects
  • 103. Current State of Quantum Computing IBM claims to have a working prototype of a 50 qubit quantum computer D Wave solves optimization problems by exploiting QM effects Much of quantum computing is still theoretical and uses simulation Q#, Libquantum, IBM Q etc Simulation requires lots of memory (e.g. 32 qubits implies 2 · 232 real numbers)
  • 104. Outline Classical Search Quantum Mechanics Overview Notation Mathematics QM Background Grover’s Algorithm Explanation References
  • 105. References https://en.wikipedia.org/wiki/Grover%27s algorithm https://quantiki.org/wiki/grovers-search-algorithm Quantum Mechanics for Scientists and Engineers - David Miller https://web.eecs.umich.edu/ imarkov/pubs/jour/cise05- grov.pdf