QC Lec11
QC Lec11
October 9, 2003
In this lecture we will cover several applications of Grover’s search algorithm, and show that
Grover’s search algorithm is optimal.
O|x� = −|x� if x ∈ T,
O|x� = |x� otherwise.
We�want to find elements in the target set T. If there are N |x�’s and M targets, after
N
c· M iterations of G, most amplitude will be in the target set. The following operator G
is performed in each iteration:
In addition to perform the search of a target in a set of elements, the Grover’s search algorithm
has other possible applications. Here we will demonstrate how to use Grover’s search algorithm to
speed up classical algorithms, and do target counting.
3SAT: Given a boolean formula of totally n variables in conjunctive normal form with at most 3
variables in each clause, ex. (x1 ∨ x3 ∨ x7 ) ∧ (x1 ∨ x¯5 ∨ x9 ) ∧ (x2 ∨ x¯3 ∨ x11 ) . . ., we want to
know if there exist a set of {xi , i = 1 . . . n} such that the whole formula is satisfied.
1
P. Shor – 18.435/2.111 Quantum Computation – Lecture 11 2
Using the 3SAT problem as an example, classically we have to search exhaustively and try every
set of values, therefor the algorithm takes 2n time. Here we will show that the problem can be done
using the Grover’s search algorithm in 2n/2 time.
A better way to start is to find a maximal set of disjoint clauses in the formula. We can rename
the variables and write the formula as
= M ± NAM
� � �
N
= M 1 ± AM
�
N
Therefore, M (1 + ε) = M (1 ± AM ). To get M within ±ε range, we need to sample A times,
N
where A ≈ M ε2
.The efficient of the estimation is ∼ 1/ε2 .
We can use Grover’s algorithm to improve the performance. Recall that in the Grover’s search
algorithm, if we define
�
|α� = √N1−M |x�
�x∈T
/
|β� = √1 |x�,
M
x∈T
what Grover’s algorithm does in each iteration is�to rotate the state vector in the |α�, |β� basis
θ
counterclockwise for θ angle, where 2 = arcsin( MN ). In the |α�, |β� basis, we can write the G
operator as a rotation matrix (for N � M ):
� �
cos θ − sin θ
G= .
sin θ cos θ
P. Shor – 18.435/2.111 Quantum Computation – Lecture 11 3
The eigenvalues of the matrix are e±iθ . Therefore, we can use phase estimation algorithm to obtain
the phase factor θ, and compute the number of targets in the set. Figure 1. shows the circuit for
approximate quantum counting to t qubits accuracy on a quantum computer.
We now analyze the efficiency of the quantum counting algorithm. Suppose we get θ to t bits
accuracy, i.e. θest = θ ± 21t . We need 2t calls to the function. By the definition of θ, we have
θ M
sin2= .
2 N
To estimate the error, we take the derivative on both side to obtain the relationship between the
change of θ, δθ, and the change of M , δM :
θ θ δM
2 sin cos · δθ = .
2 2 N
Using N � M, and θ � 1, we obtain
√
�
M θ
δM = 2N δθ cos ≤ 2δθ M N .
N 2
√ �
We define εM = δM ≈ 2δθ M N , so δθ = M · 2 . Therefore, in terms of ε, the number of calls
� N ε
needed to get to the accuracy of ε is ∼ M 2
N · ε . This is the squareroot of what we need in the
classical algorithm.
√ √
1 − ε|x� + ε|g� ≈ Un Ox . . . U3 Ox U2 Ox U1 Ox |ψ�,
where |g� is composed of states ⊥ to |x�. For a successful algorithm, the outcome of the operations
should be very close to the target state, that is, ε has to be very small.
Let’s also define
��
�Ox (|ψkx � − |ψk �)�2 + 2�Ox (|ψkx � − |ψk �)� · �(Ox − I)|ψk �� + �(Ox − I)|ψk ��2
�
Dk+1 ≤
�x � �
≤ �|ψkx � − |ψk ��2 + 2 · �|ψkx � − |ψk �� · �(Ox − I)|ψk �� + �(Ox − I)|ψk ��2
x � x x
≤ Dk + 4 · �|ψkx � − |ψk �� · ��x|ψk � · |x�� + 4,
x
(2)
where we have used the property that the unitary operator Ox preserves the norm and Ox − I =
−2|x��x|. Now apply the Cauchy’s inequality,
� �� �
�|ψkx � − |ψk �� · ��x|ψk � · |x�� ≤ �|ψkx � − |ψk ��2 · ��x|ψk � · |x��2 ,
x x
Hence we have shown that the best you can do to distinguish the target states and other states
using j operations is Dj ≤ 4 · j 2 . Note that the least distance√you need to distinguish target states
in totally N states is Dleast ≈ O(N ). Therefore, at least k ∼ N is necessary to solve the Grover’s
problem. This shows that you can not do better than Grover’s algorithm.