Ang pahinang ito ay hindi pa naisalin. Nakikita mo ang orihinal na bersyon sa Ingles.
Now we'll analyze Grover's algorithm to understand how it works.
We'll start with what could be described as a symbolic analysis, where we calculate how the Grover operation G acts on certain states, and then we'll tie this symbolic analysis to a geometric picture that's helpful for visualizing how the algorithm works.
The set A1 contains all of the solutions to our search problem while A0 contains the strings that aren't solutions (which we can refer to as non-solutions when it's convenient).
These two sets satisfy A0∩A1=∅ and A0∪A1=Σn, which is to say that this is a bipartition of Σn.
Next we'll define two unit vectors representing uniform superpositions over the sets of solutions and non-solutions.
Formally speaking, each of these vectors is only defined when its corresponding set is nonempty, but hereafter we're going to focus on the case that neither A0 nor A1 is empty.
The cases that A0=∅ and A1=∅ are easily handled separately, and we'll do that later.
As an aside, the notation being used here is common: any time we have a finite and nonempty set S, we can write ∣S⟩ to denote the quantum state vector that's uniform over the elements of S.
Let's also define ∣u⟩ to be a uniform quantum state over all n-bit strings:
∣u⟩=N1x∈Σn∑∣x⟩.
Notice that
∣u⟩=N∣A0∣∣A0⟩+N∣A1∣∣A1⟩.
We also have that ∣u⟩=H⊗n∣0n⟩, so ∣u⟩ represents the state of the register Q after the initialization in step 1 of Grover's algorithm.
This implies that just before the iterations of G happen in step 2, the state of Q is contained in the two-dimensional vector space spanned by ∣A0⟩ and ∣A1⟩, and moreover the coefficients of these vectors are real numbers.
As we will see, the state of Q will always have these properties — meaning that the state is a real linear combination of ∣A0⟩ and ∣A1⟩ — after any number of iterations of the operation G in step 2.
We'll now turn our attention to the Grover operation
G=H⊗nZORH⊗nZf,
beginning with an interesting observation about it.
Imagine for a moment that we replaced the function f by the composition of f with the NOT function — or, in other words, the function we get by flipping the output bit of f.
We'll call this new function g, and we can express it using symbols in a few alternative ways.
g(x)=¬f(x)=1⊕f(x)=1−f(x)={10f(x)=0f(x)=1
Notice that
(−1)g(x)=(−1)1⊕f(x)=−(−1)f(x)
for every string x∈Σn, and therefore
Zg=−Zf.
This means that if we were to substitute the function f with the function g, Grover's algorithm wouldn't function any differently — because the states we obtain from the algorithm in the two cases are necessarily equivalent up to a global phase.
This isn't a problem!
Intuitively speaking, the algorithm doesn't care which strings are solutions and which are non-solutions — it only needs to be able to distinguish solutions and non-solutions to operate correctly.
As we already noted, the state of Q just prior to step 2 is contained in the two-dimensional space spanned by ∣A0⟩ and ∣A1⟩, and we have just established that G maps any vector in this space to another vector in the same space.
This means that, for the sake of the analysis, we can focus our attention exclusively on this subspace.
To better understand what's happening within this two-dimensional space, let's express the action of G on this space as a matrix,
whose first and second rows/columns correspond to ∣A0⟩ and ∣A1⟩, respectively.
So far in this series, we've always connected the rows and columns of matrices with the classical states of a system, but matrices can also be used to describe the actions of linear mappings on different bases like we have here.
While it isn't at all obvious at first glance, the matrix M is what we obtain by squaring a simpler-looking matrix.
This angle θ is going to play a very important role in the analysis that follows, so it's worth stressing its importance here as we see it for the first time.
In light of this expression of this matrix, we observe that
This is because rotating by the angle θ two times is equivalent to rotating by the angle 2θ.
Another way to see this is to make use of the alternative expression
θ=cos−1(N∣A0∣),
together with the double angle formulas from trigonometry:
cos(2θ)sin(2θ)=cos2(θ)−sin2(θ)=2sin(θ)cos(θ).
In summary, the state of the register Q at the start of step 2 is
Now let's connect the analysis we just went through to a geometric picture.
The idea is that the operation G is the product of two reflections,
Zf and H⊗nZORH⊗n.
And the net effect of performing two reflections is to perform a rotation.
Let's start with Zf.
As we already observed previously, we have
Zf∣A0⟩Zf∣A1⟩=∣A0⟩=−∣A1⟩.
Within the two-dimensional vector space spanned by ∣A0⟩ and ∣A1⟩,
this is a reflection about the line parallel to ∣A0⟩, which we'll call L1.
Here's a figure illustrating the action of this reflection on a hypothetical unit vector ∣ψ⟩,
which we're assuming is a real linear combination of ∣A0⟩ and ∣A1⟩.
Second we have the operation H⊗nZORH⊗n, which we've already seen can be written as
H⊗nZORH⊗n=2∣u⟩⟨u∣−I.
This is also a reflection, this time about the line L2 parallel to the vector ∣u⟩.
Here's a figure depicting the action of this reflection on a unit vector ∣ψ⟩.
When we compose these two reflections, we obtain a rotation — by twice the angle between the lines of reflection — as this figure illustrates.
This explains, in geometric terms, why the effect of the Grover operation is to rotate linear combinations of ∣A0⟩ and ∣A1⟩ by an angle of 2θ.