0% found this document useful (0 votes)
22 views14 pages

Grover Agorlithm LEZ2

GroverAgorlithmLEZ2

Uploaded by

Shaheer Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views14 pages

Grover Agorlithm LEZ2

GroverAgorlithmLEZ2

Uploaded by

Shaheer Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

An Introduction to Grover’s

Search Algorithm

M. Grossi – IBM Quantum


In collaboration with F. Tramonto

M. Grossi - IBM Italy -DO NOT DISTRIBUTE 1


Grover’s Search Algorithm
Applications
• Searches in a non–ordered list
• Example: Search a phone book for a specifc number
Lov Grover
• Travelling salesman problem (TSP)

Speedup?
Classical search: ! " steps
Grover’s Algorithm search: ! " steps

M. Grossi - IBM Italy -DO NOT DISTRIBUTE 2


The problem
Given a boolean function !(#)
) 1, if # = # ∗
! # : 0,1 → 0,1 , ! # =,
0, if # ≠ # ∗
find the value of # such that ! # = 1, that is find # ∗ .

)
A remind: x ∈ 0,1 ⟷ x = 0, 1, 2, … 7 − 1 in binary with 7 = 2) (i.e. 9 = log = 7)

Classically: worst case à 7 steps


on average à 7/2 steps ⟹ O(7) steps

M. Grossi - IBM Italy -DO NOT DISTRIBUTE 3


The idea…
Step 0) Initial state: equal superpostion of the ! = 2$ basis states |0⟩, )1⟩, |2⟩, … |! − 1⟩

Step 1)
equal 1
amplitudes A black box operator, the
Oracle 1 marks |- ∗ ⟩ with a
-∗ minus sign

If we measure now equal probability for all states

⟹ we have to amplify |- ∗⟩ to have higher probability. How?

average of all
Step 2)
amplitudes Inversion about the mean

Repeat step 1) and 2) M times M. Grossi - IBM Italy -DO NOT DISTRIBUTE 4
Schematic Circuit
Hadamard
Transform

Step 0)
Grover
Operator G

" Step 2)
Inversion about the
Step 1) mean or Grover
Diffusion Operator
M. Grossi - IBM Italy -DO NOT DISTRIBUTE 5
Hadamard Transform
Step 0) Prepare all the basis states with equal amplitude, by applying the
⨂'
Hadamard transform to the initial state |0⟩= |000 … 0⟩ = |0⟩
1 /01
⨂'
( |0⟩ = + |2⟩ ≡ |7. ⟩
2 ' ,-.

( ⨂' 1
⨂'
1 /01
(⨂' |0⟩ = (|0⟩ ⨂' = |0⟩ + |1⟩ = + |2 ⟩
2 2' ,-.

Example with 2 qubits:


|0⟩ 1 1
(⨂4|00⟩ = (|0⟩ ⨂ (|0⟩ = |0⟩ + |1⟩ ⨂ |0⟩ + |1⟩ =
2 2
1 1
= |00⟩ + |01⟩ + |10⟩ + |11⟩ = |0⟩ + |1⟩ + |2⟩ + |3⟩
24 24
M. Grossi - IBM Italy -DO NOT DISTRIBUTE 6
!
The Oracle
Oracle operator ! associated to the function "($) marks the state |$ ∗ ⟩ with a minus

! |$ ∗ ⟩ = − |$ ∗ ⟩
and leaves the other states unchanged |$ ⟩

! |$ ⟩ = |$ ⟩ if $ ≠ $ ∗
or more compactly

!|$⟩ = (−1)/(0) |$⟩


How? A way is by using an Oracle operator that exploits an ancilla qubit defined as
ancilla qubit !
| $ ⟩| 1 ⟩ |$⟩|1 ⊕ "($)⟩
1
−|0⟩ + |1⟩ , if " $ = 1 ($ = $ ∗ )
1 ! 2 1
|$ ⟩ |0⟩ − |1⟩ |$ ⟩ = (−1)/(0) |$ ⟩ |0⟩ − |1⟩
2 1 2
|0⟩ − |1⟩ , if " $ = 0 ($ ≠ $ ∗ )
2 M. Grossi - IBM Italy -DO NOT DISTRIBUTE 7
Inversion around the mean
(or Grover diffusion)
3 steps:

1) Hadamard Transform !⨂#


2) Conditional phase shift: |&⟩ → −(−1),-,/ |&⟩
3) Hadamard Transform !⨂#

step 2: the operator 2|0⟩⟨0| − 3 applied to |0⟩ it gives |0⟩


and to |&⟩ it gives −|&⟩ , if & ≠ 0

Combining all 3 steps: !⨂# 2|0⟩⟨0| − 3 !⨂# = 2|67⟩⟨67| − 3

With the Oracle the Grover operator G ≡ 2|67⟩⟨67| − 3 :


M. Grossi - IBM Italy -DO NOT DISTRIBUTE 8
Geometric representation |0 ⟩

|# ⟩ =
%
∑ |/ ⟩ |2.⟩
&'( *,, * -.
sum of states that aren’t solution
:/2
|# ⟩
%
|0 ⟩ = ∑ |/ ⟩ sum of states that are solution
( *,, * -%

|#⟩ and |0⟩ generate a 2-dimensional subspace 1 and |2.⟩ belong to 1 :

3−5 5
|2.⟩ = |# ⟩ + |0 ⟩
3 3 |0 ⟩
: :
|2.⟩ = cos |#⟩ + sin |0⟩
2 2
If apply > to a state of 1: |2.⟩
:/2
> ? |# ⟩ + @ |0 ⟩ = ? |# ⟩ − @ |0 ⟩ |# ⟩
the sign of the |0⟩ component changes >|2.⟩
M. Grossi - IBM Italy -DO NOT DISTRIBUTE 9
Geometric representation 2
&
By applying G ! |$%⟩ goes to an angle '
+ ) respect to |*⟩
|2 ⟩
at each iteration ! add an angle ) : ! |$%⟩
) )
! |$%⟩ = cos + ) |*⟩ + sin + ) |2⟩
2 2 ) |$%⟩
5 )/2
! 3 |$%⟩ = cos )3 |*⟩ + sin )3 |2⟩, )3 = 4 + ) |* ⟩
'
=|$%⟩
When stop the iterations?
7 5 7 |2 ⟩
Nearer possible to |2⟩ )3 ≃ 4≃ − 1
' ' &
! 3 |$%⟩
1 π
4 = CI −1 == >/@ )3
2 ) |$%⟩
)5
For calculation details see, for example, |* ⟩
Nielsen, Chuang – Quantum Computation and Quantum Information
M. Grossi - IBM Italy -DO NOT DISTRIBUTE 10
Now let’s apply the algorithm…

M. Grossi - IBM Italy -DO NOT DISTRIBUTE 11


M. Grossi - IBM Italy -DO NOT DISTRIBUTE 12
Example: 2 Qubits

M. Grossi - IBM Italy -DO NOT DISTRIBUTE 13


%
| # ⟩| $ ⟩ |#⟩|$ ⊕ '(#)⟩
If |$⟩ = |0⟩
% |1⟩ , if ' # = 1 (# = # ∗ )
|# ⟩|0⟩ |# ⟩|'(#)⟩ = |# ⟩ ,
|0⟩ , if ' # = 0 (# ≠ # ∗ )
If |$⟩ = |1⟩

% |0⟩ , if ' # = 1 (# = # ∗ )
|# ⟩|1⟩ |# ⟩|1 ⊕ '(#)⟩ = |# ⟩ ,
|1⟩ , if ' # = 0 (# ≠ # ∗ )

3
If |$⟩ = |0⟩ − |1⟩
4
1
−|0⟩ + |1⟩ , if ' # = 1 (# = # ∗ )
1 % 2 1
|# ⟩ |0⟩ − |1⟩ |# ⟩ = (−1)8(9) |# ⟩ |0⟩ − |1⟩
2 1 2
|0⟩ − |1⟩ , if ' # = 0 (# ≠ # ∗ )
2

M. Grossi - IBM Italy -DO NOT DISTRIBUTE 14

You might also like