The previous quantum algorithms show explicitly some instances in which a quantum computer beats a classical computer, as was advanced in Sec. VIII.A de-voted to quantum Turing machines. However, they also present several drawbacks:
(i) utility: it is not clear what they are useful for in practical applications.
(ii) structure: the searched functions are constrained to comply with certain promises. Thus we may feel as if those constraints quantumly conspire in favor of the Deutsch-Jozsa and Simon algorithms.
Grover’s algorithm (Grover, 1996, 1997) represents an example of an unstructured problem: one in which no assumptions are made about the function f under scru-tiny. Thus we can contrast classical and quantum algo-rithms on equal footing. Although it came after Shor’s algorithm (Shor, 1994), we present it first because it is quite related to the previous algorithms.
The algorithm by Grover solves the problem of searching for an element in a list of N unsorted ele-ments, similar to searching a database like a telephone directory when we know the number but not the per-son’s name. When the size of the database becomes very large, this is known to be one of the basic problems in computational science (Knuth, 1975). The utility of such an algorithm is guaranteed. Classically one may devise many strategies to perform this search, but if the ele-ments in the list are randomly distributed, then we shall need to make O(N) trials in order to have a high con-fidence of finding the desired element. Grover’s quan-tum searching algorithm takes advantage of quanquan-tum- quantum-mechanical properties to perform the search with an efficiency of order O(
冑
N) (Grover, 1996, 1997).Let us state the searching problem in terms of a list L关0,1,...,N⫺1兴 with a number N of unsorted elements.
We shall denote by x0 the marked element inL that we are looking for. The quantum-mechanical solution to this searching problem goes through the preparation of a quantum register in a quantum computer to store the N items of our list. This will allow exploit quantum par-allelism. Let us assume that a quantum register is made of n source qubits so that N⫽2n. We shall also need another register with a target qubit to store the output of function evaluations or calls.
To implement the quantum search we need to con-struct a unitary operation that discriminates between the marked item x0 and the rest. The following function,
fx
0共x兲ª
再
01 ifif x⫽xx⫽x00, (106)and its corresponding unitary operation (95), Uf
x0兩x典兩y典⫽兩x典兩y丣fx0共x兲典, (107) will do the job. We shall need to count how many appli-cations of this operation or oracle calls are needed to find the item. The rationale behind the Grover algo-rithm is (1) to start with a quantum register in a state in
47Sometimes one introduces, for didactical purposes, a fur-ther step in which the target qubits are measured (Jozsa, 1998).
which all the computational basis states are equally present; and (2) to apply several unitary transformations to produce an output state in which the probability of catching the marked state 兩x0典 is large enough.
We now present the steps in Grover’s algorithm, with the quantum circuit shown in Fig. 35.
Step 1. Initialize the quantum registers to the state 兩⌿1典ª兩00¯0典兩1典.
Step 2. Apply bitwise the Hadamard one-qubit gate [Eq.
(75)] to the source register so as to produce a uniform superposition of basis states in the source register, and also to the target register:
兩⌿2典ªUH丢(n⫹1)兩⌿1典
⫽ 1
2(n⫹1)/22x
兺
⫽0n⫺1
兩x典y
兺
⫽0,1共⫺1兲y兩y典. (108)Step 3. Apply the operator Uf
x0: 兩⌿3典ªUfx
0兩⌿2典
⫽2⫺(n⫹1)/22x
兺
⫽0n⫺1
共⫺1兲fx0(x)兩x典y
兺
⫽0,1共⫺1兲y兩y典.(109) Let Ux
0 be the operator defined by Ux
0兩x典ª共1⫺2兩x0典具x0兩兲兩x典⫽
再
⫺兩x兩x典 0典if xif x⫽x⫽x0, 0(110) that is, it flips the amplitude of the marked state, leaving the remaining source basis states unchanged. Grover
presents this operator graphically as in Fig. 36, with a sort of ‘‘quantum comb’’ in which the spikes denote the uniform amplitudes of state (108) and the action of Ux
0
is to flip over the spike corresponding to the marked item. We realize that the state in the source register of Eq. (109) equals precisely the result of the action of Ux
0, i.e.,
兩⌿3典⫽共关1⫺2兩x0典具x0兩兴丢1兲兩⌿2典. (111) Step 4. Apply the operation D known as inversion about the average (Grover, 1996, 1997). This operator is de-fined as follows:
Dª⫺共UH丢
n丢I兲Uf0共UH丢
n丢I兲, (112)
where Uf
0 is the operator in Eq. (109) for x0⫽0. The effect of this operator on the source qubits is to trans-form 兺x␣x兩x典哫兺x(⫺␣x⫹2具␣典)兩x典, where 具␣典 ª2⫺n兺x␣x is the mean of the amplitudes, so its net ef-fect is to enhance the amplitude of 兩x0典 over the rest.
This is graphically represented in Fig. 37 (Grover, 1996, 1997).
Step 5. Iterate Steps 3 and 4 a number of times m.
Step 6. Measure the source qubits (in the computational basis). The number m is determined such that the prob-ability of finding the searched item x0 is maximal.
The basic component of the algorithm is the quantum operation encoded in Steps 3 and 4, which is repeatedly applied to the uniform state 兩⌿2典 in order to find the marked element. Although this procedure resembles the classical strategy, Grover’s neatly designed operation en-hances by constructive interference of quantum ampli-tudes (see Table V) the presence of the desired marked state.
It is possible to give a more general formulation to the operators entering Steps 3 and 4 of the algorithm (Gal-indo and Martin-Delgado, 2000). To this end it is suffi-cient to focus on the source qubits and introduce the following definitions.
(i) A Grover operator G is any unitary operator with at most two different eigenvalues, i.e., G a linear superposition of two orthogonal projectors P and Q:
G⫽␣P⫹Q, P2⫽P, Q2⫽Q, P⫹Q⫽1, (113) where␣,苸C are complex numbers of unit norm.
(ii) A Grover kernel K is the product of two Grover FIG. 35. Quantum circuit (up to an irrelevant global sign
fac-tor) for Grover’s algorithm.
FIG. 36. Schematic representation of Grover’s operator Ux0in Eq. (110).
FIG. 37. Schematic representation of Grover’s operator D in Eq. (112). The dashed line represents the mean amplitude.
operators:
K⫽G2G1. (114)
Some elementary properties follow immediately from these definitions:
(a) Any Grover kernel K is a unitary operator.
(b) Let the Grover operators G1,G2 be chosen such that
G1⫽␣Px0⫹Qx0, Px
0⫹Qx0⫽1,
G2⫽␥P¯⫹␦Q¯ , P¯⫹Q¯⫽1, (115) with Px
0⫽兩x0典具x0兩, and P¯ given by the rank 1 ma-trix
P¯ª1
N
冉
1⯗1 ¯ 1¯ 1⯗冊
. (116)This is clearly a projector P¯⫽兩k0典具k0兩 on the sub-space spanned by the state 兩k0典
⫽ (1/
冑
N) (1, . . . ,1)t, where the superscript de-notes the transpose. Then, if we take the following set of parameters,␣⫽⫺1, ⫽1, ␥⫽⫺1, ␦⫽1, (117)
the Grover kernel (114) reproduces the original Grover’s choice (1996, 1997). This property follows immediately by construction. In fact, we have in this case G1⫽1⫺2Px0⫽..Gx0 while the operator G2⫽1⫺2P¯ coincides (up to a sign) with the diffu-sion operator D (112) introduced by Grover to implement the inversion about the average of Step 4.
The iterative part of the algorithm in Step 5 corre-sponds to applying m times the Grover kernel K to the initial state 兩xin典ª2⫺n/2兺x兩x典, which describes the source qubits after Step 2, searching for a final state兩xf典 of the form
兩xf典ªKm兩xin典, (118)
such that the probability p(x0) of finding the marked state is above a given threshold value. We may take this value to be 1/2, meaning that we choose a probability of success of 50% or larger. Thus we are seeking under which circumstances the condition
p共x0兲⫽円具x0兩Km兩xin典円2⭓1/2 (119) holds true.
The analysis of this probability gets simplified if we realize that the evolution associated with the searching problem can be mapped onto a reduced 2D space spanned by the vectors
兵
兩x0典,兩x⬜典ª 1冑
N⫺1x兺
⫽x0
兩x典. (120)
Then we can easily compute the projections of the Grover operators G1,G2 in the reduced basis with the result
G1⫽
冉
␣0 0冊
, (121)G2⫽
冉
␦0 ␥0冊
⫹共␥⫺␦兲冉 冑
N⫺1NN1冑
N⫺1⫺1NN冊
. (122)From now on, we shall fix two of the phase parameters using the freedom we have to define each Grover factor in Eq. (114) up to an overall phase. Then we decide to fix them as follows:
␣⫽␥⫽⫺1. (123)
With this choice, the Grover kernel (112) takes the fol-lowing form in this basis:
K⫽ 1
N
冉
共1⫹1⫹␦␦共1⫺N兲兲冑
N⫺1 ⫺共1⫹共1⫹␦␦兲⫺N兲冑
N⫺1冊
. (124)The source state 兩xin典 has the following components in the reduced basis:
兩xin典⫽ 1
冑
N兩x0典⫹冑
NN⫺1兩x⬜典. (125) In order to compute the probability amplitude in Eq.(119), we introduce the spectral decomposition of the Grover kernel K in terms of its eigenvectors兵兩1典,兩2典其, with eigenvalues ei1,ei2. Thus we have
a共x0兲ª具x0兩Km兩xin典
⫽ 1
冑
Nj兺
⫽12 兵兩具x0兩j典兩2⫹冑
N⫺1具x0兩j典具j兩x⬜典其eimj.(126) This in turn can be cast into the following closed form:
具x0兩Km兩xin典⫽eim1
冉 冑
1N⫹共eim⌬⫺1兲具x0兩2典⫻具2兩xin典
冊
, (127)with ⌬ª2⫺1.
In terms of the matrix invariants
DetK⫽␦, TrK⫽⫺共⫹␦兲⫹共1⫹兲共1⫹␦兲1 N,
(128) the eigenvalues 1,2ªei1,2are given by
1,2⫽12TrK⫿
冑
⫺DetK⫹14共TrK兲2. (129) The corresponding un-normalized eigenvectors are兩1,2典⬀
冉
A⫿冑
2⫺4共DetK兲N共1⫹␦1兲冑
N⫺12⫹A2冊
, (130)with
Aª共⫺␦兲N⫹共1⫺兲共1⫹␦兲. (131) Although we could work out all the expressions for a generic value N of elements in the list, we shall restrict our analysis to the case of a large number of elements, N→⬁ (see Fig. 38). Thus, in this asymptotic limit, we need to know the behavior for NⰇ1 of the eigenvector 兩2典, which turns out to be
兩2典⬀
冉
1⫹⫺␦␦冑
N⫹O1冉 冑
1N冊 冊
. (132)For generic values of,␦ we observe that the first com-ponent of the eigenvector dominates the second one, meaning that asymptotically 兩2典⬃兩x0典 and then 具x0兩2典具2兩xin典⫽O(1/
冑
N). This implies that the prob-ability of success in Eq. (127) will never reach the threshold value (119). Then we are forced to tune the values of the two parameters in order to have a well-defined and nontrivial algorithm, and we require⫽␦⫽⫺1. (133)
Now the asymptotic behavior of the eigenvector changes and is given by a balanced superposition of marked and unmarked states, as
兩2典⬃ 1
&
冉
i␦11/2冊
. (134)This is normalized, and we see that none of the compo-nents predominates. When we insert this expression into Eq. (127) we find
円具x0兩Km兩xin典円⬃12兩␦兩兩eim⌬⫺1兩⬃兩sin共12m⌬兲兩. (135) This result means that we have succeeded in finding a class of algorithms that are appropriate for solving the quantum searching problem. Now we need to find out how efficient they are. To do this let us denote by M the smallest value of the time step m at which the probabil-ity becomes maximum; then, asymptotically,48
M⬃关兩/⌬兩兴. (136)
As it happens, we are interested in the asymptotic be-havior of this optimal period of time M. From Eq. (129) we find the following behavior as N→⬁:
⌬⬃ 4
冑
NRe冑
␦. (137)If we parametrize ␦⫽ei, we finally obtain the expres-sion
M⬃
冋
4 cos 2冑
N册
. (138)Therefore we conclude that Grover’s algorithm of the class parametrized by is a well-defined quantum searching algorithm with an efficiency of order O(
冑
N).There have been many applications of Grover’s work to quantum searching: for example, finding the mean and median of a given set of values (Grover, 1996), searching the maximum/minimum (Durr and Hoyer, 1996), searching more than one marked item (Boyer et al., 1998), and quantum counting, i.e., finding the number of marked items without caring about their lo-cation (Brassard, Hoyer, and Tapp, 1998). There is also a nice geometrical interpretation of the Grover kernel K
⫽⫺G2G1 in terms of two reflections G1 and⫺G2, one about兩x⬜典 and the other about兩xin典, producing a simple rotation of the initial state (Jozsa, 1999) by an angle
⫽2 arcsin(1/
冑
N) in the plane spanned by兩x0典 and兩x⬜典. With this construction it is straightforward to arrive at the following exact condition for the optimal value m of iterations:m⫽
冋
12冉
2 arcsin冑
1N⫺1冊册
. (139)Finally, it has been shown that Grover’s algorithm is optimal (Bennett, Bernstein, et al., 1997; Zalka, 1999), that is, its quadratic speedup cannot be improved for unstructured lists.