Grover's Search
Part of Womanium Quantum + AI 2024 program
Definition
Grover's search is unstructured quantum search algorithm that provides a clear quantum advantage over classical unstructured search.
Grover's search helps to speed up general functions with no other promises. (quadratic speed up)
Searching a function f:{0,1}^2 -> {0,1} to find x such that f(x) = 1
- Classical approach is a linear search with a complexity of
- Quantum approach gives a complexity of
Grover's Algorithm
Grover's Algorithm works by repeating a specific process multiple times to ultimately increase the probability of measuring the "correct" answer. This process of increasing the probability of the right answer is known as amplitude amplification.
Grover's Algorithm makes use of a quantum oracle that can indicate the "correct" answer, which is the target of the search.
There are different ways to illustrate this algorithm, two of which are inversion around the mean and phase rotations.
Grover's Operator ( )
Where
negates the phase if is the all 0 string.
This is basically an identity matrix where the first entry is -1.
encodes oracle function , It's encoded using phase kickback such that the oracle’s results are stored in the phase.
Inversion Around the Mean
Let’s assume we have 8 options, but only 1 option is correct.
The algorithm start by setting an equal probability of measurement to each options (i.e. uniform superposition).
Then the oracle is queried, by doing that, the oracle "stores" the answer in the phase of the correct option, in other words it flips the phase of the correct option.
Now we apply Grover's operator (
Where:
is the mean of the amplitudes. is the amplitude of option .
The Grover's operator is defined in unitary operators as:
The
qubit is needed to enable the oracle to apply phase kickback.
This will lower the amplitude of all options except the option with an inverted phase, i.e. the correct answer.
The figure clearly shows the amplification effect of the algorithm.
Finally, we repeat
It's important to note that we are not exploring all options at once, as most people think, instead we manipulating the probability of measuring a specific result.
We are starting the algorithm with a superposition of all possible options, therefore it's only one quantum state and not multiple.
Applying Grover's Operator
To able to see how Grover's operator (
such that
is known as the diffusion operator, and it inverts the amplitudes about .
where we define
Finally, we can represent
Now we plug in
But we know that
is the sum of the amplitudes of all options divided by their number, which means it's the mean
The final step to complete
We can see now that
Phase Rotations
We start by splitting our set of options into two sets, set
We show that as:
Now we define these sets as state vectors
The set
The overall system state
Since now we need to apply our operations on
Applying Grover's Operator
In phase rotations representation it's beneficial to change the grouping of the operator from what we did last time. We group the operator as follows:
We notice that the first part is similar to
Now for
We also know that
Now, we start applying the operator to the system then expanding it out to the state vectors
Now we can apply the operator to each state vector separately.
This makes sense because
has an equal amplitude for all options and has 1s only for the set strings.
Now we apply
Finally, we get it all together to finish applying
as a Rotation Operator
Let's define
We notice that we can rewrite this matrix as
which is similar to the rotation matrix in Euclidean space
Therefore, we can represent
Grover's operator is two rotation operators in Euclidean space, where:
such that after
where the goal of the algorithm is to maximize
Here we draw one application of
, in purple, is the starting state. , in orange, is the state after applying the oracle. , in green, is the state after applying .
Notice that the starting state
Calculating
Since out goal is to get
Since the use of this algorithm only makes sense when we have a massive number of options to search through, we can assume that
And therefore, we can approximate
The computed value of
Complexity Analysis
We can assume that
For the worst-case scenario we will assume
This proves that Grover's search algorithm offers a quadratic speed up over classical search of unstructured data.
Classical Search | Grover's Search |
---|---|
Circuit Implementation of the Diffusion Operator ( )
We discussed the application and effect of Grover's diffusion operator
Let's see how we can implement that in a circuit. Note that we will be implementing
Now let's expand the form
We can see that we have two Hadamard operators at each end which we can simply implement with two Hadamard gates. Since we know how to implement the Hadamard operators, let's discard of them.
But from constructing the diffusion operator earlier we know that the remaining part is just flipping the sign of the zero state
Finally, we can implement the diffusion operator as shown in the image:
Notice that we can apply the MCZ gate to an arbitrary target since it would result in the same effect of flipping the sign of the entire state.
We also notice that the target bit of the Z gate is not contributing to the control, and that's because it is indirectly controlling the application of the Z gate, since
Summary
Grover's algorithm employs the following steps:
-
Let
be an n-qubit register, initialized to . Using Hadamard gates , put in a uniform superposition: -
Apply the unitary transformation
to register times. -
Measure register
and output result.
Grover's search algorithm offer a quadratic speed up over classical search (linear search) for unstructured data.